From 3c95d6d43e69c75c34ddc35b8612d27bd9b0430c Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Wed, 28 May 2025 19:10:11 +1000 Subject: [PATCH 01/67] start of 3.0 Silk.Net.Maths rewrite From 04846e7715fc6cb0e0e5d2107dc8a1da52dda4f3 Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Wed, 28 May 2025 20:27:39 +1000 Subject: [PATCH 02/67] Start work on Vector2I. --- .../Maths/Maths/{ => Legacy}/Vector2D.Ops.cs | 0 sources/Maths/Maths/{ => Legacy}/Vector2D.cs | 0 .../Maths/Maths/{ => Legacy}/Vector3D.Ops.cs | 0 sources/Maths/Maths/{ => Legacy}/Vector3D.cs | 0 .../Maths/Maths/{ => Legacy}/Vector4D.Ops.cs | 0 sources/Maths/Maths/{ => Legacy}/Vector4D.cs | 0 sources/Maths/Maths/Vector2I.cs | 96 +++++++++++++++++++ 7 files changed, 96 insertions(+) rename sources/Maths/Maths/{ => Legacy}/Vector2D.Ops.cs (100%) rename sources/Maths/Maths/{ => Legacy}/Vector2D.cs (100%) rename sources/Maths/Maths/{ => Legacy}/Vector3D.Ops.cs (100%) rename sources/Maths/Maths/{ => Legacy}/Vector3D.cs (100%) rename sources/Maths/Maths/{ => Legacy}/Vector4D.Ops.cs (100%) rename sources/Maths/Maths/{ => Legacy}/Vector4D.cs (100%) create mode 100644 sources/Maths/Maths/Vector2I.cs diff --git a/sources/Maths/Maths/Vector2D.Ops.cs b/sources/Maths/Maths/Legacy/Vector2D.Ops.cs similarity index 100% rename from sources/Maths/Maths/Vector2D.Ops.cs rename to sources/Maths/Maths/Legacy/Vector2D.Ops.cs diff --git a/sources/Maths/Maths/Vector2D.cs b/sources/Maths/Maths/Legacy/Vector2D.cs similarity index 100% rename from sources/Maths/Maths/Vector2D.cs rename to sources/Maths/Maths/Legacy/Vector2D.cs diff --git a/sources/Maths/Maths/Vector3D.Ops.cs b/sources/Maths/Maths/Legacy/Vector3D.Ops.cs similarity index 100% rename from sources/Maths/Maths/Vector3D.Ops.cs rename to sources/Maths/Maths/Legacy/Vector3D.Ops.cs diff --git a/sources/Maths/Maths/Vector3D.cs b/sources/Maths/Maths/Legacy/Vector3D.cs similarity index 100% rename from sources/Maths/Maths/Vector3D.cs rename to sources/Maths/Maths/Legacy/Vector3D.cs diff --git a/sources/Maths/Maths/Vector4D.Ops.cs b/sources/Maths/Maths/Legacy/Vector4D.Ops.cs similarity index 100% rename from sources/Maths/Maths/Vector4D.Ops.cs rename to sources/Maths/Maths/Legacy/Vector4D.Ops.cs diff --git a/sources/Maths/Maths/Vector4D.cs b/sources/Maths/Maths/Legacy/Vector4D.cs similarity index 100% rename from sources/Maths/Maths/Vector4D.cs rename to sources/Maths/Maths/Legacy/Vector4D.cs diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs new file mode 100644 index 0000000000..d3fd8fea4b --- /dev/null +++ b/sources/Maths/Maths/Vector2I.cs @@ -0,0 +1,96 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + + +using System.Collections; +using System.Numerics; + +namespace Silk.NET.Maths +{ + /// A structure representing a 2D integer vector. + internal struct Vector2I : IEquatable>, IReadOnlyList, ISpanFormattable + where T : IBinaryInteger + { + /// The X component of the vector. + public T X; + + /// The Y component of the vector. + public T Y; + + /// Creates a vector whose elements have the specified values. + /// The value to assign to the field. + /// The value to assign to the field. + public Vector2I(T x, T y) => (X, Y) = (x, y); + + ///Gets the component at the specified index: 0 = X, 1 = Y. + public T this[int index] => index switch { + 0 => X, + 1 => Y, + _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1.") + }; + + /// The number of elements in the vector. + public int Count => 2; + + /// Returns a boolean indicating whether the given Object is equal to this instance. + public bool Equals(Vector2I other) => X.Equals(other.X) && Y.Equals(other.Y); + + /// Returns an enumerator that iterates through the vector components. + public IEnumerator GetEnumerator() + { + yield return X; + yield return Y; + } + + /// Formats the vector as a string using the specified format and format provider. + public string ToString(string? format, IFormatProvider? formatProvider) + { + return $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}>"; + } + + /// Formats the vector as a string using the specified format and format provider. + public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) + { + // Format components individually into temporary buffers + // Not too sure about this implementation + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider)) + { + charsWritten = 0; + return false; + } + + // Calculate total required length: < + x + ", " + y + > + int requiredLength = 1 + xChars + 2 + yChars + 1; + + if (destination.Length < requiredLength) + { + charsWritten = 0; + return false; + } + + int pos = 0; + destination[pos++] = '<'; + + xBuffer[..xChars].CopyTo(destination[pos..]); + pos += xChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + yBuffer[..yChars].CopyTo(destination[pos..]); + pos += yChars; + + destination[pos++] = '>'; + + charsWritten = pos; + return true; + } + + /// Returns an enumerator that iterates through the vector components. + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + } +} From 7afd57ff1cd8f4b9532ffb1525a8772c3337dc93 Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Wed, 28 May 2025 20:52:29 +1000 Subject: [PATCH 03/67] Finish implementing Vector2I Interfaces. --- sources/Maths/Maths/Vector2I.cs | 151 ++++++++++++++++++++++++++++++-- 1 file changed, 143 insertions(+), 8 deletions(-) diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index d3fd8fea4b..542193478c 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -3,12 +3,22 @@ using System.Collections; +using System.Diagnostics.CodeAnalysis; using System.Numerics; +using System.Text; namespace Silk.NET.Maths { /// A structure representing a 2D integer vector. - internal struct Vector2I : IEquatable>, IReadOnlyList, ISpanFormattable + internal struct Vector2I : + IEquatable>, + IReadOnlyList, + ISpanFormattable, + ISpanParsable>, + IUtf8SpanFormattable, + IUtf8SpanParsable>, + IParsable>, + IFormattable where T : IBinaryInteger { /// The X component of the vector. @@ -17,11 +27,22 @@ internal struct Vector2I : IEquatable>, IReadOnlyList, ISpanFo /// The Y component of the vector. public T Y; - /// Creates a vector whose elements have the specified values. - /// The value to assign to the field. - /// The value to assign to the field. + /// Initializes both components to the same value. + public Vector2I(T value) => (X, Y) = (value, value); + + /// Initializes the vector with individual values for X and Y. public Vector2I(T x, T y) => (X, Y) = (x, y); + /// Initializes the vector from a span of two values. + public Vector2I(ReadOnlySpan values) + { + if (values.Length != 2) + throw new ArgumentException("Input span must contain exactly 2 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + } + ///Gets the component at the specified index: 0 = X, 1 = Y. public T this[int index] => index switch { 0 => X, @@ -43,10 +64,7 @@ public IEnumerator GetEnumerator() } /// Formats the vector as a string using the specified format and format provider. - public string ToString(string? format, IFormatProvider? formatProvider) - { - return $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}>"; - } + public string ToString(string? format, IFormatProvider? formatProvider) => $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}>"; /// Formats the vector as a string using the specified format and format provider. public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) @@ -90,7 +108,124 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan return true; } + /// Parses a span to a Vector2I instance. + public static Vector2I Parse(ReadOnlySpan s, IFormatProvider? provider) + { + if (!TryParse(s, provider, out var result)) + throw new FormatException("Invalid format for Vector2I."); + + return result; + } + + /// Parses a string to a Vector2I instance. + public static Vector2I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + + /// Tries to parse a span to a Vector2I instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) + { + result = default; + + s = s.Trim(); + if (s.Length < 5 || s[0] != '<' || s[^1] != '>') + return false; + + s = s[1..^1]; // Remove < and > + + int commaIndex = s.IndexOf(','); + if (commaIndex < 0) + return false; + + ReadOnlySpan xSpan = s[..commaIndex].Trim(); + ReadOnlySpan ySpan = s[(commaIndex + 1)..].Trim(); + + if (T.TryParse(xSpan, provider, out var x) && + T.TryParse(ySpan, provider, out var y)) + { + result = new Vector2I(x, y); + return true; + } + + return false; + } + + + /// Tries to parse a string to a Vector2I instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => + TryParse(s.AsSpan(), provider, out result); + + /// Parses a span to a Vector2I instance. + static Vector2I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + Parse(s, provider); + + /// Parses a string to a Vector2I instance. + static Vector2I IParsable>.Parse(string s, IFormatProvider? provider) => + Parse(s, provider); + + /// Tries to parse a span to a Vector2I instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => + TryParse(s, provider, out result); + + /// Tries to parse a string to a Vector2I instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => + TryParse(s, provider, out result); + /// Returns an enumerator that iterates through the vector components. IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// Formats the vector as a UTF-8 string using the specified format and format provider. + public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) + { + // Format components individually into temporary buffers + // Not too sure about this implementation + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider)) + { + bytesWritten = 0; + return false; + } + + // Estimate total required UTF-8 bytes + int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + + Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + + Encoding.UTF8.GetByteCount("<, >"); + + if (utf8Destination.Length < estimatedSize) + { + bytesWritten = 0; + return false; + } + + int totalBytes = 0; + + totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); + + bytesWritten = totalBytes; + return true; + } + + /// Parses a UTF-8 span to a Vector2I instance. + public static Vector2I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return Parse(charBuffer, provider); + } + + /// Tries to parse a UTF-8 span to a Vector2I instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return TryParse(charBuffer, provider, out result); + } } } From 249be1fc97763f1a6bb48306cf36b629a5fa6273 Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Wed, 28 May 2025 20:55:03 +1000 Subject: [PATCH 04/67] Add Vector2I Unit properties. --- sources/Maths/Maths/Vector2I.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index 542193478c..e4bca600b4 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -43,6 +43,18 @@ public Vector2I(ReadOnlySpan values) Y = values[1]; } + /// Gets a vector whose 2 elements are equal to one. + public static Vector2I One => new(Scalar.One); + + /// Gets the vector (1, 0). + public static Vector2I UnitX => new(Scalar.One, Scalar.Zero); + + /// Gets the vector (0, 1). + public static Vector2I UnitY => new(Scalar.Zero, Scalar.One); + + /// Returns a vector whose 2 elements are equal to zero. + public static Vector2I Zero => default; + ///Gets the component at the specified index: 0 = X, 1 = Y. public T this[int index] => index switch { 0 => X, From 709c14295d051c3131074189a1f395310c0bb2c4 Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Wed, 28 May 2025 21:10:07 +1000 Subject: [PATCH 05/67] Add Vector3I Maths methods. --- sources/Maths/Maths/Vector2I.cs | 99 ++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 3 deletions(-) diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index e4bca600b4..5d0befb58a 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -5,6 +5,7 @@ using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; +using System.Runtime.InteropServices; using System.Text; namespace Silk.NET.Maths @@ -55,6 +56,12 @@ public Vector2I(ReadOnlySpan values) /// Returns a vector whose 2 elements are equal to zero. public static Vector2I Zero => default; + /// Gets the squared length of the vector (dot product with itself). + public T LengthSquared => (X * X) + (Y * Y); + + /// The number of elements in the vector. + public int Count => 2; + ///Gets the component at the specified index: 0 = X, 1 = Y. public T this[int index] => index switch { 0 => X, @@ -62,9 +69,6 @@ public Vector2I(ReadOnlySpan values) _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1.") }; - /// The number of elements in the vector. - public int Count => 2; - /// Returns a boolean indicating whether the given Object is equal to this instance. public bool Equals(Vector2I other) => X.Equals(other.X) && Y.Equals(other.Y); @@ -75,9 +79,59 @@ public IEnumerator GetEnumerator() yield return Y; } + /// Computes the dot product of this vector with another vector. + public T Dot(Vector2I other) => (X * other.X) + (Y * other.Y); + + /// Computes the dot product of two vectors. + public static T Dot(Vector2I left, Vector2I right) => (left.X * right.X) + (left.Y * right.Y); + + /// Computes the cross product of this vector with another vector. + public T Cross(Vector2I other) => (X * other.Y) - (Y * other.X); + + /// Computes the cross product of two vectors. + public static T Cross(Vector2I left, Vector2I right) => (left.X * right.Y) - (left.Y * right.X); + + /// Returns a span over the vector components. + public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 2); + + /// Returns a vector with the component-wise maximum of this and another vector. + public Vector2I Max(Vector2I other) => + new Vector2I(T.Max(X, other.X), T.Max(Y, other.Y)); + + /// Returns a vector with the component-wise maximum of two vectors. + public static Vector2I Max(Vector2I left, Vector2I right) => + new Vector2I(T.Max(left.X, right.X), T.Max(left.Y, right.Y)); + + /// Returns a vector with the component-wise maximum of this vector and a scalar. + public Vector2I Max(T scalar) => + new Vector2I(T.Max(X, scalar), T.Max(Y, scalar)); + + /// Returns a vector with the component-wise maximum of a vector and a scalar. + public static Vector2I Max(Vector2I vector, T scalar) => + new Vector2I(T.Max(vector.X, scalar), T.Max(vector.Y, scalar)); + + /// Returns a vector with the component-wise minimum of this and another vector. + public Vector2I Min(Vector2I other) => + new Vector2I(T.Min(X, other.X), T.Min(Y, other.Y)); + + /// Returns a vector with the component-wise minimum of two vectors. + public static Vector2I Min(Vector2I left, Vector2I right) => + new Vector2I(T.Min(left.X, right.X), T.Min(left.Y, right.Y)); + + /// Returns a vector with the component-wise minimum of this vector and a scalar. + public Vector2I Min(T scalar) => + new Vector2I(T.Min(X, scalar), T.Min(Y, scalar)); + + /// Returns a vector with the component-wise minimum of a vector and a scalar. + public static Vector2I Min(Vector2I vector, T scalar) => + new Vector2I(T.Min(vector.X, scalar), T.Min(vector.Y, scalar)); + /// Formats the vector as a string using the specified format and format provider. public string ToString(string? format, IFormatProvider? formatProvider) => $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}>"; + /// Formats the vector as a string. + public override string ToString() => $"<{X}, {Y}>"; + /// Formats the vector as a string using the specified format and format provider. public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) { @@ -239,5 +293,44 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid Encoding.UTF8.GetChars(utf8Text, charBuffer); return TryParse(charBuffer, provider, out result); } + + // Component Operators + public static Vector2I operator +(Vector2I left, Vector2I right) => + new Vector2I(left.X + right.X, left.Y + right.Y); + + public static Vector2I operator -(Vector2I left, Vector2I right) => + new Vector2I(left.X - right.X, left.Y - right.Y); + + public static Vector2I operator *(Vector2I left, Vector2I right) => + new Vector2I(left.X * right.X, left.Y * right.Y); + + public static Vector2I operator /(Vector2I left, Vector2I right) => + new Vector2I(left.X / right.X, left.Y / right.Y); + + public static Vector2I operator %(Vector2I left, Vector2I right) => + new Vector2I(left.X % right.X, left.Y % right.Y); + + // Scalar Operators + public static Vector2I operator +(Vector2I vector, T scalar) => + new Vector2I(vector.X + scalar, vector.Y + scalar); + + public static Vector2I operator -(Vector2I vector, T scalar) => + new Vector2I(vector.X - scalar, vector.Y - scalar); + + public static Vector2I operator *(Vector2I vector, T scalar) => + new Vector2I(vector.X * scalar, vector.Y * scalar); + + public static Vector2I operator /(Vector2I vector, T scalar) => + new Vector2I(vector.X / scalar, vector.Y / scalar); + + public static Vector2I operator %(Vector2I vector, T scalar) => + new Vector2I(vector.X % scalar, vector.Y % scalar); + + // + operator: returns the vector (?) + public static Vector2I operator +(Vector2I vector) => vector; + + // - operator: returns the negated vector + public static Vector2I operator -(Vector2I vector) => + new Vector2I(-vector.X, -vector.Y); } } From 94a912d94edd9fd5eb3b30690fdf49a24430dcef Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Wed, 28 May 2025 21:25:44 +1000 Subject: [PATCH 06/67] Add more missing Vector2I requirements. --- sources/Maths/Maths/Vector2I.cs | 137 +++++++++++++++++++++++++++++++- 1 file changed, 135 insertions(+), 2 deletions(-) diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index 5d0befb58a..dfe0d5060d 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -47,14 +47,17 @@ public Vector2I(ReadOnlySpan values) /// Gets a vector whose 2 elements are equal to one. public static Vector2I One => new(Scalar.One); + /// Returns a vector whose 2 elements are equal to zero. + public static Vector2I Zero => default; + /// Gets the vector (1, 0). public static Vector2I UnitX => new(Scalar.One, Scalar.Zero); /// Gets the vector (0, 1). public static Vector2I UnitY => new(Scalar.Zero, Scalar.One); - /// Returns a vector whose 2 elements are equal to zero. - public static Vector2I Zero => default; + /// Gets a vector with all bits set for each component. + public static Vector2I AllBitsSet => new Vector2I(T.AllBitsSet, T.AllBitsSet); /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => (X * X) + (Y * Y); @@ -126,6 +129,29 @@ public Vector2I Min(T scalar) => public static Vector2I Min(Vector2I vector, T scalar) => new Vector2I(T.Min(vector.X, scalar), T.Min(vector.Y, scalar)); + /// Clamps this vector's components between the corresponding Min and Max vectors. + public Vector2I Clamp(Vector2I min, Vector2I max) => + new Vector2I(T.Clamp(X, min.X, max.X), T.Clamp(Y, min.Y, max.Y)); + + /// Clamps the components of a vector between the corresponding Min and Max vectors. + public static Vector2I Clamp(Vector2I vector, Vector2I min, Vector2I max) => + new Vector2I(T.Clamp(vector.X, min.X, max.X), T.Clamp(vector.Y, min.Y, max.Y)); + + /// Clamps this vector's components between the Min and Max scalar values. + public Vector2I Clamp(T min, T max) => + new Vector2I(T.Clamp(X, min, max), T.Clamp(Y, min, max)); + + /// Clamps the components of a vector between the Min and Max scalar values. + public static Vector2I Clamp(Vector2I vector, T min, T max) => + new Vector2I(T.Clamp(vector.X, min, max), T.Clamp(vector.Y, min, max)); + + /// Returns a vector with the absolute value of each component of this vector. + public Vector2I Abs() => new Vector2I(T.Abs(X), T.Abs(Y)); + + /// Returns a vector with the absolute value of each component of the specified vector. + public static Vector2I Abs(Vector2I vector) => + new Vector2I(T.Abs(vector.X), T.Abs(vector.Y)); + /// Formats the vector as a string using the specified format and format provider. public string ToString(string? format, IFormatProvider? formatProvider) => $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}>"; @@ -183,6 +209,55 @@ public static Vector2I Parse(ReadOnlySpan s, IFormatProvider? provider) return result; } + /// Copies the components of the vector to the specified array starting at index 0. + public void CopyTo(T[] array) => CopyTo(array, 0); + + /// Copies the components of the vector to the specified array starting at the given index. + public void CopyTo(T[] array, int startIndex) + { + if (array == null) + throw new ArgumentNullException(nameof(array)); + if (startIndex < 0 || startIndex + 2 > array.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + array[startIndex] = X; + array[startIndex + 1] = Y; + } + + /// Copies the components of the vector to the specified span starting at index 0. + public void CopyTo(Span span) => CopyTo(span, 0); + + /// Copies the components of the vector to the specified span starting at the given index. + public void CopyTo(Span span, int startIndex) + { + if (startIndex < 0 || startIndex + 2 > span.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + span[startIndex] = X; + span[startIndex + 1] = Y; + } + + /// Returns a vector where each component is the sign of the original vector's component. + public Vector2I Sign() => new Vector2I(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y))); + + /// Returns a vector where each component is the sign of the input vector's component. + public static Vector2I Sign(Vector2I vector) => + new Vector2I(T.CreateChecked(T.Sign(vector.X)), T.CreateChecked(T.Sign(vector.Y))); + + /// Copies the sign of each component from another vector to this vector's components. + public Vector2I CopySign(Vector2I signSource) => + new Vector2I(T.CopySign(X, signSource.X), T.CopySign(Y, signSource.Y)); + + /// Copies the sign of each component from another vector to a new vector. + public static Vector2I CopySign(Vector2I value, Vector2I signSource) => + new Vector2I(T.CopySign(value.X, signSource.X), T.CopySign(value.Y, signSource.Y)); + + /// Copies the sign of a scalar onto each component of this vector. + public Vector2I CopySign(T signScalar) => + new Vector2I(T.CopySign(X, signScalar), T.CopySign(Y, signScalar)); + + /// Copies the sign of a scalar onto each component of a new vector. + public static Vector2I CopySign(Vector2I value, T signScalar) => + new Vector2I(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar)); + /// Parses a string to a Vector2I instance. public static Vector2I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); @@ -294,6 +369,16 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid return TryParse(charBuffer, provider, out result); } + // Casts + + /// Explicitly casts a System.Numerics.Vector2 to a Vector2I. + public static explicit operator Vector2I(System.Numerics.Vector2 v) => + new Vector2I((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T))); + + /// Explicitly casts a Vector2I to System.Numerics.Vector2. + public static explicit operator System.Numerics.Vector2(Vector2I v) => + new System.Numerics.Vector2(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); + // Component Operators public static Vector2I operator +(Vector2I left, Vector2I right) => new Vector2I(left.X + right.X, left.Y + right.Y); @@ -332,5 +417,53 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid // - operator: returns the negated vector public static Vector2I operator -(Vector2I vector) => new Vector2I(-vector.X, -vector.Y); + + // Bitwise Operators + public static Vector2I operator &(Vector2I left, Vector2I right) => + new Vector2I(left.X & right.X, left.Y & right.Y); + + public static Vector2I operator |(Vector2I left, Vector2I right) => + new Vector2I(left.X | right.X, left.Y | right.Y); + + public static Vector2I operator ^(Vector2I left, Vector2I right) => + new Vector2I(left.X ^ right.X, left.Y ^ right.Y); + + public static Vector2I operator &(Vector2I vector, T scalar) => + new Vector2I(vector.X & scalar, vector.Y & scalar); + + public static Vector2I operator &(T scalar, Vector2I vector) => + new Vector2I(scalar & vector.X, scalar & vector.Y); + + public static Vector2I operator |(Vector2I vector, T scalar) => + new Vector2I(vector.X | scalar, vector.Y | scalar); + + public static Vector2I operator |(T scalar, Vector2I vector) => + new Vector2I(scalar | vector.X, scalar | vector.Y); + + public static Vector2I operator ^(Vector2I vector, T scalar) => + new Vector2I(vector.X ^ scalar, vector.Y ^ scalar); + + public static Vector2I operator ^(T scalar, Vector2I vector) => + new Vector2I(scalar ^ vector.X, scalar ^ vector.Y); + + // NOT operator + public static Vector2I operator ~(Vector2I vector) => + new Vector2I(~vector.X, ~vector.Y); + + // IBinaryInteger + // TODO: Verify these are actually correct + + public static Vector2I Log2(Vector2I x) => + new Vector2I(T.Log2(x.X), T.Log2(x.Y)); + + public static (Vector2I Quotient, Vector2I Remainder) DivRem(Vector2I left, Vector2I right) + { + var (qX, rX) = T.DivRem(left.X, right.X); + var (qY, rY) = T.DivRem(left.Y, right.Y); + return (new Vector2I(qX, qY), new Vector2I(rX, rY)); + } + + public static Vector2I PopCount(Vector2I x) => + new Vector2I(T.PopCount(x.X), T.PopCount(x.Y)); } } From 051785de5d7ff7b774462bfd935d8a57873c4eb5 Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Wed, 28 May 2025 21:37:44 +1000 Subject: [PATCH 07/67] Add `Vector3I`. --- sources/Maths/Maths/Vector3I.cs | 530 ++++++++++++++++++++++++++++++++ 1 file changed, 530 insertions(+) create mode 100644 sources/Maths/Maths/Vector3I.cs diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs new file mode 100644 index 0000000000..e6f3644c16 --- /dev/null +++ b/sources/Maths/Maths/Vector3I.cs @@ -0,0 +1,530 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + + +using System.Collections; +using System.Diagnostics.CodeAnalysis; +using System.Numerics; +using System.Runtime.InteropServices; +using System.Text; + +namespace Silk.NET.Maths +{ + /// A structure representing a 3D integer vector. + internal struct Vector3I : + IEquatable>, + IReadOnlyList, + ISpanFormattable, + ISpanParsable>, + IUtf8SpanFormattable, + IUtf8SpanParsable>, + IParsable>, + IFormattable + where T : IBinaryInteger + { + /// The X component of the vector. + public T X; + + /// The Y component of the vector. + public T Y; + + /// The Z component of the vector. + public T Z; + + /// Initializes all components to the same value. + public Vector3I(T value) => (X, Y, Z) = (value, value, value); + + /// Initializes the vector with individual values for X, Y and Z. + public Vector3I(T x, T y, T z) => (X, Y, Z) = (x, y, z); + + /// Initializes the vector from a span of three values. + public Vector3I(ReadOnlySpan values) + { + if (values.Length != 3) + throw new ArgumentException("Input span must contain exactly 3 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + Z = values[2]; + } + + /// Gets a vector whose 3 elements are equal to one. + public static Vector3I One => new(Scalar.One); + + /// Returns a vector whose 3 elements are equal to zero. + public static Vector3I Zero => default; + + /// Gets the vector (1, 0, 0). + public static Vector3I UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero); + + /// Gets the vector (0, 1, 0). + public static Vector3I UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero); + + /// Gets the vector (0, 0, 1). + public static Vector3I UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One); + + /// Gets a vector with all bits set for each component. + public static Vector3I AllBitsSet => new Vector3I(T.AllBitsSet, T.AllBitsSet, T.AllBitsSet); + + /// Gets the squared length of the vector (dot product with itself). + public T LengthSquared => (X * X) + (Y * Y) + (Z * Z); + + /// The number of elements in the vector. + public int Count => 3; + + ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z. + public T this[int index] => index switch { + 0 => X, + 1 => Y, + 2 => Z, + _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0, 1, or 2.") + }; + + /// Returns a boolean indicating whether the given Object is equal to this instance. + public bool Equals(Vector3I other) => X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z); + + /// Returns an enumerator that iterates through the vector components. + public IEnumerator GetEnumerator() + { + yield return X; + yield return Y; + yield return Z; + } + + /// Computes the dot product of this vector with another vector. + public T Dot(Vector3I other) => (X * other.X) + (Y * other.Y) + (Z * other.Z); + + /// Computes the dot product of two vectors. + public static T Dot(Vector3I left, Vector3I right) => (left.X * right.X) + (left.Y * right.Y) + (left.Z * right.Z); + + /// Computes the cross product of this vector with another vector. + public Vector3I Cross(Vector3I other) => + new Vector3I( + (Y * other.Z) - (Z * other.Y), + (Z * other.X) - (X * other.Z), + (X * other.Y) - (Y * other.X) + ); + + /// Computes the cross product of two vectors. + public static Vector3I Cross(Vector3I left, Vector3I right) => + new Vector3I( + (left.Y * right.Z) - (left.Z * right.Y), + (left.Z * right.X) - (left.X * right.Z), + (left.X * right.Y) - (left.Y * right.X) + ); + + /// Returns a span over the vector components. + public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 3); + + /// Returns a vector with the component-wise maximum of this and another vector. + public Vector3I Max(Vector3I other) => + new Vector3I(T.Max(X, other.X), T.Max(Y, other.Y), T.Max(Z, other.Z)); + + /// Returns a vector with the component-wise maximum of two vectors. + public static Vector3I Max(Vector3I left, Vector3I right) => + new Vector3I(T.Max(left.X, right.X), T.Max(left.Y, right.Y), T.Max(left.Z, right.Z)); + + /// Returns a vector with the component-wise maximum of this vector and a scalar. + public Vector3I Max(T scalar) => + new Vector3I(T.Max(X, scalar), T.Max(Y, scalar), T.Max(Z, scalar)); + + /// Returns a vector with the component-wise maximum of a vector and a scalar. + public static Vector3I Max(Vector3I vector, T scalar) => + new Vector3I(T.Max(vector.X, scalar), T.Max(vector.Y, scalar), T.Max(vector.Z, scalar)); + + /// Returns a vector with the component-wise minimum of this and another vector. + public Vector3I Min(Vector3I other) => + new Vector3I(T.Min(X, other.X), T.Min(Y, other.Y), T.Min(Z, other.Z)); + + /// Returns a vector with the component-wise minimum of two vectors. + public static Vector3I Min(Vector3I left, Vector3I right) => + new Vector3I(T.Min(left.X, right.X), T.Min(left.Y, right.Y), T.Min(left.Z, right.Z)); + + /// Returns a vector with the component-wise minimum of this vector and a scalar. + public Vector3I Min(T scalar) => + new Vector3I(T.Min(X, scalar), T.Min(Y, scalar), T.Min(Z, scalar)); + + /// Returns a vector with the component-wise minimum of a vector and a scalar. + public static Vector3I Min(Vector3I vector, T scalar) => + new Vector3I(T.Min(vector.X, scalar), T.Min(vector.Y, scalar), T.Min(vector.Z, scalar)); + + /// Clamps this vector's components between the corresponding Min and Max vectors. + public Vector3I Clamp(Vector3I min, Vector3I max) => + new Vector3I( + T.Clamp(X, min.X, max.X), + T.Clamp(Y, min.Y, max.Y), + T.Clamp(Z, min.Z, max.Z) + ); + + /// Clamps the components of a vector between the corresponding Min and Max vectors. + public static Vector3I Clamp(Vector3I vector, Vector3I min, Vector3I max) => + new Vector3I( + T.Clamp(vector.X, min.X, max.X), + T.Clamp(vector.Y, min.Y, max.Y), + T.Clamp(vector.Z, min.Z, max.Z) + ); + + /// Clamps this vector's components between the Min and Max scalar values. + public Vector3I Clamp(T min, T max) => + new Vector3I( + T.Clamp(X, min, max), + T.Clamp(Y, min, max), + T.Clamp(Z, min, max) + ); + + /// Clamps the components of a vector between the Min and Max scalar values. + public static Vector3I Clamp(Vector3I vector, T min, T max) => + new Vector3I( + T.Clamp(vector.X, min, max), + T.Clamp(vector.Y, min, max), + T.Clamp(vector.Z, min, max) + ); + + /// Returns a vector with the absolute value of each component of this vector. + public Vector3I Abs() => new Vector3I(T.Abs(X), T.Abs(Y), T.Abs(Z)); + + /// Returns a vector with the absolute value of each component of the specified vector. + public static Vector3I Abs(Vector3I vector) => + new Vector3I(T.Abs(vector.X), T.Abs(vector.Y), T.Abs(vector.Z)); + + /// Formats the vector as a string using the specified format and format provider. + public string ToString(string? format, IFormatProvider? formatProvider) => + $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}, {Z.ToString(format, formatProvider)}>"; + + /// Formats the vector as a string. + public override string ToString() => $"<{X}, {Y}, {Z}>"; + + /// Formats the vector as a string using the specified format and format provider. + public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) + { + // Format components individually into temporary buffers + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + Span zBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider) || + !Z.TryFormat(zBuffer, out int zChars, format, provider)) + { + charsWritten = 0; + return false; + } + + // Calculate total required length: < + x + ", " + y + ", " + z + > + int requiredLength = 1 + xChars + 2 + yChars + 2 + zChars + 1; + + if (destination.Length < requiredLength) + { + charsWritten = 0; + return false; + } + + int pos = 0; + destination[pos++] = '<'; + + xBuffer[..xChars].CopyTo(destination[pos..]); + pos += xChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + yBuffer[..yChars].CopyTo(destination[pos..]); + pos += yChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + zBuffer[..zChars].CopyTo(destination[pos..]); + pos += zChars; + + destination[pos++] = '>'; + + charsWritten = pos; + return true; + } + + /// Parses a span to a Vector3I instance. + public static Vector3I Parse(ReadOnlySpan s, IFormatProvider? provider) + { + if (!TryParse(s, provider, out var result)) + throw new FormatException("Invalid format for Vector3I."); + + return result; + } + + /// Copies the components of the vector to the specified array starting at index 0. + public void CopyTo(T[] array) => CopyTo(array, 0); + + /// Copies the components of the vector to the specified array starting at the given index. + public void CopyTo(T[] array, int startIndex) + { + if (array == null) + throw new ArgumentNullException(nameof(array)); + if (startIndex < 0 || startIndex + 3 > array.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + array[startIndex] = X; + array[startIndex + 1] = Y; + array[startIndex + 2] = Z; + } + + /// Copies the components of the vector to the specified span starting at index 0. + public void CopyTo(Span span) => CopyTo(span, 0); + + /// Copies the components of the vector to the specified span starting at the given index. + public void CopyTo(Span span, int startIndex) + { + if (startIndex < 0 || startIndex + 3 > span.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + span[startIndex] = X; + span[startIndex + 1] = Y; + span[startIndex + 2] = Z; + } + + /// Returns a vector where each component is the sign of the original vector's component. + public Vector3I Sign() => + new Vector3I(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y)), T.CreateChecked(T.Sign(Z))); + + /// Returns a vector where each component is the sign of the input vector's component. + public static Vector3I Sign(Vector3I vector) => + new Vector3I(T.CreateChecked(T.Sign(vector.X)), T.CreateChecked(T.Sign(vector.Y)), T.CreateChecked(T.Sign(vector.Z))); + + /// Copies the sign of each component from another vector to this vector's components. + public Vector3I CopySign(Vector3I signSource) => + new Vector3I(T.CopySign(X, signSource.X), T.CopySign(Y, signSource.Y), T.CopySign(Z, signSource.Z)); + + /// Copies the sign of each component from another vector to a new vector. + public static Vector3I CopySign(Vector3I value, Vector3I signSource) => + new Vector3I(T.CopySign(value.X, signSource.X), T.CopySign(value.Y, signSource.Y), T.CopySign(value.Z, signSource.Z)); + + /// Copies the sign of a scalar onto each component of this vector. + public Vector3I CopySign(T signScalar) => + new Vector3I(T.CopySign(X, signScalar), T.CopySign(Y, signScalar), T.CopySign(Z, signScalar)); + + /// Copies the sign of a scalar onto each component of a new vector. + public static Vector3I CopySign(Vector3I value, T signScalar) => + new Vector3I(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar), T.CopySign(value.Z, signScalar)); + + /// Parses a string to a Vector3I instance. + public static Vector3I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + + /// Tries to parse a span to a Vector3I instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) + { + result = default; + + s = s.Trim(); + if (s.Length < 7 || s[0] != '<' || s[^1] != '>') + return false; + + s = s[1..^1]; // Remove < and > + + int firstComma = s.IndexOf(','); + if (firstComma < 0) + return false; + + // Kind of hacky, but it works + // TODO: See if there's a better way + ReadOnlySpan remainder = s.Slice(firstComma + 1); + int secondCommaRelative = remainder.IndexOf(','); + if (secondCommaRelative < 0) + return false; + + int secondComma = firstComma + 1 + secondCommaRelative; + if (secondComma < 0) + return false; + + ReadOnlySpan xSpan = s[..firstComma].Trim(); + ReadOnlySpan ySpan = s[(firstComma + 1)..secondComma].Trim(); + ReadOnlySpan zSpan = s[(secondComma + 1)..].Trim(); + + if (T.TryParse(xSpan, provider, out var x) && + T.TryParse(ySpan, provider, out var y) && + T.TryParse(zSpan, provider, out var z)) + { + result = new Vector3I(x, y, z); + return true; + } + + return false; + } + + /// Tries to parse a string to a Vector3I instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => + TryParse(s.AsSpan(), provider, out result); + + /// Parses a span to a Vector3I instance. + static Vector3I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + Parse(s, provider); + + /// Parses a string to a Vector3I instance. + static Vector3I IParsable>.Parse(string s, IFormatProvider? provider) => + Parse(s, provider); + + /// Tries to parse a span to a Vector3I instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => + TryParse(s, provider, out result); + + /// Tries to parse a string to a Vector3I instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => + TryParse(s, provider, out result); + + /// Returns an enumerator that iterates through the vector components. + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// Formats the vector as a UTF-8 string using the specified format and format provider. + public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) + { + // Format components individually into temporary buffers + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + Span zBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider) || + !Z.TryFormat(zBuffer, out int zChars, format, provider)) + { + bytesWritten = 0; + return false; + } + + // Estimate total required UTF-8 bytes + int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + + Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + + Encoding.UTF8.GetByteCount(zBuffer[..zChars]) + + Encoding.UTF8.GetByteCount("<, , >"); + + if (utf8Destination.Length < estimatedSize) + { + bytesWritten = 0; + return false; + } + + int totalBytes = 0; + + totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(zBuffer[..zChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); + + bytesWritten = totalBytes; + return true; + } + + /// Parses a UTF-8 span to a Vector3I instance. + public static Vector3I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return Parse(charBuffer, provider); + } + + /// Tries to parse a UTF-8 span to a Vector3I instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return TryParse(charBuffer, provider, out result); + } + + // Casts + + /// Explicitly casts a System.Numerics.Vector3 to a Vector3I. + public static explicit operator Vector3I(System.Numerics.Vector3 v) => + new Vector3I((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T))); + + /// Explicitly casts a Vector3I to System.Numerics.Vector3. + public static explicit operator System.Numerics.Vector3(Vector3I v) => + new System.Numerics.Vector3(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z)); + + // Component Operators + public static Vector3I operator +(Vector3I left, Vector3I right) => + new Vector3I(left.X + right.X, left.Y + right.Y, left.Z + right.Z); + + public static Vector3I operator -(Vector3I left, Vector3I right) => + new Vector3I(left.X - right.X, left.Y - right.Y, left.Z - right.Z); + + public static Vector3I operator *(Vector3I left, Vector3I right) => + new Vector3I(left.X * right.X, left.Y * right.Y, left.Z * right.Z); + + public static Vector3I operator /(Vector3I left, Vector3I right) => + new Vector3I(left.X / right.X, left.Y / right.Y, left.Z / right.Z); + + public static Vector3I operator %(Vector3I left, Vector3I right) => + new Vector3I(left.X % right.X, left.Y % right.Y, left.Z % right.Z); + + // Scalar Operators + public static Vector3I operator +(Vector3I vector, T scalar) => + new Vector3I(vector.X + scalar, vector.Y + scalar, vector.Z + scalar); + + public static Vector3I operator -(Vector3I vector, T scalar) => + new Vector3I(vector.X - scalar, vector.Y - scalar, vector.Z - scalar); + + public static Vector3I operator *(Vector3I vector, T scalar) => + new Vector3I(vector.X * scalar, vector.Y * scalar, vector.Z * scalar); + + public static Vector3I operator /(Vector3I vector, T scalar) => + new Vector3I(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); + + public static Vector3I operator %(Vector3I vector, T scalar) => + new Vector3I(vector.X % scalar, vector.Y % scalar, vector.Z % scalar); + + // + operator: returns the vector (?) + public static Vector3I operator +(Vector3I vector) => vector; + + // - operator: returns the negated vector + public static Vector3I operator -(Vector3I vector) => + new Vector3I(-vector.X, -vector.Y, -vector.Z); + + // Bitwise Operators + public static Vector3I operator &(Vector3I left, Vector3I right) => + new Vector3I(left.X & right.X, left.Y & right.Y, left.Z & right.Z); + + public static Vector3I operator |(Vector3I left, Vector3I right) => + new Vector3I(left.X | right.X, left.Y | right.Y, left.Z | right.Z); + + public static Vector3I operator ^(Vector3I left, Vector3I right) => + new Vector3I(left.X ^ right.X, left.Y ^ right.Y, left.Z ^ right.Z); + + public static Vector3I operator &(Vector3I vector, T scalar) => + new Vector3I(vector.X & scalar, vector.Y & scalar, vector.Z & scalar); + + public static Vector3I operator &(T scalar, Vector3I vector) => + new Vector3I(scalar & vector.X, scalar & vector.Y, scalar & vector.Z); + + public static Vector3I operator |(Vector3I vector, T scalar) => + new Vector3I(vector.X | scalar, vector.Y | scalar, vector.Z | scalar); + + public static Vector3I operator |(T scalar, Vector3I vector) => + new Vector3I(scalar | vector.X, scalar | vector.Y, scalar | vector.Z); + + public static Vector3I operator ^(Vector3I vector, T scalar) => + new Vector3I(vector.X ^ scalar, vector.Y ^ scalar, vector.Z ^ scalar); + + public static Vector3I operator ^(T scalar, Vector3I vector) => + new Vector3I(scalar ^ vector.X, scalar ^ vector.Y, scalar ^ vector.Z); + + // NOT operator + public static Vector3I operator ~(Vector3I vector) => + new Vector3I(~vector.X, ~vector.Y, ~vector.Z); + + // IBinaryInteger + public static Vector3I Log2(Vector3I x) => + new Vector3I(T.Log2(x.X), T.Log2(x.Y), T.Log2(x.Z)); + + public static (Vector3I Quotient, Vector3I Remainder) DivRem(Vector3I left, Vector3I right) + { + var (qX, rX) = T.DivRem(left.X, right.X); + var (qY, rY) = T.DivRem(left.Y, right.Y); + var (qZ, rZ) = T.DivRem(left.Z, right.Z); + return (new Vector3I(qX, qY, qZ), new Vector3I(rX, rY, rZ)); + } + + public static Vector3I PopCount(Vector3I x) => + new Vector3I(T.PopCount(x.X), T.PopCount(x.Y), T.PopCount(x.Z)); + } +} From 88b840589f304a4cf56897bb0757ea7217462bfa Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Wed, 28 May 2025 22:08:33 +1000 Subject: [PATCH 08/67] Change VectorI XML comments. --- sources/Maths/Maths/Vector2I.cs | 24 ++++++++++++------------ sources/Maths/Maths/Vector3I.cs | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index dfe0d5060d..1e556d2a41 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -200,7 +200,7 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan return true; } - /// Parses a span to a Vector2I instance. + /// Parses a span to a instance. public static Vector2I Parse(ReadOnlySpan s, IFormatProvider? provider) { if (!TryParse(s, provider, out var result)) @@ -258,10 +258,10 @@ public Vector2I CopySign(T signScalar) => public static Vector2I CopySign(Vector2I value, T signScalar) => new Vector2I(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar)); - /// Parses a string to a Vector2I instance. + /// Parses a string to a instance. public static Vector2I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); - /// Tries to parse a span to a Vector2I instance. + /// Tries to parse a span to a instance. public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) { result = default; @@ -290,23 +290,23 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [Ma } - /// Tries to parse a string to a Vector2I instance. + /// Tries to parse a string to a instance. public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => TryParse(s.AsSpan(), provider, out result); - /// Parses a span to a Vector2I instance. + /// Parses a span to a instance. static Vector2I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => Parse(s, provider); - /// Parses a string to a Vector2I instance. + /// Parses a string to a instance. static Vector2I IParsable>.Parse(string s, IFormatProvider? provider) => Parse(s, provider); - /// Tries to parse a span to a Vector2I instance. + /// Tries to parse a span to a instance. static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => TryParse(s, provider, out result); - /// Tries to parse a string to a Vector2I instance. + /// Tries to parse a string to a instance. static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => TryParse(s, provider, out result); @@ -351,7 +351,7 @@ public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnly return true; } - /// Parses a UTF-8 span to a Vector2I instance. + /// Parses a UTF-8 span to a instance. public static Vector2I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) { int charCount = Encoding.UTF8.GetCharCount(utf8Text); @@ -360,7 +360,7 @@ public static Vector2I Parse(ReadOnlySpan utf8Text, IFormatProvider? pr return Parse(charBuffer, provider); } - /// Tries to parse a UTF-8 span to a Vector2I instance. + /// Tries to parse a UTF-8 span to a instance. public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) { int charCount = Encoding.UTF8.GetCharCount(utf8Text); @@ -371,11 +371,11 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid // Casts - /// Explicitly casts a System.Numerics.Vector2 to a Vector2I. + /// Explicitly casts a to a . public static explicit operator Vector2I(System.Numerics.Vector2 v) => new Vector2I((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T))); - /// Explicitly casts a Vector2I to System.Numerics.Vector2. + /// Explicitly casts a to . public static explicit operator System.Numerics.Vector2(Vector2I v) => new System.Numerics.Vector2(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index e6f3644c16..842a391b42 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -243,7 +243,7 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan return true; } - /// Parses a span to a Vector3I instance. + /// Parses a span to a instance. public static Vector3I Parse(ReadOnlySpan s, IFormatProvider? provider) { if (!TryParse(s, provider, out var result)) @@ -304,10 +304,10 @@ public Vector3I CopySign(T signScalar) => public static Vector3I CopySign(Vector3I value, T signScalar) => new Vector3I(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar), T.CopySign(value.Z, signScalar)); - /// Parses a string to a Vector3I instance. + /// Parses a string to a instance. public static Vector3I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); - /// Tries to parse a span to a Vector3I instance. + /// Tries to parse a span to a instance. public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) { result = default; @@ -348,23 +348,23 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [Ma return false; } - /// Tries to parse a string to a Vector3I instance. + /// Tries to parse a string to a instance. public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => TryParse(s.AsSpan(), provider, out result); - /// Parses a span to a Vector3I instance. + /// Parses a span to a instance. static Vector3I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => Parse(s, provider); - /// Parses a string to a Vector3I instance. + /// Parses a string to a instance. static Vector3I IParsable>.Parse(string s, IFormatProvider? provider) => Parse(s, provider); - /// Tries to parse a span to a Vector3I instance. + /// Tries to parse a span to a instance. static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => TryParse(s, provider, out result); - /// Tries to parse a string to a Vector3I instance. + /// Tries to parse a string to a instance. static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => TryParse(s, provider, out result); @@ -413,7 +413,7 @@ public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnly return true; } - /// Parses a UTF-8 span to a Vector3I instance. + /// Parses a UTF-8 span to a instance. public static Vector3I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) { int charCount = Encoding.UTF8.GetCharCount(utf8Text); @@ -422,7 +422,7 @@ public static Vector3I Parse(ReadOnlySpan utf8Text, IFormatProvider? pr return Parse(charBuffer, provider); } - /// Tries to parse a UTF-8 span to a Vector3I instance. + /// Tries to parse a UTF-8 span to a instance. public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) { int charCount = Encoding.UTF8.GetCharCount(utf8Text); @@ -433,11 +433,11 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid // Casts - /// Explicitly casts a System.Numerics.Vector3 to a Vector3I. + /// Explicitly casts a to a . public static explicit operator Vector3I(System.Numerics.Vector3 v) => new Vector3I((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T))); - /// Explicitly casts a Vector3I to System.Numerics.Vector3. + /// Explicitly casts a to . public static explicit operator System.Numerics.Vector3(Vector3I v) => new System.Numerics.Vector3(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z)); From d1eade9172bd5ecb30b8b5482f586f58a38de703 Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Wed, 28 May 2025 22:08:54 +1000 Subject: [PATCH 09/67] Add `Vector4I`. --- sources/Maths/Maths/Vector4I.cs | 546 ++++++++++++++++++++++++++++++++ 1 file changed, 546 insertions(+) create mode 100644 sources/Maths/Maths/Vector4I.cs diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs new file mode 100644 index 0000000000..71480db468 --- /dev/null +++ b/sources/Maths/Maths/Vector4I.cs @@ -0,0 +1,546 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + + +using System.Collections; +using System.Diagnostics.CodeAnalysis; +using System.Numerics; +using System.Runtime.InteropServices; +using System.Text; + +namespace Silk.NET.Maths +{ + /// A structure representing a 4D integer vector. + internal struct Vector4I : + IEquatable>, + IReadOnlyList, + ISpanFormattable, + ISpanParsable>, + IUtf8SpanFormattable, + IUtf8SpanParsable>, + IParsable>, + IFormattable + where T : IBinaryInteger + { + /// The X component of the vector. + public T X; + + /// The Y component of the vector. + public T Y; + + /// The Z component of the vector. + public T Z; + + /// The W component of the vector. + public T W; + + /// Initializes all components to the same value. + public Vector4I(T value) => (X, Y, Z, W) = (value, value, value, value); + + /// Initializes the vector with individual values for X, Y, Z and W. + public Vector4I(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); + + /// Initializes the vector from a span of four values. + public Vector4I(ReadOnlySpan values) + { + if (values.Length != 4) + throw new ArgumentException("Input span must contain exactly 4 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + Z = values[2]; + W = values[3]; + } + + /// Gets a vector whose 4 elements are equal to one. + public static Vector4I One => new(Scalar.One); + + /// Returns a vector whose 4 elements are equal to zero. + public static Vector4I Zero => default; + + /// Gets the vector (1, 0, 0, 0). + public static Vector4I UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero, Scalar.Zero); + + /// Gets the vector (0, 1, 0, 0). + public static Vector4I UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero, Scalar.Zero); + + /// Gets the vector (0, 0, 1, 0). + public static Vector4I UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One, Scalar.Zero); + + /// Gets the vector (0, 0, 0, 1). + public static Vector4I UnitW => new(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); + + /// Gets a vector with all bits set for each component. + public static Vector4I AllBitsSet => new Vector4I(T.AllBitsSet, T.AllBitsSet, T.AllBitsSet, T.AllBitsSet); + + /// Gets the squared length of the vector (dot product with itself). + public T LengthSquared => (X * X) + (Y * Y) + (Z * Z) + (W * W); + + /// The number of elements in the vector. + public int Count => 4; + + ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z, 3 = W. + public T this[int index] => index switch { + 0 => X, + 1 => Y, + 2 => Z, + 3 => W, + _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0, 1, 2, or 3.") + }; + + /// Returns a boolean indicating whether the given Object is equal to this instance. + public bool Equals(Vector4I other) => X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z) && W.Equals(other.W); + + /// Returns an enumerator that iterates through the vector components. + public IEnumerator GetEnumerator() + { + yield return X; + yield return Y; + yield return Z; + yield return W; + } + + /// Computes the dot product of this vector with another vector. + public T Dot(Vector4I other) => (X * other.X) + (Y * other.Y) + (Z * other.Z) + (W * other.W); + + /// Computes the dot product of two vectors. + public static T Dot(Vector4I left, Vector4I right) => (left.X * right.X) + (left.Y * right.Y) + (left.Z * right.Z) + (left.W * right.W); + + /// Returns a span over the vector components. + public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 4); + + /// Returns a vector with the component-wise maximum of this and another vector. + public Vector4I Max(Vector4I other) => + new Vector4I(T.Max(X, other.X), T.Max(Y, other.Y), T.Max(Z, other.Z), T.Max(W, other.W)); + + /// Returns a vector with the component-wise maximum of two vectors. + public static Vector4I Max(Vector4I left, Vector4I right) => + new Vector4I(T.Max(left.X, right.X), T.Max(left.Y, right.Y), T.Max(left.Z, right.Z), T.Max(left.W, right.W)); + + /// Returns a vector with the component-wise maximum of this vector and a scalar. + public Vector4I Max(T scalar) => + new Vector4I(T.Max(X, scalar), T.Max(Y, scalar), T.Max(Z, scalar), T.Max(W, scalar)); + + /// Returns a vector with the component-wise maximum of a vector and a scalar. + public static Vector4I Max(Vector4I vector, T scalar) => + new Vector4I(T.Max(vector.X, scalar), T.Max(vector.Y, scalar), T.Max(vector.Z, scalar), T.Max(vector.W, scalar)); + + /// Returns a vector with the component-wise minimum of this and another vector. + public Vector4I Min(Vector4I other) => + new Vector4I(T.Min(X, other.X), T.Min(Y, other.Y), T.Min(Z, other.Z), T.Min(W, other.W)); + + /// Returns a vector with the component-wise minimum of two vectors. + public static Vector4I Min(Vector4I left, Vector4I right) => + new Vector4I(T.Min(left.X, right.X), T.Min(left.Y, right.Y), T.Min(left.Z, right.Z), T.Min(left.W, right.W)); + + /// Returns a vector with the component-wise minimum of this vector and a scalar. + public Vector4I Min(T scalar) => + new Vector4I(T.Min(X, scalar), T.Min(Y, scalar), T.Min(Z, scalar), T.Min(W, scalar)); + + /// Returns a vector with the component-wise minimum of a vector and a scalar. + public static Vector4I Min(Vector4I vector, T scalar) => + new Vector4I(T.Min(vector.X, scalar), T.Min(vector.Y, scalar), T.Min(vector.Z, scalar), T.Min(vector.W, scalar)); + + /// Clamps this vector's components between the corresponding Min and Max vectors. + public Vector4I Clamp(Vector4I min, Vector4I max) => + new Vector4I( + T.Clamp(X, min.X, max.X), + T.Clamp(Y, min.Y, max.Y), + T.Clamp(Z, min.Z, max.Z), + T.Clamp(W, min.W, max.W) + ); + + /// Clamps the components of a vector between the corresponding Min and Max vectors. + public static Vector4I Clamp(Vector4I vector, Vector4I min, Vector4I max) => + new Vector4I( + T.Clamp(vector.X, min.X, max.X), + T.Clamp(vector.Y, min.Y, max.Y), + T.Clamp(vector.Z, min.Z, max.Z), + T.Clamp(vector.W, min.W, max.W) + ); + + /// Clamps this vector's components between the Min and Max scalar values. + public Vector4I Clamp(T min, T max) => + new Vector4I( + T.Clamp(X, min, max), + T.Clamp(Y, min, max), + T.Clamp(Z, min, max), + T.Clamp(W, min, max) + ); + + /// Clamps the components of a vector between the Min and Max scalar values. + public static Vector4I Clamp(Vector4I vector, T min, T max) => + new Vector4I( + T.Clamp(vector.X, min, max), + T.Clamp(vector.Y, min, max), + T.Clamp(vector.Z, min, max), + T.Clamp(vector.W, min, max) + ); + + /// Returns a vector with the absolute value of each component of this vector. + public Vector4I Abs() => new Vector4I(T.Abs(X), T.Abs(Y), T.Abs(Z), T.Abs(W)); + + /// Returns a vector with the absolute value of each component of the specified vector. + public static Vector4I Abs(Vector4I vector) => + new Vector4I(T.Abs(vector.X), T.Abs(vector.Y), T.Abs(vector.Z), T.Abs(vector.W)); + + /// Formats the vector as a string using the specified format and format provider. + public string ToString(string? format, IFormatProvider? formatProvider) => + $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}, {Z.ToString(format, formatProvider)}, {W.ToString(format, formatProvider)}>"; + + /// Formats the vector as a string. + public override string ToString() => $"<{X}, {Y}, {Z}, {W}>"; + + /// Formats the vector as a string using the specified format and format provider. + public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) + { + // Format components individually into temporary buffers + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + Span zBuffer = stackalloc char[64]; + Span wBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider) || + !Z.TryFormat(zBuffer, out int zChars, format, provider) || + !W.TryFormat(wBuffer, out int wChars, format, provider)) + { + charsWritten = 0; + return false; + } + + // Calculate total required length: < + x + ", " + y + ", " + z + ", " + w + > + int requiredLength = 1 + xChars + 2 + yChars + 2 + zChars + 2 + wChars + 1; + + if (destination.Length < requiredLength) + { + charsWritten = 0; + return false; + } + + int pos = 0; + destination[pos++] = '<'; + + xBuffer[..xChars].CopyTo(destination[pos..]); + pos += xChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + yBuffer[..yChars].CopyTo(destination[pos..]); + pos += yChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + zBuffer[..zChars].CopyTo(destination[pos..]); + pos += zChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + wBuffer[..wChars].CopyTo(destination[pos..]); + pos += wChars; + + destination[pos++] = '>'; + + charsWritten = pos; + return true; + } + + /// Parses a span to a Vector4I instance. + public static Vector4I Parse(ReadOnlySpan s, IFormatProvider? provider) + { + if (!TryParse(s, provider, out var result)) + throw new FormatException("Invalid format for Vector4I."); + + return result; + } + + /// Copies the components of the vector to the specified array starting at index 0. + public void CopyTo(T[] array) => CopyTo(array, 0); + + /// Copies the components of the vector to the specified array starting at the given index. + public void CopyTo(T[] array, int startIndex) + { + if (array == null) + throw new ArgumentNullException(nameof(array)); + if (startIndex < 0 || startIndex + 4 > array.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + array[startIndex] = X; + array[startIndex + 1] = Y; + array[startIndex + 2] = Z; + array[startIndex + 3] = W; + } + + /// Copies the components of the vector to the specified span starting at index 0. + public void CopyTo(Span span) => CopyTo(span, 0); + + /// Copies the components of the vector to the specified span starting at the given index. + public void CopyTo(Span span, int startIndex) + { + if (startIndex < 0 || startIndex + 4 > span.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + span[startIndex] = X; + span[startIndex + 1] = Y; + span[startIndex + 2] = Z; + span[startIndex + 3] = W; + } + + /// Returns a vector where each component is the sign of the original vector's component. + public Vector4I Sign() => + new Vector4I(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y)), T.CreateChecked(T.Sign(Z)), T.CreateChecked(T.Sign(W))); + + /// Returns a vector where each component is the sign of the input vector's component. + public static Vector4I Sign(Vector4I vector) => + new Vector4I(T.CreateChecked(T.Sign(vector.X)), T.CreateChecked(T.Sign(vector.Y)), T.CreateChecked(T.Sign(vector.Z)), T.CreateChecked(T.Sign(vector.W))); + + /// Copies the sign of each component from another vector to this vector's components. + public Vector4I CopySign(Vector4I signSource) => + new Vector4I(T.CopySign(X, signSource.X), T.CopySign(Y, signSource.Y), T.CopySign(Z, signSource.Z), T.CopySign(W, signSource.W)); + + /// Copies the sign of each component from another vector to a new vector. + public static Vector4I CopySign(Vector4I value, Vector4I signSource) => + new Vector4I(T.CopySign(value.X, signSource.X), T.CopySign(value.Y, signSource.Y), T.CopySign(value.Z, signSource.Z), T.CopySign(value.W, signSource.W)); + + /// Copies the sign of a scalar onto each component of this vector. + public Vector4I CopySign(T signScalar) => + new Vector4I(T.CopySign(X, signScalar), T.CopySign(Y, signScalar), T.CopySign(Z, signScalar), T.CopySign(W, signScalar)); + + /// Copies the sign of a scalar onto each component of a new vector. + public static Vector4I CopySign(Vector4I value, T signScalar) => + new Vector4I(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar), T.CopySign(value.Z, signScalar), T.CopySign(value.W, signScalar)); + + /// Parses a string to a Vector4I instance. + public static Vector4I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + + /// Tries to parse a span to a Vector4I instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) + { + result = default; + + s = s.Trim(); + if (s.Length < 9 || s[0] != '<' || s[^1] != '>') + return false; + + s = s[1..^1]; // Remove < and > + + int firstComma = s.IndexOf(','); + if (firstComma < 0) + return false; + + ReadOnlySpan remainder1 = s.Slice(firstComma + 1); + int secondCommaRelative = remainder1.IndexOf(','); + if (secondCommaRelative < 0) + return false; + int secondComma = firstComma + 1 + secondCommaRelative; + + ReadOnlySpan remainder2 = s.Slice(secondComma + 1); + int thirdCommaRelative = remainder2.IndexOf(','); + if (thirdCommaRelative < 0) + return false; + int thirdComma = secondComma + 1 + thirdCommaRelative; + + ReadOnlySpan xSpan = s[..firstComma].Trim(); + ReadOnlySpan ySpan = s[(firstComma + 1)..secondComma].Trim(); + ReadOnlySpan zSpan = s[(secondComma + 1)..thirdComma].Trim(); + ReadOnlySpan wSpan = s[(thirdComma + 1)..].Trim(); + + if (T.TryParse(xSpan, provider, out var x) && + T.TryParse(ySpan, provider, out var y) && + T.TryParse(zSpan, provider, out var z) && + T.TryParse(wSpan, provider, out var w)) + { + result = new Vector4I(x, y, z, w); + return true; + } + + return false; + } + + /// Tries to parse a string to a Vector4I instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => + TryParse(s.AsSpan(), provider, out result); + + /// Parses a span to a Vector4I instance. + static Vector4I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + Parse(s, provider); + + /// Parses a string to a Vector4I instance. + static Vector4I IParsable>.Parse(string s, IFormatProvider? provider) => + Parse(s, provider); + + /// Tries to parse a span to a Vector4I instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => + TryParse(s, provider, out result); + + /// Tries to parse a string to a Vector4I instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => + TryParse(s, provider, out result); + + /// Returns an enumerator that iterates through the vector components. + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// Formats the vector as a UTF-8 string using the specified format and format provider. + public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) + { + // Format components individually into temporary buffers + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + Span zBuffer = stackalloc char[64]; + Span wBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider) || + !Z.TryFormat(zBuffer, out int zChars, format, provider) || + !W.TryFormat(wBuffer, out int wChars, format, provider)) + { + bytesWritten = 0; + return false; + } + + // Estimate total required UTF-8 bytes + int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + + Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + + Encoding.UTF8.GetByteCount(zBuffer[..zChars]) + + Encoding.UTF8.GetByteCount(wBuffer[..wChars]) + + Encoding.UTF8.GetByteCount("<, , , >"); + + if (utf8Destination.Length < estimatedSize) + { + bytesWritten = 0; + return false; + } + + int totalBytes = 0; + + totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(zBuffer[..zChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(wBuffer[..wChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); + + bytesWritten = totalBytes; + return true; + } + + /// Parses a UTF-8 span to a Vector4I instance. + public static Vector4I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return Parse(charBuffer, provider); + } + + /// Tries to parse a UTF-8 span to a Vector4I instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return TryParse(charBuffer, provider, out result); + } + + // Casts + + /// Explicitly casts a System.Numerics.Vector4 to a Vector4I. + public static explicit operator Vector4I(System.Numerics.Vector4 v) => + new Vector4I((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T)), (T)Convert.ChangeType(v.W, typeof(T))); + + /// Explicitly casts a Vector4I to System.Numerics.Vector4. + public static explicit operator System.Numerics.Vector4(Vector4I v) => + new System.Numerics.Vector4(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z), Convert.ToSingle(v.W)); + + // Component Operators + public static Vector4I operator +(Vector4I left, Vector4I right) => + new Vector4I(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); + + public static Vector4I operator -(Vector4I left, Vector4I right) => + new Vector4I(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); + + public static Vector4I operator *(Vector4I left, Vector4I right) => + new Vector4I(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W); + + public static Vector4I operator /(Vector4I left, Vector4I right) => + new Vector4I(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W); + + public static Vector4I operator %(Vector4I left, Vector4I right) => + new Vector4I(left.X % right.X, left.Y % right.Y, left.Z % right.Z, left.W % right.W); + + // Scalar Operators + public static Vector4I operator +(Vector4I vector, T scalar) => + new Vector4I(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar); + + public static Vector4I operator -(Vector4I vector, T scalar) => + new Vector4I(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar); + + public static Vector4I operator *(Vector4I vector, T scalar) => + new Vector4I(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar); + + public static Vector4I operator /(Vector4I vector, T scalar) => + new Vector4I(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); + + public static Vector4I operator %(Vector4I vector, T scalar) => + new Vector4I(vector.X % scalar, vector.Y % scalar, vector.Z % scalar, vector.W % scalar); + + // + operator: returns the vector (?) + public static Vector4I operator +(Vector4I vector) => vector; + + // - operator: returns the negated vector + public static Vector4I operator -(Vector4I vector) => + new Vector4I(-vector.X, -vector.Y, -vector.Z, -vector.W); + + // Bitwise Operators + public static Vector4I operator &(Vector4I left, Vector4I right) => + new Vector4I(left.X & right.X, left.Y & right.Y, left.Z & right.Z, left.W & right.W); + + public static Vector4I operator |(Vector4I left, Vector4I right) => + new Vector4I(left.X | right.X, left.Y | right.Y, left.Z | right.Z, left.W | right.W); + + public static Vector4I operator ^(Vector4I left, Vector4I right) => + new Vector4I(left.X ^ right.X, left.Y ^ right.Y, left.Z ^ right.Z, left.W ^ right.W); + + public static Vector4I operator &(Vector4I vector, T scalar) => + new Vector4I(vector.X & scalar, vector.Y & scalar, vector.Z & scalar, vector.W & scalar); + + public static Vector4I operator &(T scalar, Vector4I vector) => + new Vector4I(scalar & vector.X, scalar & vector.Y, scalar & vector.Z, scalar & vector.W); + + public static Vector4I operator |(Vector4I vector, T scalar) => + new Vector4I(vector.X | scalar, vector.Y | scalar, vector.Z | scalar, vector.W | scalar); + + public static Vector4I operator |(T scalar, Vector4I vector) => + new Vector4I(scalar | vector.X, scalar | vector.Y, scalar | vector.Z, scalar | vector.W); + + public static Vector4I operator ^(Vector4I vector, T scalar) => + new Vector4I(vector.X ^ scalar, vector.Y ^ scalar, vector.Z ^ scalar, vector.W ^ scalar); + + public static Vector4I operator ^(T scalar, Vector4I vector) => + new Vector4I(scalar ^ vector.X, scalar ^ vector.Y, scalar ^ vector.Z, scalar ^ vector.W); + + // NOT operator + public static Vector4I operator ~(Vector4I vector) => + new Vector4I(~vector.X, ~vector.Y, ~vector.Z, ~vector.W); + + // IBinaryInteger + public static Vector4I Log2(Vector4I x) => + new Vector4I(T.Log2(x.X), T.Log2(x.Y), T.Log2(x.Z), T.Log2(x.W)); + + public static (Vector4I Quotient, Vector4I Remainder) DivRem(Vector4I left, Vector4I right) + { + var (qX, rX) = T.DivRem(left.X, right.X); + var (qY, rY) = T.DivRem(left.Y, right.Y); + var (qZ, rZ) = T.DivRem(left.Z, right.Z); + var (qW, rW) = T.DivRem(left.W, right.W); + return (new Vector4I(qX, qY, qZ, qW), new Vector4I(rX, rY, rZ, rW)); + } + + public static Vector4I PopCount(Vector4I x) => + new Vector4I(T.PopCount(x.X), T.PopCount(x.Y), T.PopCount(x.Z), T.PopCount(x.W)); + } +} From 9b68e351c363a6f7fceb6d898f719539dd2ac852 Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Wed, 28 May 2025 22:41:15 +1000 Subject: [PATCH 10/67] Improve VectorI equality checks. --- sources/Maths/Maths/Vector2I.cs | 15 ++++++++++++++- sources/Maths/Maths/Vector3I.cs | 15 ++++++++++++++- sources/Maths/Maths/Vector4I.cs | 21 ++++++++++++++++++++- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index 1e556d2a41..ab8ba58dfc 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -73,7 +73,13 @@ public Vector2I(ReadOnlySpan values) }; /// Returns a boolean indicating whether the given Object is equal to this instance. - public bool Equals(Vector2I other) => X.Equals(other.X) && Y.Equals(other.Y); + public override bool Equals(object? obj) => obj is Vector2I other && Equals(other); + + /// Returns a boolean indicating whether the given Vector2I is equal to this instance. + public bool Equals(Vector2I other) => this == other; + + /// Returns the hash code for this instance. + public override int GetHashCode() => HashCode.Combine(X, Y); /// Returns an enumerator that iterates through the vector components. public IEnumerator GetEnumerator() @@ -450,6 +456,13 @@ public static explicit operator System.Numerics.Vector2(Vector2I v) => public static Vector2I operator ~(Vector2I vector) => new Vector2I(~vector.X, ~vector.Y); + // Equality Operators + public static bool operator ==(Vector2I left, Vector2I right) => + left.X == right.X && left.Y == right.Y; + + public static bool operator !=(Vector2I left, Vector2I right) => + left.X != right.X || left.Y != right.Y; + // IBinaryInteger // TODO: Verify these are actually correct diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index 842a391b42..357643abd9 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -81,7 +81,13 @@ public Vector3I(ReadOnlySpan values) }; /// Returns a boolean indicating whether the given Object is equal to this instance. - public bool Equals(Vector3I other) => X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z); + public override bool Equals(object? obj) => obj is Vector3I other && Equals(other); + + /// Returns a boolean indicating whether the given Vector3I is equal to this instance. + public bool Equals(Vector3I other) => this == other; + + /// Returns the hash code for this instance. + public override int GetHashCode() => HashCode.Combine(X, Y, Z); /// Returns an enumerator that iterates through the vector components. public IEnumerator GetEnumerator() @@ -512,6 +518,13 @@ public static explicit operator System.Numerics.Vector3(Vector3I v) => public static Vector3I operator ~(Vector3I vector) => new Vector3I(~vector.X, ~vector.Y, ~vector.Z); + // Equality Operators + public static bool operator ==(Vector3I left, Vector3I right) => + left.X == right.X && left.Y == right.Y && left.Z == right.Z; + + public static bool operator !=(Vector3I left, Vector3I right) => + left.X != right.X || left.Y != right.Y || left.Z != right.Z; + // IBinaryInteger public static Vector3I Log2(Vector3I x) => new Vector3I(T.Log2(x.X), T.Log2(x.Y), T.Log2(x.Z)); diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs index 71480db468..b1866d3f00 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4I.cs @@ -89,7 +89,13 @@ public Vector4I(ReadOnlySpan values) }; /// Returns a boolean indicating whether the given Object is equal to this instance. - public bool Equals(Vector4I other) => X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z) && W.Equals(other.W); + public override bool Equals(object? obj) => obj is Vector4I other && Equals(other); + + /// Returns a boolean indicating whether the given Vector4I is equal to this instance. + public bool Equals(Vector4I other) => this == other; + + /// Returns the hash code for this instance. + public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); /// Returns an enumerator that iterates through the vector components. public IEnumerator GetEnumerator() @@ -527,6 +533,19 @@ public static explicit operator System.Numerics.Vector4(Vector4I v) => public static Vector4I operator ~(Vector4I vector) => new Vector4I(~vector.X, ~vector.Y, ~vector.Z, ~vector.W); + // Equality Operators + public static bool operator ==(Vector4I left, Vector4I right) => + left.X == right.X && + left.Y == right.Y && + left.Z == right.Z && + left.W == right.W; + + public static bool operator !=(Vector4I left, Vector4I right) => + left.X != right.X || + left.Y != right.Y || + left.Z != right.Z || + left.W != right.W; + // IBinaryInteger public static Vector4I Log2(Vector4I x) => new Vector4I(T.Log2(x.X), T.Log2(x.Y), T.Log2(x.Z), T.Log2(x.W)); From 6a3cf885afd2f5c1e4487dc270adec6351814886 Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Wed, 28 May 2025 22:49:16 +1000 Subject: [PATCH 11/67] Start work on new `Quaternion`. --- sources/Maths/Maths/Legacy/Quaternion.cs | 794 +++++++++++++++++++++++ sources/Maths/Maths/Quaternion.cs | 771 +--------------------- 2 files changed, 818 insertions(+), 747 deletions(-) create mode 100644 sources/Maths/Maths/Legacy/Quaternion.cs diff --git a/sources/Maths/Maths/Legacy/Quaternion.cs b/sources/Maths/Maths/Legacy/Quaternion.cs new file mode 100644 index 0000000000..b0c46916b9 --- /dev/null +++ b/sources/Maths/Maths/Legacy/Quaternion.cs @@ -0,0 +1,794 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Globalization; +using System.Runtime.CompilerServices; +using System.Runtime.Serialization; +using Silk.NET.Maths; + +namespace Silk.NET.Maths.Legacy +{ + /// + /// Represents a vector that is used to encode three-dimensional physical rotations. + /// + /// The type used to store values. + [Serializable] + [DataContract] + public struct Quaternion + : IEquatable> where T : unmanaged, IFormattable, IEquatable, IComparable + { + private const float SlerpEpsilon = 1e-6f; + + /// Specifies the X-value of the vector component of the Quaternion. + [DataMember] + public T X; + + /// Specifies the Y-value of the vector component of the Quaternion. + [DataMember] + public T Y; + + /// Specifies the Z-value of the vector component of the Quaternion. + [DataMember] + public T Z; + + /// Specifies the rotation component of the Quaternion. + [DataMember] + public T W; + + /// Constructs a Quaternion from the given components. + /// The X component of the Quaternion. + /// The Y component of the Quaternion. + /// The Z component of the Quaternion. + /// The W component of the Quaternion. + public Quaternion(T x, T y, T z, T w) + { + X = x; + Y = y; + Z = z; + W = w; + } + + /// Constructs a Quaternion from the given vector and rotation parts. + /// The vector part of the Quaternion. + /// The rotation part of the Quaternion. + public Quaternion(Vector3D vectorPart, T scalarPart) + { + X = vectorPart.X; + Y = vectorPart.Y; + Z = vectorPart.Z; + W = scalarPart; + } + + /// Returns a Quaternion representing no rotation. + public static Quaternion Identity => new(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); + + /// Returns whether the Quaternion is the identity Quaternion. + [IgnoreDataMember] + public readonly bool IsIdentity => this == Identity; + + /// Adds two Quaternions element-by-element. + /// The first source Quaternion. + /// The second source Quaternion. + /// The result of adding the Quaternions. + public static Quaternion operator +(Quaternion value1, Quaternion value2) + { + Quaternion ans; + + ans.X = Scalar.Add(value1.X, value2.X); + ans.Y = Scalar.Add(value1.Y, value2.Y); + ans.Z = Scalar.Add(value1.Z, value2.Z); + ans.W = Scalar.Add(value1.W, value2.W); + + return ans; + } + + /// Divides a Quaternion by another Quaternion. + /// The source Quaternion. + /// The divisor. + /// The result of the division. + public static Quaternion operator /(Quaternion value1, Quaternion value2) + { + Quaternion ans; + + T q1x = value1.X; + T q1y = value1.Y; + T q1z = value1.Z; + T q1w = value1.W; + + //------------------------------------- + // Inverse part. + T ls = Scalar.Add( + Scalar.Add( + Scalar.Add(Scalar.Multiply(value2.X, value2.X), Scalar.Multiply(value2.Y, value2.Y)), + Scalar.Multiply(value2.Z, value2.Z)), Scalar.Multiply(value2.W, value2.W)); + T invNorm = Scalar.Reciprocal(ls); + + T q2x = Scalar.Negate(Scalar.Multiply(value2.X, invNorm)); + T q2y = Scalar.Negate(Scalar.Multiply(value2.Y, invNorm)); + T q2z = Scalar.Negate(Scalar.Multiply(value2.Z, invNorm)); + T q2w = Scalar.Multiply(value2.W, invNorm); + + //------------------------------------- + // Multiply part. + + // cross(av, bv) + T cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); + T cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); + T cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); + + T dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), + Scalar.Multiply(q1z, q2z)); + + ans.X = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2w), Scalar.Multiply(q2x, q1w)), cx); + ans.Y = Scalar.Add(Scalar.Add(Scalar.Multiply(q1y, q2w), Scalar.Multiply(q2y, q1w)), cy); + ans.Z = Scalar.Add(Scalar.Add(Scalar.Multiply(q1z, q2w), Scalar.Multiply(q2z, q1w)), cz); + ans.W = Scalar.Subtract(Scalar.Multiply(q1w, q2w), dot); + + return ans; + } + + /// Returns a boolean indicating whether the two given Quaternions are equal. + /// The first Quaternion to compare. + /// The second Quaternion to compare. + /// True if the Quaternions are equal; False otherwise. + public static bool operator ==(Quaternion value1, Quaternion value2) + => Scalar.Equal(value1.X, value2.X) + && Scalar.Equal(value1.Y, value2.Y) + && Scalar.Equal(value1.Z, value2.Z) + && Scalar.Equal(value1.W, value2.W); + + /// Returns a boolean indicating whether the two given Quaternions are not equal. + /// The first Quaternion to compare. + /// The second Quaternion to compare. + /// True if the Quaternions are not equal; False if they are equal. + public static bool operator !=(Quaternion value1, Quaternion value2) + => !(value1 == value2); + + /// Multiplies two Quaternions together. + /// The Quaternion on the left side of the multiplication. + /// The Quaternion on the right side of the multiplication. + /// The result of the multiplication. + public static Quaternion operator *(Quaternion value1, Quaternion value2) + { + Quaternion ans; + + T q1x = value1.X; + T q1y = value1.Y; + T q1z = value1.Z; + T q1w = value1.W; + + T q2x = value2.X; + T q2y = value2.Y; + T q2z = value2.Z; + T q2w = value2.W; + + // cross(av, bv) + T cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); + T cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); + T cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); + + T dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), + Scalar.Multiply(q1z, q2z)); + + ans.X = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2w), Scalar.Multiply(q2x, q1w)), cx); + ans.Y = Scalar.Add(Scalar.Add(Scalar.Multiply(q1y, q2w), Scalar.Multiply(q2y, q1w)), cy); + ans.Z = Scalar.Add(Scalar.Add(Scalar.Multiply(q1z, q2w), Scalar.Multiply(q2z, q1w)), cz); + ans.W = Scalar.Subtract(Scalar.Multiply(q1w, q2w), dot); + + return ans; + } + + /// Multiplies a Quaternion by a scalar value. + /// The source Quaternion. + /// The scalar value. + /// The result of the multiplication. + public static Quaternion operator *(Quaternion value1, T value2) + { + Quaternion ans; + + ans.X = Scalar.Multiply(value1.X, value2); + ans.Y = Scalar.Multiply(value1.Y, value2); + ans.Z = Scalar.Multiply(value1.Z, value2); + ans.W = Scalar.Multiply(value1.W, value2); + + return ans; + } + + /// Subtracts one Quaternion from another. + /// The first source Quaternion. + /// The second Quaternion, to be subtracted from the first. + /// The result of the subtraction. + public static Quaternion operator -(Quaternion value1, Quaternion value2) + { + Quaternion ans; + + ans.X = Scalar.Subtract(value1.X, value2.X); + ans.Y = Scalar.Subtract(value1.Y, value2.Y); + ans.Z = Scalar.Subtract(value1.Z, value2.Z); + ans.W = Scalar.Subtract(value1.W, value2.W); + + return ans; + } + + /// Flips the sign of each component of the quaternion. + /// The source Quaternion. + /// The negated Quaternion. + public static Quaternion operator -(Quaternion value) + { + Quaternion ans; + + ans.X = Scalar.Negate(value.X); + ans.Y = Scalar.Negate(value.Y); + ans.Z = Scalar.Negate(value.Z); + ans.W = Scalar.Negate(value.W); + + return ans; + } + + /// Adds two Quaternions element-by-element. + /// The first source Quaternion. + /// The second source Quaternion. + /// The result of adding the Quaternions. + [MethodImpl((MethodImplOptions) 768)] + public static Quaternion Add(Quaternion value1, Quaternion value2) + => value1 + value2; + + /// Concatenates two Quaternions; the result represents the value1 rotation followed by the value2 rotation. + /// The first Quaternion rotation in the series. + /// The second Quaternion rotation in the series. + /// A new Quaternion representing the concatenation of the value1 rotation followed by the value2 rotation. + public static Quaternion Concatenate(Quaternion value1, Quaternion value2) + { + Quaternion ans; + + // Concatenate rotation is actually q2 * q1 instead of q1 * q2. + // So that's why value2 goes q1 and value1 goes q2. + T q1x = value2.X; + T q1y = value2.Y; + T q1z = value2.Z; + T q1w = value2.W; + + T q2x = value1.X; + T q2y = value1.Y; + T q2z = value1.Z; + T q2w = value1.W; + + // cross(av, bv) + T cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); + T cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); + T cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); + + T dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), + Scalar.Multiply(q1z, q2z)); + + ans.X = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2w), Scalar.Multiply(q2x, q1w)), cx); + ans.Y = Scalar.Add(Scalar.Add(Scalar.Multiply(q1y, q2w), Scalar.Multiply(q2y, q1w)), cy); + ans.Z = Scalar.Add(Scalar.Add(Scalar.Multiply(q1z, q2w), Scalar.Multiply(q2z, q1w)), cz); + ans.W = Scalar.Subtract(Scalar.Multiply(q1w, q2w), dot); + + return ans; + } + + /// Creates the conjugate of a specified Quaternion. + /// The Quaternion of which to return the conjugate. + /// A new Quaternion that is the conjugate of the specified one. + public static Quaternion Conjugate(Quaternion value) + { + Quaternion ans; + + ans.X = Scalar.Negate(value.X); + ans.Y = Scalar.Negate(value.Y); + ans.Z = Scalar.Negate(value.Z); + ans.W = value.W; + + return ans; + } + + /// Creates a Quaternion from a normalized vector axis and an angle to rotate about the vector. + /// The unit vector to rotate around. + /// This vector must be normalized before calling this function or the resulting Quaternion will be incorrect. + /// The angle, in radians, to rotate around the vector. + /// The created Quaternion. + public static Quaternion CreateFromAxisAngle(Vector3D axis, T angle) + { + Quaternion ans; + + T halfAngle = Scalar.Divide(angle, Scalar.Two); + T s = Scalar.Sin(halfAngle); + T c = Scalar.Cos(halfAngle); + + ans.X = Scalar.Multiply(axis.X, s); + ans.Y = Scalar.Multiply(axis.Y, s); + ans.Z = Scalar.Multiply(axis.Z, s); + ans.W = c; + + return ans; + } + + /// Creates a Quaternion from the given rotation matrix. + /// The rotation matrix. + /// The created Quaternion. + public static Quaternion CreateFromRotationMatrix(Matrix4X4 matrix) + { + T trace = Scalar.Add(Scalar.Add(matrix.M11, matrix.M22), matrix.M33); + + Quaternion q = default; + + if (Scalar.GreaterThan(trace, Scalar.Zero)) + { + T s = Scalar.Sqrt(Scalar.Add(trace, Scalar.One)); + q.W = Scalar.Divide(s, Scalar.Two); + s = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + q.X = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), s); + q.Y = Scalar.Multiply(Scalar.Subtract(matrix.M31, matrix.M13), s); + q.Z = Scalar.Multiply(Scalar.Subtract(matrix.M12, matrix.M21), s); + } + else + { + if (Scalar.GreaterThanOrEqual(matrix.M11, matrix.M22) && Scalar.GreaterThanOrEqual(matrix.M11, matrix.M33)) + { + T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M11), matrix.M22), matrix.M33)); + T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + q.X = Scalar.Divide(s, Scalar.Two); + q.Y = Scalar.Multiply(Scalar.Add(matrix.M12, matrix.M21), invS); + q.Z = Scalar.Multiply(Scalar.Add(matrix.M13, matrix.M31), invS); + q.W = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), invS); + } + else if (Scalar.GreaterThan(matrix.M22, matrix.M33)) + { + T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M22), matrix.M11), matrix.M33)); + T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + q.X = Scalar.Multiply(Scalar.Add(matrix.M21, matrix.M12), invS); + q.Y = Scalar.Divide(s, Scalar.Two); + q.Z = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); + q.W = Scalar.Multiply(Scalar.Subtract(matrix.M31, matrix.M13), invS); + } + else + { + T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M33), matrix.M11), matrix.M22)); + T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + q.X = Scalar.Multiply(Scalar.Add(matrix.M31, matrix.M13), invS); + q.Y = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); + q.Z = Scalar.Divide(s, Scalar.Two); + q.W = Scalar.Multiply(Scalar.Subtract(matrix.M12, matrix.M21), invS); + } + } + + return q; + } + + /// Creates a Quaternion from the given rotation matrix. + /// The rotation matrix. + /// The created Quaternion. + public static Quaternion CreateFromRotationMatrix(Matrix3X3 matrix) + { + T trace = Scalar.Add(Scalar.Add(matrix.M11, matrix.M22), matrix.M33); + + Quaternion q = default; + + if (Scalar.GreaterThan(trace, Scalar.Zero)) + { + T s = Scalar.Sqrt(Scalar.Add(trace, Scalar.One)); + q.W = Scalar.Divide(s, Scalar.Two); + s = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + q.X = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), s); + q.Y = Scalar.Multiply(Scalar.Subtract(matrix.M31, matrix.M13), s); + q.Z = Scalar.Multiply(Scalar.Subtract(matrix.M12, matrix.M21), s); + } + else + { + if (Scalar.GreaterThanOrEqual(matrix.M11, matrix.M22) && Scalar.GreaterThanOrEqual(matrix.M11, matrix.M33)) + { + T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M11), matrix.M22), matrix.M33)); + T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + q.X = Scalar.Divide(s, Scalar.Two); + q.Y = Scalar.Multiply(Scalar.Add(matrix.M12, matrix.M21), invS); + q.Z = Scalar.Multiply(Scalar.Add(matrix.M13, matrix.M31), invS); + q.W = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), invS); + } + else if (Scalar.GreaterThan(matrix.M22, matrix.M33)) + { + T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M22), matrix.M11), matrix.M33)); + T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + q.X = Scalar.Multiply(Scalar.Add(matrix.M21, matrix.M12), invS); + q.Y = Scalar.Divide(s, Scalar.Two); + q.Z = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); + q.W = Scalar.Multiply(Scalar.Subtract(matrix.M31, matrix.M13), invS); + } + else + { + T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M33), matrix.M11), matrix.M22)); + T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + q.X = Scalar.Multiply(Scalar.Add(matrix.M31, matrix.M13), invS); + q.Y = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); + q.Z = Scalar.Divide(s, Scalar.Two); + q.W = Scalar.Multiply(Scalar.Subtract(matrix.M12, matrix.M21), invS); + } + } + + return q; + } + + /// Creates a new Quaternion from the given yaw, pitch, and roll, in radians. + /// The yaw angle, in radians, around the Y-axis. + /// The pitch angle, in radians, around the X-axis. + /// The roll angle, in radians, around the Z-axis. + /// + public static Quaternion CreateFromYawPitchRoll(T yaw, T pitch, T roll) + { + // Roll first, about axis the object is facing, then + // pitch upward, then yaw to face into the new heading + T sr, cr, sp, cp, sy, cy; + + T halfRoll = Scalar.Divide(roll, Scalar.Two); + sr = Scalar.Sin(halfRoll); + cr = Scalar.Cos(halfRoll); + + T halfPitch = Scalar.Divide(pitch, Scalar.Two); + sp = Scalar.Sin(halfPitch); + cp = Scalar.Cos(halfPitch); + + T halfYaw = Scalar.Divide(yaw, Scalar.Two); + sy = Scalar.Sin(halfYaw); + cy = Scalar.Cos(halfYaw); + + Quaternion result; + + result.X = Scalar.Add(Scalar.Multiply(Scalar.Multiply(cy, sp), cr), Scalar.Multiply(Scalar.Multiply(sy, cp), sr)); + result.Y = Scalar.Subtract(Scalar.Multiply(Scalar.Multiply(sy, cp), cr), Scalar.Multiply(Scalar.Multiply(cy, sp), sr)); + result.Z = Scalar.Subtract(Scalar.Multiply(Scalar.Multiply(cy, cp), sr), Scalar.Multiply(Scalar.Multiply(sy, sp), cr)); + result.W = Scalar.Add(Scalar.Multiply(Scalar.Multiply(cy, cp), cr), Scalar.Multiply(Scalar.Multiply(sy, sp), sr)); + + return result; + } + + /// Divides a Quaternion by another Quaternion. + /// The source Quaternion. + /// The divisor. + /// The result of the division. + [MethodImpl((MethodImplOptions) 768)] + public static Quaternion Divide(Quaternion value1, Quaternion value2) + => value1 / value2; + + /// Calculates the dot product of two Quaternions. + /// The first source Quaternion. + /// The second source Quaternion. + /// The dot product of the Quaternions. + public static T Dot(Quaternion quaternion1, Quaternion quaternion2) + { + return Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(quaternion1.X, quaternion2.X), + Scalar.Multiply(quaternion1.Y, quaternion2.Y)), + Scalar.Multiply(quaternion1.Z, quaternion2.Z)), + Scalar.Multiply(quaternion1.W, quaternion2.W)); + } + + /// Returns the inverse of a Quaternion. + /// The source Quaternion. + /// The inverted Quaternion. + public static Quaternion Inverse(Quaternion value) + { + // -1 ( a -v ) + // q = ( ------------- ------------- ) + // ( a^2 + |v|^2 , a^2 + |v|^2 ) + + Quaternion ans; + + T ls = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, value.X), Scalar.Multiply(value.Y, value.Y)), Scalar.Multiply(value.Z, value.Z)), Scalar.Multiply(value.W, value.W)); + T invNorm = Scalar.Reciprocal(ls); + + ans.X = Scalar.Negate(Scalar.Multiply(value.X, invNorm)); + ans.Y = Scalar.Negate(Scalar.Multiply(value.Y, invNorm)); + ans.Z = Scalar.Negate(Scalar.Multiply(value.Z, invNorm)); + ans.W = Scalar.Multiply(value.W, invNorm); + + return ans; + } + + /// Linearly interpolates between two quaternions. + /// The first source Quaternion. + /// The second source Quaternion. + /// The relative weight of the second source Quaternion in the interpolation. + /// The interpolated Quaternion. + public static Quaternion Lerp(Quaternion quaternion1, Quaternion quaternion2, T amount) + { + T t = amount; + T t1 = Scalar.Subtract(Scalar.One, t); + + Quaternion r = default; + + T dot = Scalar.Add( + Scalar.Add( + Scalar.Add(Scalar.Multiply(quaternion1.X, quaternion2.X), + Scalar.Multiply(quaternion1.Y, quaternion2.Y)), + Scalar.Multiply(quaternion1.Z, quaternion2.Z)), + Scalar.Multiply(quaternion1.W, quaternion2.W)); + + if (Scalar.GreaterThanOrEqual(dot, Scalar.Zero)) + { + r.X = Scalar.Add(Scalar.Multiply(t1, quaternion1.X), Scalar.Multiply(t, quaternion2.X)); + r.Y = Scalar.Add(Scalar.Multiply(t1, quaternion1.Y), Scalar.Multiply(t, quaternion2.Y)); + r.Z = Scalar.Add(Scalar.Multiply(t1, quaternion1.Z), Scalar.Multiply(t, quaternion2.Z)); + r.W = Scalar.Add(Scalar.Multiply(t1, quaternion1.W), Scalar.Multiply(t, quaternion2.W)); + } + else + { + r.X = Scalar.Subtract(Scalar.Multiply(t1, quaternion1.X), Scalar.Multiply(t, quaternion2.X)); + r.Y = Scalar.Subtract(Scalar.Multiply(t1, quaternion1.Y), Scalar.Multiply(t, quaternion2.Y)); + r.Z = Scalar.Subtract(Scalar.Multiply(t1, quaternion1.Z), Scalar.Multiply(t, quaternion2.Z)); + r.W = Scalar.Subtract(Scalar.Multiply(t1, quaternion1.W), Scalar.Multiply(t, quaternion2.W)); + } + + // Normalize it. + T ls = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(r.X, r.X), Scalar.Multiply(r.Y, r.Y)), Scalar.Multiply(r.Z, r.Z)), Scalar.Multiply(r.W, r.W)); + T invNorm = Scalar.Reciprocal(Scalar.Sqrt(ls)); + + r.X = Scalar.Multiply(r.X, invNorm); + r.Y = Scalar.Multiply(r.Y, invNorm); + r.Z = Scalar.Multiply(r.Z, invNorm); + r.W = Scalar.Multiply(r.W, invNorm); + + return r; + } + + /// Multiplies two Quaternions together. + /// The Quaternion on the left side of the multiplication. + /// The Quaternion on the right side of the multiplication. + /// The result of the multiplication. + [MethodImpl((MethodImplOptions) 768)] + public static Quaternion Multiply(Quaternion value1, Quaternion value2) + => value1 * value2; + + /// Multiplies a Quaternion by a scalar value. + /// The source Quaternion. + /// The scalar value. + /// The result of the multiplication. + [MethodImpl((MethodImplOptions) 768)] + public static Quaternion Multiply(Quaternion value1, T value2) + => value1 * value2; + + /// Flips the sign of each component of the quaternion. + /// The source Quaternion. + /// The negated Quaternion. + [MethodImpl((MethodImplOptions) 768)] + public static Quaternion Negate(Quaternion value) + => -value; + + /// Divides each component of the Quaternion by the length of the Quaternion. + /// The source Quaternion. + /// The normalized Quaternion. + public static Quaternion Normalize(Quaternion value) + { + Quaternion ans; + + T ls = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, value.X), Scalar.Multiply(value.Y, value.Y)), Scalar.Multiply(value.Z, value.Z)), Scalar.Multiply(value.W, value.W)); + T invNorm = Scalar.Reciprocal(Scalar.Sqrt(ls)); + + ans.X = Scalar.Multiply(value.X, invNorm); + ans.Y = Scalar.Multiply(value.Y, invNorm); + ans.Z = Scalar.Multiply(value.Z, invNorm); + ans.W = Scalar.Multiply(value.W, invNorm); + + return ans; + } + + /// Interpolates between two quaternions, using spherical linear interpolation. + /// The first source Quaternion. + /// The second source Quaternion. + /// The relative weight of the second source Quaternion in the interpolation. + /// The interpolated Quaternion. + public static Quaternion Slerp(Quaternion quaternion1, Quaternion quaternion2, T amount) + { + T t = amount; + + T cosOmega = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(quaternion1.X, quaternion2.X), Scalar.Multiply(quaternion1.Y, quaternion2.Y)), Scalar.Multiply(quaternion1.Z, quaternion2.Z)), Scalar.Multiply(quaternion1.W, quaternion2.W)); + + bool flip = false; + + if (!Scalar.GreaterThanOrEqual(cosOmega, Scalar.Zero)) + { + flip = true; + cosOmega = Scalar.Negate(cosOmega); + } + + T s1, s2; + + if (Scalar.GreaterThan(cosOmega, Scalar.Subtract(Scalar.One, Scalar.As(SlerpEpsilon)))) + { + // Too close, do straight linear interpolation. + s1 = Scalar.Subtract(Scalar.One, t); + s2 = flip ? Scalar.Negate(t) : t; + } + else + { + T omega = Scalar.Acos(cosOmega); + T invSinOmega = Scalar.Reciprocal(Scalar.Sin(omega)); + + s1 = Scalar.Multiply(Scalar.Sin(Scalar.Multiply(Scalar.Subtract(Scalar.One, t), omega)), invSinOmega); + s2 = (flip) + ? Scalar.Negate(Scalar.Multiply(Scalar.Sin(Scalar.Multiply(t, omega)), invSinOmega)) + : Scalar.Multiply(Scalar.Sin(Scalar.Multiply(t, omega)), invSinOmega); + } + + Quaternion ans; + + ans.X = Scalar.Add(Scalar.Multiply(s1, quaternion1.X), Scalar.Multiply(s2, quaternion2.X)); + ans.Y = Scalar.Add(Scalar.Multiply(s1, quaternion1.Y), Scalar.Multiply(s2, quaternion2.Y)); + ans.Z = Scalar.Add(Scalar.Multiply(s1, quaternion1.Z), Scalar.Multiply(s2, quaternion2.Z)); + ans.W = Scalar.Add(Scalar.Multiply(s1, quaternion1.W), Scalar.Multiply(s2, quaternion2.W)); + + return ans; + } + + /// Subtracts one Quaternion from another. + /// The first source Quaternion. + /// The second Quaternion, to be subtracted from the first. + /// The result of the subtraction. + [MethodImpl((MethodImplOptions) 768)] + public static Quaternion Subtract(Quaternion value1, Quaternion value2) + => value1 - value2; + + /// Returns a boolean indicating whether the given Object is equal to this Quaternion instance. + /// The Object to compare against. + /// True if the Object is equal to this Quaternion; False otherwise. + public override readonly bool Equals(object? obj) + => (obj is Quaternion other) && Equals(other); + + /// Returns a boolean indicating whether the given Quaternion is equal to this Quaternion instance. + /// The Quaternion to compare this instance to. + /// True if the other Quaternion is equal to this instance; False otherwise. + public readonly bool Equals(Quaternion other) + => this == other; + + /// Returns the hash code for this instance. + /// The hash code. + public override readonly int GetHashCode() + { + return unchecked(X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode()); + } + + /// Calculates the length of the Quaternion. + /// The computed length of the Quaternion. + public readonly T Length() + => Scalar.Sqrt(LengthSquared()); + + /// Calculates the length squared of the Quaternion. This operation is cheaper than Length(). + /// The length squared of the Quaternion. + public readonly T LengthSquared() + => Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(X, X), Scalar.Multiply(Y, Y)), Scalar.Multiply(Z, Z)), Scalar.Multiply(W, W)); + + /// Returns a String representing this Quaternion instance. + /// The string representation. + public override readonly string ToString() + { + return string.Format(CultureInfo.CurrentCulture, "{{X:{0} Y:{1} Z:{2} W:{3}}}", X, Y, Z, W); + } + + /// + /// Converts a into one with a of + /// + /// The source matrix + /// The matrix + public static explicit operator Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Converts a into one with a of + /// + /// The source matrix + /// The matrix + public static explicit operator Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Converts a into + /// + /// The source quaternion + /// The quaternion + public static explicit operator System.Numerics.Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Converts a into one with a of + /// + /// The source matrix + /// The matrix + public static explicit operator Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Converts a into one with a of + /// + /// The source matrix + /// The matrix + public static explicit operator Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Converts a into one with a of + /// + /// The source matrix + /// The matrix + public static explicit operator Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Converts a into one with a of + /// + /// The source matrix + /// The matrix + public static explicit operator Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Converts a into one with a of + /// + /// The source matrix + /// The matrix + public static explicit operator Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Converts a into one with a of + /// + /// The source matrix + /// The matrix + public static explicit operator Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Converts a into one with a of + /// + /// The source matrix + /// The matrix + public static explicit operator Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Converts a into one with a of + /// + /// The source matrix + /// The matrix + public static explicit operator Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Converts a into one with a of + /// + /// The source matrix + /// The matrix + public static explicit operator Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Converts a into one with a of + /// + /// The source matrix + /// The matrix + public static explicit operator Quaternion(Quaternion from) + => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), + Scalar.As(from.W)); + + /// + /// Returns this quaternion casted to + /// + /// The type to cast to + /// The casted quaternion + public Quaternion As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + { + return new(Scalar.As(X), Scalar.As(Y), Scalar.As(Z), Scalar.As(W)); + } + } +} diff --git a/sources/Maths/Maths/Quaternion.cs b/sources/Maths/Maths/Quaternion.cs index 67f99086a2..fc7921fb15 100644 --- a/sources/Maths/Maths/Quaternion.cs +++ b/sources/Maths/Maths/Quaternion.cs @@ -2,37 +2,31 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; -using System.Globalization; -using System.Runtime.CompilerServices; -using System.Runtime.Serialization; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using System.Text; +using System.Threading.Tasks; namespace Silk.NET.Maths { /// - /// Represents a vector that is used to encode three-dimensional physical rotations. + /// Represents a four-dimensional vector used to encode 3D rotations. /// - /// The type used to store values. - [Serializable] - [DataContract] - public struct Quaternion - : IEquatable> where T : unmanaged, IFormattable, IEquatable, IComparable + internal struct Quaternion : + IEquatable> + where T : IBinaryFloatingPointIeee754 { - private const float SlerpEpsilon = 1e-6f; - /// Specifies the X-value of the vector component of the Quaternion. - [DataMember] public T X; /// Specifies the Y-value of the vector component of the Quaternion. - [DataMember] public T Y; /// Specifies the Z-value of the vector component of the Quaternion. - [DataMember] public T Z; - /// Specifies the rotation component of the Quaternion. - [DataMember] + /// Specifies the W-value of the scalar component of the Quaternion. public T W; /// Constructs a Quaternion from the given components. @@ -48,746 +42,29 @@ public Quaternion(T x, T y, T z, T w) W = w; } - /// Constructs a Quaternion from the given vector and rotation parts. - /// The vector part of the Quaternion. - /// The rotation part of the Quaternion. - public Quaternion(Vector3D vectorPart, T scalarPart) - { - X = vectorPart.X; - Y = vectorPart.Y; - Z = vectorPart.Z; - W = scalarPart; - } + // TODO: Vector4F/Vector3F constructors /// Returns a Quaternion representing no rotation. - public static Quaternion Identity => new(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); - - /// Returns whether the Quaternion is the identity Quaternion. - [IgnoreDataMember] - public readonly bool IsIdentity => this == Identity; - - /// Adds two Quaternions element-by-element. - /// The first source Quaternion. - /// The second source Quaternion. - /// The result of adding the Quaternions. - public static Quaternion operator +(Quaternion value1, Quaternion value2) - { - Quaternion ans; - - ans.X = Scalar.Add(value1.X, value2.X); - ans.Y = Scalar.Add(value1.Y, value2.Y); - ans.Z = Scalar.Add(value1.Z, value2.Z); - ans.W = Scalar.Add(value1.W, value2.W); - - return ans; - } - - /// Divides a Quaternion by another Quaternion. - /// The source Quaternion. - /// The divisor. - /// The result of the division. - public static Quaternion operator /(Quaternion value1, Quaternion value2) - { - Quaternion ans; - - T q1x = value1.X; - T q1y = value1.Y; - T q1z = value1.Z; - T q1w = value1.W; - - //------------------------------------- - // Inverse part. - T ls = Scalar.Add( - Scalar.Add( - Scalar.Add(Scalar.Multiply(value2.X, value2.X), Scalar.Multiply(value2.Y, value2.Y)), - Scalar.Multiply(value2.Z, value2.Z)), Scalar.Multiply(value2.W, value2.W)); - T invNorm = Scalar.Reciprocal(ls); - - T q2x = Scalar.Negate(Scalar.Multiply(value2.X, invNorm)); - T q2y = Scalar.Negate(Scalar.Multiply(value2.Y, invNorm)); - T q2z = Scalar.Negate(Scalar.Multiply(value2.Z, invNorm)); - T q2w = Scalar.Multiply(value2.W, invNorm); - - //------------------------------------- - // Multiply part. - - // cross(av, bv) - T cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); - T cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); - T cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); - - T dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), - Scalar.Multiply(q1z, q2z)); - - ans.X = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2w), Scalar.Multiply(q2x, q1w)), cx); - ans.Y = Scalar.Add(Scalar.Add(Scalar.Multiply(q1y, q2w), Scalar.Multiply(q2y, q1w)), cy); - ans.Z = Scalar.Add(Scalar.Add(Scalar.Multiply(q1z, q2w), Scalar.Multiply(q2z, q1w)), cz); - ans.W = Scalar.Subtract(Scalar.Multiply(q1w, q2w), dot); - - return ans; - } - - /// Returns a boolean indicating whether the two given Quaternions are equal. - /// The first Quaternion to compare. - /// The second Quaternion to compare. - /// True if the Quaternions are equal; False otherwise. - public static bool operator ==(Quaternion value1, Quaternion value2) - => Scalar.Equal(value1.X, value2.X) - && Scalar.Equal(value1.Y, value2.Y) - && Scalar.Equal(value1.Z, value2.Z) - && Scalar.Equal(value1.W, value2.W); - - /// Returns a boolean indicating whether the two given Quaternions are not equal. - /// The first Quaternion to compare. - /// The second Quaternion to compare. - /// True if the Quaternions are not equal; False if they are equal. - public static bool operator !=(Quaternion value1, Quaternion value2) - => !(value1 == value2); - - /// Multiplies two Quaternions together. - /// The Quaternion on the left side of the multiplication. - /// The Quaternion on the right side of the multiplication. - /// The result of the multiplication. - public static Quaternion operator *(Quaternion value1, Quaternion value2) - { - Quaternion ans; - - T q1x = value1.X; - T q1y = value1.Y; - T q1z = value1.Z; - T q1w = value1.W; - - T q2x = value2.X; - T q2y = value2.Y; - T q2z = value2.Z; - T q2w = value2.W; - - // cross(av, bv) - T cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); - T cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); - T cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); - - T dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), - Scalar.Multiply(q1z, q2z)); - - ans.X = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2w), Scalar.Multiply(q2x, q1w)), cx); - ans.Y = Scalar.Add(Scalar.Add(Scalar.Multiply(q1y, q2w), Scalar.Multiply(q2y, q1w)), cy); - ans.Z = Scalar.Add(Scalar.Add(Scalar.Multiply(q1z, q2w), Scalar.Multiply(q2z, q1w)), cz); - ans.W = Scalar.Subtract(Scalar.Multiply(q1w, q2w), dot); - - return ans; - } - - /// Multiplies a Quaternion by a scalar value. - /// The source Quaternion. - /// The scalar value. - /// The result of the multiplication. - public static Quaternion operator *(Quaternion value1, T value2) - { - Quaternion ans; - - ans.X = Scalar.Multiply(value1.X, value2); - ans.Y = Scalar.Multiply(value1.Y, value2); - ans.Z = Scalar.Multiply(value1.Z, value2); - ans.W = Scalar.Multiply(value1.W, value2); - - return ans; - } - - /// Subtracts one Quaternion from another. - /// The first source Quaternion. - /// The second Quaternion, to be subtracted from the first. - /// The result of the subtraction. - public static Quaternion operator -(Quaternion value1, Quaternion value2) - { - Quaternion ans; - - ans.X = Scalar.Subtract(value1.X, value2.X); - ans.Y = Scalar.Subtract(value1.Y, value2.Y); - ans.Z = Scalar.Subtract(value1.Z, value2.Z); - ans.W = Scalar.Subtract(value1.W, value2.W); - - return ans; - } - - /// Flips the sign of each component of the quaternion. - /// The source Quaternion. - /// The negated Quaternion. - public static Quaternion operator -(Quaternion value) - { - Quaternion ans; - - ans.X = Scalar.Negate(value.X); - ans.Y = Scalar.Negate(value.Y); - ans.Z = Scalar.Negate(value.Z); - ans.W = Scalar.Negate(value.W); - - return ans; - } - - /// Adds two Quaternions element-by-element. - /// The first source Quaternion. - /// The second source Quaternion. - /// The result of adding the Quaternions. - [MethodImpl((MethodImplOptions) 768)] - public static Quaternion Add(Quaternion value1, Quaternion value2) - => value1 + value2; - - /// Concatenates two Quaternions; the result represents the value1 rotation followed by the value2 rotation. - /// The first Quaternion rotation in the series. - /// The second Quaternion rotation in the series. - /// A new Quaternion representing the concatenation of the value1 rotation followed by the value2 rotation. - public static Quaternion Concatenate(Quaternion value1, Quaternion value2) - { - Quaternion ans; - - // Concatenate rotation is actually q2 * q1 instead of q1 * q2. - // So that's why value2 goes q1 and value1 goes q2. - T q1x = value2.X; - T q1y = value2.Y; - T q1z = value2.Z; - T q1w = value2.W; - - T q2x = value1.X; - T q2y = value1.Y; - T q2z = value1.Z; - T q2w = value1.W; - - // cross(av, bv) - T cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); - T cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); - T cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); - - T dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), - Scalar.Multiply(q1z, q2z)); - - ans.X = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2w), Scalar.Multiply(q2x, q1w)), cx); - ans.Y = Scalar.Add(Scalar.Add(Scalar.Multiply(q1y, q2w), Scalar.Multiply(q2y, q1w)), cy); - ans.Z = Scalar.Add(Scalar.Add(Scalar.Multiply(q1z, q2w), Scalar.Multiply(q2z, q1w)), cz); - ans.W = Scalar.Subtract(Scalar.Multiply(q1w, q2w), dot); - - return ans; - } - - /// Creates the conjugate of a specified Quaternion. - /// The Quaternion of which to return the conjugate. - /// A new Quaternion that is the conjugate of the specified one. - public static Quaternion Conjugate(Quaternion value) - { - Quaternion ans; - - ans.X = Scalar.Negate(value.X); - ans.Y = Scalar.Negate(value.Y); - ans.Z = Scalar.Negate(value.Z); - ans.W = value.W; - - return ans; - } - - /// Creates a Quaternion from a normalized vector axis and an angle to rotate about the vector. - /// The unit vector to rotate around. - /// This vector must be normalized before calling this function or the resulting Quaternion will be incorrect. - /// The angle, in radians, to rotate around the vector. - /// The created Quaternion. - public static Quaternion CreateFromAxisAngle(Vector3D axis, T angle) - { - Quaternion ans; - - T halfAngle = Scalar.Divide(angle, Scalar.Two); - T s = Scalar.Sin(halfAngle); - T c = Scalar.Cos(halfAngle); - - ans.X = Scalar.Multiply(axis.X, s); - ans.Y = Scalar.Multiply(axis.Y, s); - ans.Z = Scalar.Multiply(axis.Z, s); - ans.W = c; - - return ans; - } - - /// Creates a Quaternion from the given rotation matrix. - /// The rotation matrix. - /// The created Quaternion. - public static Quaternion CreateFromRotationMatrix(Matrix4X4 matrix) - { - T trace = Scalar.Add(Scalar.Add(matrix.M11, matrix.M22), matrix.M33); - - Quaternion q = default; - - if (Scalar.GreaterThan(trace, Scalar.Zero)) - { - T s = Scalar.Sqrt(Scalar.Add(trace, Scalar.One)); - q.W = Scalar.Divide(s, Scalar.Two); - s = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), s); - q.Y = Scalar.Multiply(Scalar.Subtract(matrix.M31, matrix.M13), s); - q.Z = Scalar.Multiply(Scalar.Subtract(matrix.M12, matrix.M21), s); - } - else - { - if (Scalar.GreaterThanOrEqual(matrix.M11, matrix.M22) && Scalar.GreaterThanOrEqual(matrix.M11, matrix.M33)) - { - T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M11), matrix.M22), matrix.M33)); - T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Divide(s, Scalar.Two); - q.Y = Scalar.Multiply(Scalar.Add(matrix.M12, matrix.M21), invS); - q.Z = Scalar.Multiply(Scalar.Add(matrix.M13, matrix.M31), invS); - q.W = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), invS); - } - else if (Scalar.GreaterThan(matrix.M22, matrix.M33)) - { - T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M22), matrix.M11), matrix.M33)); - T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Multiply(Scalar.Add(matrix.M21, matrix.M12), invS); - q.Y = Scalar.Divide(s, Scalar.Two); - q.Z = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); - q.W = Scalar.Multiply(Scalar.Subtract(matrix.M31, matrix.M13), invS); - } - else - { - T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M33), matrix.M11), matrix.M22)); - T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Multiply(Scalar.Add(matrix.M31, matrix.M13), invS); - q.Y = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); - q.Z = Scalar.Divide(s, Scalar.Two); - q.W = Scalar.Multiply(Scalar.Subtract(matrix.M12, matrix.M21), invS); - } - } - - return q; - } - - /// Creates a Quaternion from the given rotation matrix. - /// The rotation matrix. - /// The created Quaternion. - public static Quaternion CreateFromRotationMatrix(Matrix3X3 matrix) - { - T trace = Scalar.Add(Scalar.Add(matrix.M11, matrix.M22), matrix.M33); - - Quaternion q = default; - - if (Scalar.GreaterThan(trace, Scalar.Zero)) - { - T s = Scalar.Sqrt(Scalar.Add(trace, Scalar.One)); - q.W = Scalar.Divide(s, Scalar.Two); - s = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), s); - q.Y = Scalar.Multiply(Scalar.Subtract(matrix.M31, matrix.M13), s); - q.Z = Scalar.Multiply(Scalar.Subtract(matrix.M12, matrix.M21), s); - } - else - { - if (Scalar.GreaterThanOrEqual(matrix.M11, matrix.M22) && Scalar.GreaterThanOrEqual(matrix.M11, matrix.M33)) - { - T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M11), matrix.M22), matrix.M33)); - T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Divide(s, Scalar.Two); - q.Y = Scalar.Multiply(Scalar.Add(matrix.M12, matrix.M21), invS); - q.Z = Scalar.Multiply(Scalar.Add(matrix.M13, matrix.M31), invS); - q.W = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), invS); - } - else if (Scalar.GreaterThan(matrix.M22, matrix.M33)) - { - T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M22), matrix.M11), matrix.M33)); - T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Multiply(Scalar.Add(matrix.M21, matrix.M12), invS); - q.Y = Scalar.Divide(s, Scalar.Two); - q.Z = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); - q.W = Scalar.Multiply(Scalar.Subtract(matrix.M31, matrix.M13), invS); - } - else - { - T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M33), matrix.M11), matrix.M22)); - T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Multiply(Scalar.Add(matrix.M31, matrix.M13), invS); - q.Y = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); - q.Z = Scalar.Divide(s, Scalar.Two); - q.W = Scalar.Multiply(Scalar.Subtract(matrix.M12, matrix.M21), invS); - } - } - - return q; - } - - /// Creates a new Quaternion from the given yaw, pitch, and roll, in radians. - /// The yaw angle, in radians, around the Y-axis. - /// The pitch angle, in radians, around the X-axis. - /// The roll angle, in radians, around the Z-axis. - /// - public static Quaternion CreateFromYawPitchRoll(T yaw, T pitch, T roll) - { - // Roll first, about axis the object is facing, then - // pitch upward, then yaw to face into the new heading - T sr, cr, sp, cp, sy, cy; - - T halfRoll = Scalar.Divide(roll, Scalar.Two); - sr = Scalar.Sin(halfRoll); - cr = Scalar.Cos(halfRoll); - - T halfPitch = Scalar.Divide(pitch, Scalar.Two); - sp = Scalar.Sin(halfPitch); - cp = Scalar.Cos(halfPitch); - - T halfYaw = Scalar.Divide(yaw, Scalar.Two); - sy = Scalar.Sin(halfYaw); - cy = Scalar.Cos(halfYaw); - - Quaternion result; - - result.X = Scalar.Add(Scalar.Multiply(Scalar.Multiply(cy, sp), cr), Scalar.Multiply(Scalar.Multiply(sy, cp), sr)); - result.Y = Scalar.Subtract(Scalar.Multiply(Scalar.Multiply(sy, cp), cr), Scalar.Multiply(Scalar.Multiply(cy, sp), sr)); - result.Z = Scalar.Subtract(Scalar.Multiply(Scalar.Multiply(cy, cp), sr), Scalar.Multiply(Scalar.Multiply(sy, sp), cr)); - result.W = Scalar.Add(Scalar.Multiply(Scalar.Multiply(cy, cp), cr), Scalar.Multiply(Scalar.Multiply(sy, sp), sr)); - - return result; - } - - /// Divides a Quaternion by another Quaternion. - /// The source Quaternion. - /// The divisor. - /// The result of the division. - [MethodImpl((MethodImplOptions) 768)] - public static Quaternion Divide(Quaternion value1, Quaternion value2) - => value1 / value2; - - /// Calculates the dot product of two Quaternions. - /// The first source Quaternion. - /// The second source Quaternion. - /// The dot product of the Quaternions. - public static T Dot(Quaternion quaternion1, Quaternion quaternion2) - { - return Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(quaternion1.X, quaternion2.X), - Scalar.Multiply(quaternion1.Y, quaternion2.Y)), - Scalar.Multiply(quaternion1.Z, quaternion2.Z)), - Scalar.Multiply(quaternion1.W, quaternion2.W)); - } - - /// Returns the inverse of a Quaternion. - /// The source Quaternion. - /// The inverted Quaternion. - public static Quaternion Inverse(Quaternion value) - { - // -1 ( a -v ) - // q = ( ------------- ------------- ) - // ( a^2 + |v|^2 , a^2 + |v|^2 ) - - Quaternion ans; - - T ls = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, value.X), Scalar.Multiply(value.Y, value.Y)), Scalar.Multiply(value.Z, value.Z)), Scalar.Multiply(value.W, value.W)); - T invNorm = Scalar.Reciprocal(ls); - - ans.X = Scalar.Negate(Scalar.Multiply(value.X, invNorm)); - ans.Y = Scalar.Negate(Scalar.Multiply(value.Y, invNorm)); - ans.Z = Scalar.Negate(Scalar.Multiply(value.Z, invNorm)); - ans.W = Scalar.Multiply(value.W, invNorm); - - return ans; - } - - /// Linearly interpolates between two quaternions. - /// The first source Quaternion. - /// The second source Quaternion. - /// The relative weight of the second source Quaternion in the interpolation. - /// The interpolated Quaternion. - public static Quaternion Lerp(Quaternion quaternion1, Quaternion quaternion2, T amount) - { - T t = amount; - T t1 = Scalar.Subtract(Scalar.One, t); - - Quaternion r = default; - - T dot = Scalar.Add( - Scalar.Add( - Scalar.Add(Scalar.Multiply(quaternion1.X, quaternion2.X), - Scalar.Multiply(quaternion1.Y, quaternion2.Y)), - Scalar.Multiply(quaternion1.Z, quaternion2.Z)), - Scalar.Multiply(quaternion1.W, quaternion2.W)); - - if (Scalar.GreaterThanOrEqual(dot, Scalar.Zero)) - { - r.X = Scalar.Add(Scalar.Multiply(t1, quaternion1.X), Scalar.Multiply(t, quaternion2.X)); - r.Y = Scalar.Add(Scalar.Multiply(t1, quaternion1.Y), Scalar.Multiply(t, quaternion2.Y)); - r.Z = Scalar.Add(Scalar.Multiply(t1, quaternion1.Z), Scalar.Multiply(t, quaternion2.Z)); - r.W = Scalar.Add(Scalar.Multiply(t1, quaternion1.W), Scalar.Multiply(t, quaternion2.W)); - } - else - { - r.X = Scalar.Subtract(Scalar.Multiply(t1, quaternion1.X), Scalar.Multiply(t, quaternion2.X)); - r.Y = Scalar.Subtract(Scalar.Multiply(t1, quaternion1.Y), Scalar.Multiply(t, quaternion2.Y)); - r.Z = Scalar.Subtract(Scalar.Multiply(t1, quaternion1.Z), Scalar.Multiply(t, quaternion2.Z)); - r.W = Scalar.Subtract(Scalar.Multiply(t1, quaternion1.W), Scalar.Multiply(t, quaternion2.W)); - } - - // Normalize it. - T ls = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(r.X, r.X), Scalar.Multiply(r.Y, r.Y)), Scalar.Multiply(r.Z, r.Z)), Scalar.Multiply(r.W, r.W)); - T invNorm = Scalar.Reciprocal(Scalar.Sqrt(ls)); - - r.X = Scalar.Multiply(r.X, invNorm); - r.Y = Scalar.Multiply(r.Y, invNorm); - r.Z = Scalar.Multiply(r.Z, invNorm); - r.W = Scalar.Multiply(r.W, invNorm); - - return r; - } - - /// Multiplies two Quaternions together. - /// The Quaternion on the left side of the multiplication. - /// The Quaternion on the right side of the multiplication. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Quaternion Multiply(Quaternion value1, Quaternion value2) - => value1 * value2; - - /// Multiplies a Quaternion by a scalar value. - /// The source Quaternion. - /// The scalar value. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Quaternion Multiply(Quaternion value1, T value2) - => value1 * value2; - - /// Flips the sign of each component of the quaternion. - /// The source Quaternion. - /// The negated Quaternion. - [MethodImpl((MethodImplOptions) 768)] - public static Quaternion Negate(Quaternion value) - => -value; - - /// Divides each component of the Quaternion by the length of the Quaternion. - /// The source Quaternion. - /// The normalized Quaternion. - public static Quaternion Normalize(Quaternion value) - { - Quaternion ans; - - T ls = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, value.X), Scalar.Multiply(value.Y, value.Y)), Scalar.Multiply(value.Z, value.Z)), Scalar.Multiply(value.W, value.W)); - T invNorm = Scalar.Reciprocal(Scalar.Sqrt(ls)); - - ans.X = Scalar.Multiply(value.X, invNorm); - ans.Y = Scalar.Multiply(value.Y, invNorm); - ans.Z = Scalar.Multiply(value.Z, invNorm); - ans.W = Scalar.Multiply(value.W, invNorm); - - return ans; - } - - /// Interpolates between two quaternions, using spherical linear interpolation. - /// The first source Quaternion. - /// The second source Quaternion. - /// The relative weight of the second source Quaternion in the interpolation. - /// The interpolated Quaternion. - public static Quaternion Slerp(Quaternion quaternion1, Quaternion quaternion2, T amount) - { - T t = amount; - - T cosOmega = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(quaternion1.X, quaternion2.X), Scalar.Multiply(quaternion1.Y, quaternion2.Y)), Scalar.Multiply(quaternion1.Z, quaternion2.Z)), Scalar.Multiply(quaternion1.W, quaternion2.W)); - - bool flip = false; - - if (!Scalar.GreaterThanOrEqual(cosOmega, Scalar.Zero)) - { - flip = true; - cosOmega = Scalar.Negate(cosOmega); - } - - T s1, s2; - - if (Scalar.GreaterThan(cosOmega, Scalar.Subtract(Scalar.One, Scalar.As(SlerpEpsilon)))) - { - // Too close, do straight linear interpolation. - s1 = Scalar.Subtract(Scalar.One, t); - s2 = flip ? Scalar.Negate(t) : t; - } - else - { - T omega = Scalar.Acos(cosOmega); - T invSinOmega = Scalar.Reciprocal(Scalar.Sin(omega)); - - s1 = Scalar.Multiply(Scalar.Sin(Scalar.Multiply(Scalar.Subtract(Scalar.One, t), omega)), invSinOmega); - s2 = (flip) - ? Scalar.Negate(Scalar.Multiply(Scalar.Sin(Scalar.Multiply(t, omega)), invSinOmega)) - : Scalar.Multiply(Scalar.Sin(Scalar.Multiply(t, omega)), invSinOmega); - } - - Quaternion ans; - - ans.X = Scalar.Add(Scalar.Multiply(s1, quaternion1.X), Scalar.Multiply(s2, quaternion2.X)); - ans.Y = Scalar.Add(Scalar.Multiply(s1, quaternion1.Y), Scalar.Multiply(s2, quaternion2.Y)); - ans.Z = Scalar.Add(Scalar.Multiply(s1, quaternion1.Z), Scalar.Multiply(s2, quaternion2.Z)); - ans.W = Scalar.Add(Scalar.Multiply(s1, quaternion1.W), Scalar.Multiply(s2, quaternion2.W)); - - return ans; - } - - /// Subtracts one Quaternion from another. - /// The first source Quaternion. - /// The second Quaternion, to be subtracted from the first. - /// The result of the subtraction. - [MethodImpl((MethodImplOptions) 768)] - public static Quaternion Subtract(Quaternion value1, Quaternion value2) - => value1 - value2; + public static Quaternion Identity => new Quaternion(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); /// Returns a boolean indicating whether the given Object is equal to this Quaternion instance. - /// The Object to compare against. - /// True if the Object is equal to this Quaternion; False otherwise. - public override readonly bool Equals(object? obj) - => (obj is Quaternion other) && Equals(other); + public override bool Equals(object? obj) => + obj is Quaternion other && Equals(other); /// Returns a boolean indicating whether the given Quaternion is equal to this Quaternion instance. - /// The Quaternion to compare this instance to. - /// True if the other Quaternion is equal to this instance; False otherwise. - public readonly bool Equals(Quaternion other) - => this == other; + public bool Equals(Quaternion other) => + this == other; /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - return unchecked(X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode()); - } - - /// Calculates the length of the Quaternion. - /// The computed length of the Quaternion. - public readonly T Length() - => Scalar.Sqrt(LengthSquared()); - - /// Calculates the length squared of the Quaternion. This operation is cheaper than Length(). - /// The length squared of the Quaternion. - public readonly T LengthSquared() - => Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(X, X), Scalar.Multiply(Y, Y)), Scalar.Multiply(Z, Z)), Scalar.Multiply(W, W)); - - /// Returns a String representing this Quaternion instance. - /// The string representation. - public override readonly string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "{{X:{0} Y:{1} Z:{2} W:{3}}}", X, Y, Z, W); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); + public override int GetHashCode() => + HashCode.Combine(X, Y, Z, W); - /// - /// Converts a into - /// - /// The source quaternion - /// The quaternion - public static explicit operator System.Numerics.Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); + // Equality Operators + public static bool operator ==(Quaternion left, Quaternion right) => + left.X == right.X && left.Y == right.Y && left.Z == right.Z && left.W == right.W; - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Returns this quaternion casted to - /// - /// The type to cast to - /// The casted quaternion - public Quaternion As() where TOther : unmanaged, IFormattable, IEquatable, IComparable - { - return new(Scalar.As(X), Scalar.As(Y), Scalar.As(Z), Scalar.As(W)); - } + public static bool operator !=(Quaternion left, Quaternion right) => + !(left == right); } -} \ No newline at end of file +} From cc7ebb62218e2ce42526c31fe899647b00159b26 Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Wed, 28 May 2025 23:14:09 +1000 Subject: [PATCH 12/67] Clarify current state of new Math type's indexers. --- sources/Maths/Maths/Quaternion.cs | 19 ++++++++++++++++--- sources/Maths/Maths/Vector2I.cs | 1 + sources/Maths/Maths/Vector3I.cs | 1 + sources/Maths/Maths/Vector4I.cs | 1 + 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/sources/Maths/Maths/Quaternion.cs b/sources/Maths/Maths/Quaternion.cs index fc7921fb15..4df87b736a 100644 --- a/sources/Maths/Maths/Quaternion.cs +++ b/sources/Maths/Maths/Quaternion.cs @@ -42,16 +42,29 @@ public Quaternion(T x, T y, T z, T w) W = w; } + /// Gets the rotation angle represented by the . + public T Angle => T.CreateChecked(2) * T.Acos(W); + + ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z, 3 = W. + // TODO: Make this a ref + public T this[int index] => index switch { + 0 => X, + 1 => Y, + 2 => Z, + 3 => W, + _ => throw new IndexOutOfRangeException(nameof(index)) + }; + // TODO: Vector4F/Vector3F constructors - /// Returns a Quaternion representing no rotation. + /// Returns a representing no rotation. public static Quaternion Identity => new Quaternion(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); - /// Returns a boolean indicating whether the given Object is equal to this Quaternion instance. + /// Returns a boolean indicating whether the given Object is equal to this instance. public override bool Equals(object? obj) => obj is Quaternion other && Equals(other); - /// Returns a boolean indicating whether the given Quaternion is equal to this Quaternion instance. + /// Returns a boolean indicating whether the given is equal to this instance. public bool Equals(Quaternion other) => this == other; diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index ab8ba58dfc..2fde654cb2 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -66,6 +66,7 @@ public Vector2I(ReadOnlySpan values) public int Count => 2; ///Gets the component at the specified index: 0 = X, 1 = Y. + // TODO: Make this a ref public T this[int index] => index switch { 0 => X, 1 => Y, diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index 357643abd9..83d14d802f 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -73,6 +73,7 @@ public Vector3I(ReadOnlySpan values) public int Count => 3; ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z. + // TODO: Make this a ref public T this[int index] => index switch { 0 => X, 1 => Y, diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs index b1866d3f00..42a095e035 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4I.cs @@ -80,6 +80,7 @@ public Vector4I(ReadOnlySpan values) public int Count => 4; ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z, 3 = W. + // TODO: Make this a ref public T this[int index] => index switch { 0 => X, 1 => Y, From 6af8612da32a4df532bee67a023cb9552de3912c Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Fri, 30 May 2025 17:56:20 +1000 Subject: [PATCH 13/67] Add lower-dimensional VectorI constructors. --- sources/Maths/Maths/Vector3I.cs | 4 ++++ sources/Maths/Maths/Vector4I.cs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index 83d14d802f..9aa815c588 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -48,6 +48,10 @@ public Vector3I(ReadOnlySpan values) Z = values[2]; } + /// Initializes the vector using a Vector2I for X and Y, and a separate value for Z. + // TODO: Make sure lower dimensional constructors arent meant to zero-out the higher dimensions + public Vector3I(Vector2I xy, T z) => (X, Y, Z) = (xy.X, xy.Y, z); + /// Gets a vector whose 3 elements are equal to one. public static Vector3I One => new(Scalar.One); diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs index 42a095e035..038c4be24b 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4I.cs @@ -52,6 +52,13 @@ public Vector4I(ReadOnlySpan values) W = values[3]; } + /// Initializes the vector using a Vector2I for X and Y, and a separate value for Z and W. + // TODO: Make sure lower dimensional constructors arent meant to zero-out the higher dimensions + public Vector4I(Vector2I xy, T z, T w) => (X, Y, Z, W) = (xy.X, xy.Y, z, w); + + /// Initializes the vector using a Vector3I for X, Y and Z, and a separate value for W. + public Vector4I(Vector3I xyz, T w) => (X, Y, Z, W) = (xyz.X, xyz.Y, xyz.Z, w); + /// Gets a vector whose 4 elements are equal to one. public static Vector4I One => new(Scalar.One); From 737b5a8d1b7963aaf35f48619936ef6aa07d11dc Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Fri, 30 May 2025 18:26:22 +1000 Subject: [PATCH 14/67] Add `Vector2F`. --- sources/Maths/Maths/Vector2F.cs | 669 ++++++++++++++++++++++++++++++++ 1 file changed, 669 insertions(+) create mode 100644 sources/Maths/Maths/Vector2F.cs diff --git a/sources/Maths/Maths/Vector2F.cs b/sources/Maths/Maths/Vector2F.cs new file mode 100644 index 0000000000..6f563ced9e --- /dev/null +++ b/sources/Maths/Maths/Vector2F.cs @@ -0,0 +1,669 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + + +using System; +using System.Collections; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Numerics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; + +namespace Silk.NET.Maths +{ + /// A structure representing a 2D floating-point vector. + internal struct Vector2F : + IEquatable>, + IReadOnlyList, + ISpanFormattable, + ISpanParsable>, + IUtf8SpanFormattable, + IUtf8SpanParsable>, + IParsable>, + IFormattable + where T : IBinaryFloatingPointIeee754 + { + /// The X component of the vector. + public T X; + + /// The Y component of the vector. + public T Y; + + /// Initializes both components to the same value. + public Vector2F(T value) => (X, Y) = (value, value); + + /// Initializes the vector with individual values for X and Y. + public Vector2F(T x, T y) => (X, Y) = (x, y); + + /// Initializes the vector from a span of two values. + public Vector2F(ReadOnlySpan values) + { + if (values.Length != 2) + throw new ArgumentException("Input span must contain exactly 2 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + } + + /// Gets a vector whose 2 elements are equal to one. + public static Vector2F One => new(Scalar.One); + + /// Returns a vector whose 2 elements are equal to zero. + public static Vector2F Zero => default; + + /// Gets the vector (1, 0). + public static Vector2F UnitX => new(Scalar.One, Scalar.Zero); + + /// Gets the vector (0, 1). + public static Vector2F UnitY => new(Scalar.Zero, Scalar.One); + + /// Gets a vector with all bits set for each component. + public static Vector2F AllBitsSet => new(T.AllBitsSet, T.AllBitsSet); + + /// Gets the squared length of the vector (dot product with itself). + public T LengthSquared => (X * X) + (Y * Y); + + /// Gets the length of the vector. + public T Length => T.Sqrt(LengthSquared); + + /// The number of elements in the vector. + public int Count => 2; + + ///Gets the component at the specified index: 0 = X, 1 = Y. + public T this[int index] => index switch { + 0 => X, + 1 => Y, + _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1.") + }; + + /// Returns a boolean indicating whether the given Object is equal to this instance. + public override bool Equals(object? obj) => obj is Vector2F other && Equals(other); + + /// Returns a boolean indicating whether the given Vector2F is equal to this instance. + public bool Equals(Vector2F other) => this == other; + + /// Returns the hash code for this instance. + public override int GetHashCode() => HashCode.Combine(X, Y); + + /// Returns an enumerator that iterates through the vector components. + public IEnumerator GetEnumerator() + { + yield return X; + yield return Y; + } + + /// Computes the dot product of this vector with another vector. + public T Dot(Vector2F other) => (X * other.X) + (Y * other.Y); + + /// Computes the dot product of two vectors. + public static T Dot(Vector2F left, Vector2F right) => (left.X * right.X) + (left.Y * right.Y); + + /// Computes the cross product of this vector with another vector. + public T Cross(Vector2F other) => (X * other.Y) - (Y * other.X); + + /// Computes the cross product of two vectors. + public static T Cross(Vector2F left, Vector2F right) => (left.X * right.Y) - (left.Y * right.X); + + /// Returns a span over the vector components. + public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 2); + + /// Normalizes this vector. + public Vector2F Normalize() + { + T length = Length; + return length != T.Zero ? this / length : Zero; + } + + /// Normalizes a vector. + public static Vector2F Normalize(Vector2F vector) + { + T length = vector.Length; + return length != T.Zero ? vector / length : Zero; + } + + /// Returns a vector with the component-wise maximum of this and another vector. + public Vector2F Max(Vector2F other) => + new(T.Max(X, other.X), T.Max(Y, other.Y)); + + /// Returns a vector with the component-wise maximum of two vectors. + public static Vector2F Max(Vector2F left, Vector2F right) => + new(T.Max(left.X, right.X), T.Max(left.Y, right.Y)); + + /// Returns a vector with the component-wise maximum of this vector and a scalar. + public Vector2F Max(T scalar) => + new(T.Max(X, scalar), T.Max(Y, scalar)); + + /// Returns a vector with the component-wise maximum of a vector and a scalar. + public static Vector2F Max(Vector2F vector, T scalar) => + new(T.Max(vector.X, scalar), T.Max(vector.Y, scalar)); + + /// Returns a vector with the component-wise minimum of this and another vector. + public Vector2F Min(Vector2F other) => + new(T.Min(X, other.X), T.Min(Y, other.Y)); + + /// Returns a vector with the component-wise minimum of two vectors. + public static Vector2F Min(Vector2F left, Vector2F right) => + new(T.Min(left.X, right.X), T.Min(left.Y, right.Y)); + + /// Returns a vector with the component-wise minimum of this vector and a scalar. + public Vector2F Min(T scalar) => + new(T.Min(X, scalar), T.Min(Y, scalar)); + + /// Returns a vector with the component-wise minimum of a vector and a scalar. + public static Vector2F Min(Vector2F vector, T scalar) => + new(T.Min(vector.X, scalar), T.Min(vector.Y, scalar)); + + /// Clamps this vector's components between the corresponding Min and Max vectors. + public Vector2F Clamp(Vector2F min, Vector2F max) => + new(T.Clamp(X, min.X, max.X), T.Clamp(Y, min.Y, max.Y)); + + /// Clamps the components of a vector between the corresponding Min and Max vectors. + public static Vector2F Clamp(Vector2F vector, Vector2F min, Vector2F max) => + new(T.Clamp(vector.X, min.X, max.X), T.Clamp(vector.Y, min.Y, max.Y)); + + /// Clamps this vector's components between the Min and Max scalar values. + public Vector2F Clamp(T min, T max) => + new(T.Clamp(X, min, max), T.Clamp(Y, min, max)); + + /// Clamps the components of a vector between the Min and Max scalar values. + public static Vector2F Clamp(Vector2F vector, T min, T max) => + new(T.Clamp(vector.X, min, max), T.Clamp(vector.Y, min, max)); + + /// Returns a vector with the absolute value of each component of this vector. + public Vector2F Abs() => new(T.Abs(X), T.Abs(Y)); + + /// Returns a vector with the absolute value of each component of the specified vector. + public static Vector2F Abs(Vector2F vector) => + new(T.Abs(vector.X), T.Abs(vector.Y)); + + /// Linearly interpolates between two vectors using a scalar t-value. + public static Vector2F Lerp(Vector2F a, Vector2F b, T t) => + new(a.X + (b.X - a.X) * t, a.Y + (b.Y - a.Y) * t); + + /// Linearly interpolates between two vectors using a vector t-value. + public static Vector2F Lerp(Vector2F a, Vector2F b, Vector2F t) => + new(a.X + (b.X - a.X) * t.X, a.Y + (b.Y - a.Y) * t.Y); + + /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). + public static Vector2F LerpClamped(Vector2F a, Vector2F b, T t) => + Lerp(a, b, T.Clamp(t, T.Zero, T.One)); + + /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). + public static Vector2F LerpClamped(Vector2F a, Vector2F b, Vector2F t) => + new( + a.X + (b.X - a.X) * T.Clamp(t.X, T.Zero, T.One), + a.Y + (b.Y - a.Y) * T.Clamp(t.Y, T.Zero, T.One) + ); + + /// Reflects a vector over a normal vector. + public Vector2F Reflect(Vector2F normal) + { + T dot = Dot(normal); + return this - (normal * (dot + dot)); + } + + /// Reflects a vector over a normal vector. + public static Vector2F Reflect(Vector2F vector, Vector2F normal) + { + T dot = Dot(vector, normal); + return vector - (normal * (dot + dot)); + } + + /// Formats the vector as a string using the specified format and format provider. + public string ToString(string? format, IFormatProvider? formatProvider) => $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}>"; + + /// Formats the vector as a string. + public override string ToString() => $"<{X}, {Y}>"; + + /// Formats the vector as a string using the specified format and format provider. + public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider)) + { + charsWritten = 0; + return false; + } + + int requiredLength = 1 + xChars + 2 + yChars + 1; + + if (destination.Length < requiredLength) + { + charsWritten = 0; + return false; + } + + int pos = 0; + destination[pos++] = '<'; + + xBuffer[..xChars].CopyTo(destination[pos..]); + pos += xChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + yBuffer[..yChars].CopyTo(destination[pos..]); + pos += yChars; + + destination[pos++] = '>'; + + charsWritten = pos; + return true; + } + + /// Parses a span to a instance. + public static Vector2F Parse(ReadOnlySpan s, IFormatProvider? provider) + { + if (!TryParse(s, provider, out var result)) + throw new FormatException("Invalid format for Vector2F."); + + return result; + } + + /// Copies the components of the vector to the specified array starting at index 0. + public void CopyTo(T[] array) => CopyTo(array, 0); + + /// Copies the components of the vector to the specified array starting at the given index. + public void CopyTo(T[] array, int startIndex) + { + if (array == null) + throw new ArgumentNullException(nameof(array)); + if (startIndex < 0 || startIndex + 2 > array.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + array[startIndex] = X; + array[startIndex + 1] = Y; + } + + /// Copies the components of the vector to the specified span starting at index 0. + public void CopyTo(Span span) => CopyTo(span, 0); + + /// Copies the components of the vector to the specified span starting at the given index. + public void CopyTo(Span span, int startIndex) + { + if (startIndex < 0 || startIndex + 2 > span.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + span[startIndex] = X; + span[startIndex + 1] = Y; + } + + /// Returns a vector where each component is the sign of the original vector's component. + public Vector2F Sign() => new(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y))); + + /// Returns a vector where each component is the sign of the input vector's component. + public static Vector2F Sign(Vector2F vector) => + new(T.CreateChecked(T.Sign(vector.X)), T.CreateChecked(T.Sign(vector.Y))); + + /// Copies the sign of each component from another vector to this vector's components. + public Vector2F CopySign(Vector2F signSource) => + new(T.CopySign(X, signSource.X), T.CopySign(Y, signSource.Y)); + + /// Copies the sign of each component from another vector to a new vector. + public static Vector2F CopySign(Vector2F value, Vector2F signSource) => + new(T.CopySign(value.X, signSource.X), T.CopySign(value.Y, signSource.Y)); + + /// Copies the sign of a scalar onto each component of this vector. + public Vector2F CopySign(T signScalar) => + new(T.CopySign(X, signScalar), T.CopySign(Y, signScalar)); + + /// Copies the sign of a scalar onto each component of a new vector. + public static Vector2F CopySign(Vector2F value, T signScalar) => + new(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar)); + + /// Parses a string to a instance. + public static Vector2F Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + + /// Tries to parse a span to a instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) + { + result = default; + + s = s.Trim(); + if (s.Length < 5 || s[0] != '<' || s[^1] != '>') + return false; + + s = s[1..^1]; // Remove < and > + + int commaIndex = s.IndexOf(','); + if (commaIndex < 0) + return false; + + ReadOnlySpan xSpan = s[..commaIndex].Trim(); + ReadOnlySpan ySpan = s[(commaIndex + 1)..].Trim(); + + if (T.TryParse(xSpan, provider, out var x) && + T.TryParse(ySpan, provider, out var y)) + { + result = new Vector2F(x, y); + return true; + } + + return false; + } + + /// Tries to parse a string to a instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => + TryParse(s.AsSpan(), provider, out result); + + /// Parses a span to a instance. + static Vector2F ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + Parse(s, provider); + + /// Parses a string to a instance. + static Vector2F IParsable>.Parse(string s, IFormatProvider? provider) => + Parse(s, provider); + + /// Tries to parse a span to a instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => + TryParse(s, provider, out result); + + /// Tries to parse a string to a instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => + TryParse(s, provider, out result); + + /// Returns an enumerator that iterates through the vector components. + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// Formats the vector as a UTF-8 string using the specified format and format provider. + public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider)) + { + bytesWritten = 0; + return false; + } + + int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + + Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + + Encoding.UTF8.GetByteCount("<, >"); + + if (utf8Destination.Length < estimatedSize) + { + bytesWritten = 0; + return false; + } + + int totalBytes = 0; + + totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); + + bytesWritten = totalBytes; + return true; + } + + /// Parses a UTF-8 span to a instance. + public static Vector2F Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return Parse(charBuffer, provider); + } + + /// Tries to parse a UTF-8 span to a instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return TryParse(charBuffer, provider, out result); + } + + // Casts + + /// Explicitly casts a to a . + public static explicit operator Vector2F(System.Numerics.Vector2 v) => + new((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T))); + + /// Explicitly casts a to . + public static explicit operator System.Numerics.Vector2(Vector2F v) => + new(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); + + // Component Operators + public static Vector2F operator +(Vector2F left, Vector2F right) => + new(left.X + right.X, left.Y + right.Y); + + public static Vector2F operator -(Vector2F left, Vector2F right) => + new(left.X - right.X, left.Y - right.Y); + + public static Vector2F operator *(Vector2F left, Vector2F right) => + new(left.X * right.X, left.Y * right.Y); + + public static Vector2F operator /(Vector2F left, Vector2F right) => + new(left.X / right.X, left.Y / right.Y); + + public static Vector2F operator %(Vector2F left, Vector2F right) => + new(left.X % right.X, left.Y % right.Y); + + // Scalar Operators + public static Vector2F operator +(Vector2F vector, T scalar) => + new(vector.X + scalar, vector.Y + scalar); + + public static Vector2F operator -(Vector2F vector, T scalar) => + new(vector.X - scalar, vector.Y - scalar); + + public static Vector2F operator *(Vector2F vector, T scalar) => + new(vector.X * scalar, vector.Y * scalar); + + public static Vector2F operator /(Vector2F vector, T scalar) => + new(vector.X / scalar, vector.Y / scalar); + + public static Vector2F operator %(Vector2F vector, T scalar) => + new(vector.X % scalar, vector.Y % scalar); + + // + operator: returns the vector + public static Vector2F operator +(Vector2F vector) => vector; + + // - operator: returns the negated vector + public static Vector2F operator -(Vector2F vector) => + new(-vector.X, -vector.Y); + + // Equality Operators + public static bool operator ==(Vector2F left, Vector2F right) => + left.X == right.X && left.Y == right.Y; + + public static bool operator !=(Vector2F left, Vector2F right) => + left.X != right.X || left.Y != right.Y; + + // IBinaryFloatingPointIeee754 + public static Vector2F Sqrt(Vector2F x) => + new(T.Sqrt(x.X), T.Sqrt(x.Y)); + + public static Vector2F Acosh(Vector2F x) => + new(T.Acosh(x.X), T.Acosh(x.Y)); + + public static Vector2F Asinh(Vector2F x) => + new(T.Asinh(x.X), T.Asinh(x.Y)); + + public static Vector2F Atanh(Vector2F x) => + new(T.Atanh(x.X), T.Atanh(x.Y)); + + public static Vector2F Cosh(Vector2F x) => + new(T.Cosh(x.X), T.Cosh(x.Y)); + + public static Vector2F Sinh(Vector2F x) => + new(T.Sinh(x.X), T.Sinh(x.Y)); + + public static Vector2F Tanh(Vector2F x) => + new(T.Tanh(x.X), T.Tanh(x.Y)); + + public static Vector2F Acos(Vector2F x) => + new(T.Acos(x.X), T.Acos(x.Y)); + + public static Vector2F AcosPi(Vector2F x) => + new(T.AcosPi(x.X), T.AcosPi(x.Y)); + + public static Vector2F Asin(Vector2F x) => + new(T.Asin(x.X), T.Asin(x.Y)); + + public static Vector2F AsinPi(Vector2F x) => + new(T.AsinPi(x.X), T.AsinPi(x.Y)); + + public static Vector2F Atan(Vector2F x) => + new(T.Atan(x.X), T.Atan(x.Y)); + + public static Vector2F AtanPi(Vector2F x) => + new(T.AtanPi(x.X), T.AtanPi(x.Y)); + + public static Vector2F Cos(Vector2F x) => + new(T.Cos(x.X), T.Cos(x.Y)); + + public static Vector2F CosPi(Vector2F x) => + new(T.CosPi(x.X), T.CosPi(x.Y)); + + public static Vector2F Sin(Vector2F x) => + new(T.Sin(x.X), T.Sin(x.Y)); + + public static Vector2F SinPi(Vector2F x) => + new(T.SinPi(x.X), T.SinPi(x.Y)); + + public static Vector2F Tan(Vector2F x) => + new(T.Tan(x.X), T.Tan(x.Y)); + + public static Vector2F TanPi(Vector2F x) => + new(T.TanPi(x.X), T.TanPi(x.Y)); + + public static Vector2F DegreesToRadians(Vector2F degrees) => + new(T.DegreesToRadians(degrees.X), T.DegreesToRadians(degrees.Y)); + + public static Vector2F RadiansToDegrees(Vector2F radians) => + new(T.RadiansToDegrees(radians.X), T.RadiansToDegrees(radians.Y)); + + public static (Vector2F Sin, Vector2F Cos) SinCos(Vector2F x) => + (new(T.Sin(x.X), T.Sin(x.Y)), new(T.Cos(x.X), T.Cos(x.Y))); + + public static (Vector2F SinPi, Vector2F CosPi) SinCosPi(Vector2F x) => + (new(T.SinPi(x.X), T.SinPi(x.Y)), new(T.CosPi(x.X), T.CosPi(x.Y))); + + public static Vector2F Log(Vector2F x) => + new(T.Log(x.X), T.Log(x.Y)); + + public static Vector2F Log(Vector2F x, Vector2F newBase) => + new(T.Log(x.X, newBase.X), T.Log(x.Y, newBase.Y)); + + public static Vector2F Log(Vector2F x, T newBase) => + new(T.Log(x.X, newBase), T.Log(x.Y, newBase)); + + public static Vector2F LogP1(Vector2F x) => + new(T.LogP1(x.X), T.LogP1(x.Y)); + + // TODO: Static Log2 + + public static Vector2F Log2P1(Vector2F x) => + new(T.Log2P1(x.X), T.Log2P1(x.Y)); + + public static Vector2F Log10(Vector2F x) => + new(T.Log10(x.X), T.Log10(x.Y)); + + public static Vector2F Log10P1(Vector2F x) => + new(T.Log10P1(x.X), T.Log10P1(x.Y)); + + public static Vector2F Exp(Vector2F x) => + new(T.Exp(x.X), T.Exp(x.Y)); + + public static Vector2F ExpM1(Vector2F x) => + new(T.ExpM1(x.X), T.ExpM1(x.Y)); + + public static Vector2F Exp2(Vector2F x) => + new(T.Exp2(x.X), T.Exp2(x.Y)); + + public static Vector2F Exp2M1(Vector2F x) => + new(T.Exp2M1(x.X), T.Exp2M1(x.Y)); + + public static Vector2F Exp10(Vector2F x) => + new(T.Exp10(x.X), T.Exp10(x.Y)); + + public static Vector2F Exp10M1(Vector2F x) => + new(T.Exp10M1(x.X), T.Exp10M1(x.Y)); + + public static Vector2F Pow(Vector2F x, Vector2F y) => + new(T.Pow(x.X, y.X), T.Pow(x.Y, y.Y)); + + public static Vector2F Pow(Vector2F x, T y) => + new(T.Pow(x.X, y), T.Pow(x.Y, y)); + + public static Vector2F Cbrt(Vector2F x) => + new(T.Cbrt(x.X), T.Cbrt(x.Y)); + + public static Vector2F Hypot(Vector2F x, Vector2F y) => + new(T.Hypot(x.X, y.X), T.Hypot(x.Y, y.Y)); + + public static Vector2F Hypot(Vector2F x, T y) => + new(T.Hypot(x.X, y), T.Hypot(x.Y, y)); + + public static Vector2F RootN(Vector2F x, int n) => + new(T.RootN(x.X, n), T.RootN(x.Y, n)); + + public static Vector2F Round(Vector2F x) => + new(T.Round(x.X), T.Round(x.Y)); + + public static Vector2F Round(Vector2F x, int digits) => + new(T.Round(x.X, digits), T.Round(x.Y, digits)); + + public static Vector2F Round(Vector2F x, MidpointRounding mode) => + new(T.Round(x.X, mode), T.Round(x.Y, mode)); + + public static Vector2F Round(Vector2F x, int digits, MidpointRounding mode) => + new(T.Round(x.X, digits, mode), T.Round(x.Y, digits, mode)); + + public static Vector2F Truncate(Vector2F x) => + new(T.Truncate(x.X), T.Truncate(x.Y)); + + public static Vector2F Atan2(Vector2F y, Vector2F x) => + new(T.Atan2(y.X, x.X), T.Atan2(y.Y, x.Y)); + + public static Vector2F Atan2Pi(Vector2F y, Vector2F x) => + new(T.Atan2Pi(y.X, x.X), T.Atan2Pi(y.Y, x.Y)); + + public static Vector2F Atan2(Vector2F y, T x) => + new(T.Atan2(y.X, x), T.Atan2(y.Y, x)); + + public static Vector2F Atan2Pi(Vector2F y, T x) => + new(T.Atan2Pi(y.X, x), T.Atan2Pi(y.Y, x)); + + public static Vector2F BitDecrement(Vector2F x) => + new(T.BitDecrement(x.X), T.BitDecrement(x.Y)); + + public static Vector2F BitIncrement(Vector2F x) => + new(T.BitIncrement(x.X), T.BitIncrement(x.Y)); + + public static Vector2F FusedMultiplyAdd(Vector2F left, Vector2F right, Vector2F addend) => + new(T.FusedMultiplyAdd(left.X, right.X, addend.X), T.FusedMultiplyAdd(left.Y, right.Y, addend.Y)); + + public static Vector2F FusedMultiplyAdd(Vector2F left, Vector2F right, T addend) => + new(T.FusedMultiplyAdd(left.X, right.X, addend), T.FusedMultiplyAdd(left.Y, right.Y, addend)); + + public static Vector2F FusedMultiplyAdd(Vector2F left, T right, Vector2F addend) => + new(T.FusedMultiplyAdd(left.X, right, addend.X), T.FusedMultiplyAdd(left.Y, right, addend.Y)); + + public static Vector2F FusedMultiplyAdd(Vector2F left, T right, T addend) => + new(T.FusedMultiplyAdd(left.X, right, addend), T.FusedMultiplyAdd(left.Y, right, addend)); + + public static Vector2F ReciprocalEstimate(Vector2F x) => + new(T.ReciprocalEstimate(x.X), T.ReciprocalEstimate(x.Y)); + + public static Vector2F ReciprocalSqrtEstimate(Vector2F x) => + new(T.ReciprocalSqrtEstimate(x.X), T.ReciprocalSqrtEstimate(x.Y)); + + public static Vector2I ILogB(Vector2F x) => + new(T.ILogB(x.X), T.ILogB(x.Y)); + + public static Vector2F ScaleB(Vector2F x, Vector2I n) => + new(T.ScaleB(x.X, n.X), T.ScaleB(x.Y, n.Y)); + + public static Vector2F ScaleB(Vector2F x, int n) => + new(T.ScaleB(x.X, n), T.ScaleB(x.Y, n)); + } +} From 191de4e7a3ddbdd652190498e1df6b934435d580 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Fri, 30 May 2025 10:13:09 -0700 Subject: [PATCH 15/67] Include generated code. --- sources/Maths/Maths/Matrix2x2F.gen.cs | 21 ++++++++++++++ sources/Maths/Maths/Matrix2x2I.gen.cs | 21 ++++++++++++++ sources/Maths/Maths/Matrix2x3F.gen.cs | 23 +++++++++++++++ sources/Maths/Maths/Matrix2x3I.gen.cs | 23 +++++++++++++++ sources/Maths/Maths/Matrix2x4F.gen.cs | 25 +++++++++++++++++ sources/Maths/Maths/Matrix2x4I.gen.cs | 25 +++++++++++++++++ sources/Maths/Maths/Matrix3x2F.gen.cs | 24 ++++++++++++++++ sources/Maths/Maths/Matrix3x2I.gen.cs | 24 ++++++++++++++++ sources/Maths/Maths/Matrix3x3F.gen.cs | 27 ++++++++++++++++++ sources/Maths/Maths/Matrix3x3I.gen.cs | 27 ++++++++++++++++++ sources/Maths/Maths/Matrix3x4F.gen.cs | 30 ++++++++++++++++++++ sources/Maths/Maths/Matrix3x4I.gen.cs | 30 ++++++++++++++++++++ sources/Maths/Maths/Matrix4x2F.gen.cs | 27 ++++++++++++++++++ sources/Maths/Maths/Matrix4x2I.gen.cs | 27 ++++++++++++++++++ sources/Maths/Maths/Matrix4x3F.gen.cs | 31 +++++++++++++++++++++ sources/Maths/Maths/Matrix4x3I.gen.cs | 31 +++++++++++++++++++++ sources/Maths/Maths/Matrix4x4F.gen.cs | 35 +++++++++++++++++++++++ sources/Maths/Maths/Matrix4x4I.gen.cs | 35 +++++++++++++++++++++++ sources/Maths/Maths/Matrix5x4F.gen.cs | 40 +++++++++++++++++++++++++++ sources/Maths/Maths/Matrix5x4I.gen.cs | 40 +++++++++++++++++++++++++++ sources/Maths/Maths/Vector2F.cs | 2 +- sources/Maths/Maths/Vector3F.gen.cs | 18 ++++++++++++ sources/Maths/Maths/Vector4F.gen.cs | 19 +++++++++++++ 23 files changed, 604 insertions(+), 1 deletion(-) create mode 100644 sources/Maths/Maths/Matrix2x2F.gen.cs create mode 100644 sources/Maths/Maths/Matrix2x2I.gen.cs create mode 100644 sources/Maths/Maths/Matrix2x3F.gen.cs create mode 100644 sources/Maths/Maths/Matrix2x3I.gen.cs create mode 100644 sources/Maths/Maths/Matrix2x4F.gen.cs create mode 100644 sources/Maths/Maths/Matrix2x4I.gen.cs create mode 100644 sources/Maths/Maths/Matrix3x2F.gen.cs create mode 100644 sources/Maths/Maths/Matrix3x2I.gen.cs create mode 100644 sources/Maths/Maths/Matrix3x3F.gen.cs create mode 100644 sources/Maths/Maths/Matrix3x3I.gen.cs create mode 100644 sources/Maths/Maths/Matrix3x4F.gen.cs create mode 100644 sources/Maths/Maths/Matrix3x4I.gen.cs create mode 100644 sources/Maths/Maths/Matrix4x2F.gen.cs create mode 100644 sources/Maths/Maths/Matrix4x2I.gen.cs create mode 100644 sources/Maths/Maths/Matrix4x3F.gen.cs create mode 100644 sources/Maths/Maths/Matrix4x3I.gen.cs create mode 100644 sources/Maths/Maths/Matrix4x4F.gen.cs create mode 100644 sources/Maths/Maths/Matrix4x4I.gen.cs create mode 100644 sources/Maths/Maths/Matrix5x4F.gen.cs create mode 100644 sources/Maths/Maths/Matrix5x4I.gen.cs create mode 100644 sources/Maths/Maths/Vector3F.gen.cs create mode 100644 sources/Maths/Maths/Vector4F.gen.cs diff --git a/sources/Maths/Maths/Matrix2x2F.gen.cs b/sources/Maths/Maths/Matrix2x2F.gen.cs new file mode 100644 index 0000000000..a4fe3486d6 --- /dev/null +++ b/sources/Maths/Maths/Matrix2x2F.gen.cs @@ -0,0 +1,21 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix2x2F : IEquatable> where T : IFloatingPointIeee754 + { + public Vector2F Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public Vector2F Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public static bool operator ==(Matrix2x2F left, Matrix2x2F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + public static bool operator !=(Matrix2x2F left, Matrix2x2F right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix2x2F other && Equals(other); + /// + public bool Equals(Matrix2x2F other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x2I.gen.cs b/sources/Maths/Maths/Matrix2x2I.gen.cs new file mode 100644 index 0000000000..abb70ef018 --- /dev/null +++ b/sources/Maths/Maths/Matrix2x2I.gen.cs @@ -0,0 +1,21 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix2x2I : IEquatable> where T : IBinaryInteger + { + public Vector2I Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public Vector2I Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public static bool operator ==(Matrix2x2I left, Matrix2x2I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + public static bool operator !=(Matrix2x2I left, Matrix2x2I right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix2x2I other && Equals(other); + /// + public bool Equals(Matrix2x2I other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x3F.gen.cs b/sources/Maths/Maths/Matrix2x3F.gen.cs new file mode 100644 index 0000000000..2d160ff92f --- /dev/null +++ b/sources/Maths/Maths/Matrix2x3F.gen.cs @@ -0,0 +1,23 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix2x3F : IEquatable> where T : IFloatingPointIeee754 + { + public Vector3F Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public Vector3F Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public static bool operator ==(Matrix2x3F left, Matrix2x3F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + public static bool operator !=(Matrix2x3F left, Matrix2x3F right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix2x3F other && Equals(other); + /// + public bool Equals(Matrix2x3F other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x3I.gen.cs b/sources/Maths/Maths/Matrix2x3I.gen.cs new file mode 100644 index 0000000000..a08cb80e05 --- /dev/null +++ b/sources/Maths/Maths/Matrix2x3I.gen.cs @@ -0,0 +1,23 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix2x3I : IEquatable> where T : IBinaryInteger + { + public Vector3I Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public Vector3I Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public static bool operator ==(Matrix2x3I left, Matrix2x3I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + public static bool operator !=(Matrix2x3I left, Matrix2x3I right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix2x3I other && Equals(other); + /// + public bool Equals(Matrix2x3I other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x4F.gen.cs b/sources/Maths/Maths/Matrix2x4F.gen.cs new file mode 100644 index 0000000000..be4bcd7a7c --- /dev/null +++ b/sources/Maths/Maths/Matrix2x4F.gen.cs @@ -0,0 +1,25 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix2x4F : IEquatable> where T : IFloatingPointIeee754 + { + public Vector4F Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public T M14 => Row1.W; + public Vector4F Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public T M24 => Row2.W; + public static bool operator ==(Matrix2x4F left, Matrix2x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + public static bool operator !=(Matrix2x4F left, Matrix2x4F right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix2x4F other && Equals(other); + /// + public bool Equals(Matrix2x4F other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x4I.gen.cs b/sources/Maths/Maths/Matrix2x4I.gen.cs new file mode 100644 index 0000000000..957ed5cd97 --- /dev/null +++ b/sources/Maths/Maths/Matrix2x4I.gen.cs @@ -0,0 +1,25 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix2x4I : IEquatable> where T : IBinaryInteger + { + public Vector4I Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public T M14 => Row1.W; + public Vector4I Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public T M24 => Row2.W; + public static bool operator ==(Matrix2x4I left, Matrix2x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + public static bool operator !=(Matrix2x4I left, Matrix2x4I right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix2x4I other && Equals(other); + /// + public bool Equals(Matrix2x4I other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x2F.gen.cs b/sources/Maths/Maths/Matrix3x2F.gen.cs new file mode 100644 index 0000000000..a742b8ac7a --- /dev/null +++ b/sources/Maths/Maths/Matrix3x2F.gen.cs @@ -0,0 +1,24 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix3x2F : IEquatable> where T : IFloatingPointIeee754 + { + public Vector2F Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public Vector2F Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public Vector2F Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public static bool operator ==(Matrix3x2F left, Matrix3x2F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + public static bool operator !=(Matrix3x2F left, Matrix3x2F right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix3x2F other && Equals(other); + /// + public bool Equals(Matrix3x2F other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x2I.gen.cs b/sources/Maths/Maths/Matrix3x2I.gen.cs new file mode 100644 index 0000000000..ea91c2b17c --- /dev/null +++ b/sources/Maths/Maths/Matrix3x2I.gen.cs @@ -0,0 +1,24 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix3x2I : IEquatable> where T : IBinaryInteger + { + public Vector2I Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public Vector2I Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public Vector2I Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public static bool operator ==(Matrix3x2I left, Matrix3x2I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + public static bool operator !=(Matrix3x2I left, Matrix3x2I right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix3x2I other && Equals(other); + /// + public bool Equals(Matrix3x2I other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x3F.gen.cs b/sources/Maths/Maths/Matrix3x3F.gen.cs new file mode 100644 index 0000000000..4e99f7eeec --- /dev/null +++ b/sources/Maths/Maths/Matrix3x3F.gen.cs @@ -0,0 +1,27 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix3x3F : IEquatable> where T : IFloatingPointIeee754 + { + public Vector3F Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public Vector3F Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public Vector3F Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public T M33 => Row3.Z; + public static bool operator ==(Matrix3x3F left, Matrix3x3F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + public static bool operator !=(Matrix3x3F left, Matrix3x3F right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix3x3F other && Equals(other); + /// + public bool Equals(Matrix3x3F other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x3I.gen.cs b/sources/Maths/Maths/Matrix3x3I.gen.cs new file mode 100644 index 0000000000..f87f11633a --- /dev/null +++ b/sources/Maths/Maths/Matrix3x3I.gen.cs @@ -0,0 +1,27 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix3x3I : IEquatable> where T : IBinaryInteger + { + public Vector3I Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public Vector3I Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public Vector3I Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public T M33 => Row3.Z; + public static bool operator ==(Matrix3x3I left, Matrix3x3I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + public static bool operator !=(Matrix3x3I left, Matrix3x3I right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix3x3I other && Equals(other); + /// + public bool Equals(Matrix3x3I other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x4F.gen.cs b/sources/Maths/Maths/Matrix3x4F.gen.cs new file mode 100644 index 0000000000..7cadcea5e4 --- /dev/null +++ b/sources/Maths/Maths/Matrix3x4F.gen.cs @@ -0,0 +1,30 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix3x4F : IEquatable> where T : IFloatingPointIeee754 + { + public Vector4F Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public T M14 => Row1.W; + public Vector4F Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public T M24 => Row2.W; + public Vector4F Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public T M33 => Row3.Z; + public T M34 => Row3.W; + public static bool operator ==(Matrix3x4F left, Matrix3x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + public static bool operator !=(Matrix3x4F left, Matrix3x4F right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix3x4F other && Equals(other); + /// + public bool Equals(Matrix3x4F other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x4I.gen.cs b/sources/Maths/Maths/Matrix3x4I.gen.cs new file mode 100644 index 0000000000..531d3ce4b8 --- /dev/null +++ b/sources/Maths/Maths/Matrix3x4I.gen.cs @@ -0,0 +1,30 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix3x4I : IEquatable> where T : IBinaryInteger + { + public Vector4I Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public T M14 => Row1.W; + public Vector4I Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public T M24 => Row2.W; + public Vector4I Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public T M33 => Row3.Z; + public T M34 => Row3.W; + public static bool operator ==(Matrix3x4I left, Matrix3x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + public static bool operator !=(Matrix3x4I left, Matrix3x4I right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix3x4I other && Equals(other); + /// + public bool Equals(Matrix3x4I other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x2F.gen.cs b/sources/Maths/Maths/Matrix4x2F.gen.cs new file mode 100644 index 0000000000..69b77a8983 --- /dev/null +++ b/sources/Maths/Maths/Matrix4x2F.gen.cs @@ -0,0 +1,27 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix4x2F : IEquatable> where T : IFloatingPointIeee754 + { + public Vector2F Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public Vector2F Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public Vector2F Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public Vector2F Row4; + public T M41 => Row4.X; + public T M42 => Row4.Y; + public static bool operator ==(Matrix4x2F left, Matrix4x2F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + public static bool operator !=(Matrix4x2F left, Matrix4x2F right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix4x2F other && Equals(other); + /// + public bool Equals(Matrix4x2F other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x2I.gen.cs b/sources/Maths/Maths/Matrix4x2I.gen.cs new file mode 100644 index 0000000000..009132e9a9 --- /dev/null +++ b/sources/Maths/Maths/Matrix4x2I.gen.cs @@ -0,0 +1,27 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix4x2I : IEquatable> where T : IBinaryInteger + { + public Vector2I Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public Vector2I Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public Vector2I Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public Vector2I Row4; + public T M41 => Row4.X; + public T M42 => Row4.Y; + public static bool operator ==(Matrix4x2I left, Matrix4x2I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + public static bool operator !=(Matrix4x2I left, Matrix4x2I right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix4x2I other && Equals(other); + /// + public bool Equals(Matrix4x2I other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x3F.gen.cs b/sources/Maths/Maths/Matrix4x3F.gen.cs new file mode 100644 index 0000000000..45645b08b7 --- /dev/null +++ b/sources/Maths/Maths/Matrix4x3F.gen.cs @@ -0,0 +1,31 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix4x3F : IEquatable> where T : IFloatingPointIeee754 + { + public Vector3F Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public Vector3F Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public Vector3F Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public T M33 => Row3.Z; + public Vector3F Row4; + public T M41 => Row4.X; + public T M42 => Row4.Y; + public T M43 => Row4.Z; + public static bool operator ==(Matrix4x3F left, Matrix4x3F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + public static bool operator !=(Matrix4x3F left, Matrix4x3F right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix4x3F other && Equals(other); + /// + public bool Equals(Matrix4x3F other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x3I.gen.cs b/sources/Maths/Maths/Matrix4x3I.gen.cs new file mode 100644 index 0000000000..3dd56f6000 --- /dev/null +++ b/sources/Maths/Maths/Matrix4x3I.gen.cs @@ -0,0 +1,31 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix4x3I : IEquatable> where T : IBinaryInteger + { + public Vector3I Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public Vector3I Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public Vector3I Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public T M33 => Row3.Z; + public Vector3I Row4; + public T M41 => Row4.X; + public T M42 => Row4.Y; + public T M43 => Row4.Z; + public static bool operator ==(Matrix4x3I left, Matrix4x3I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + public static bool operator !=(Matrix4x3I left, Matrix4x3I right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix4x3I other && Equals(other); + /// + public bool Equals(Matrix4x3I other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x4F.gen.cs b/sources/Maths/Maths/Matrix4x4F.gen.cs new file mode 100644 index 0000000000..83804511cc --- /dev/null +++ b/sources/Maths/Maths/Matrix4x4F.gen.cs @@ -0,0 +1,35 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix4x4F : IEquatable> where T : IFloatingPointIeee754 + { + public Vector4F Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public T M14 => Row1.W; + public Vector4F Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public T M24 => Row2.W; + public Vector4F Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public T M33 => Row3.Z; + public T M34 => Row3.W; + public Vector4F Row4; + public T M41 => Row4.X; + public T M42 => Row4.Y; + public T M43 => Row4.Z; + public T M44 => Row4.W; + public static bool operator ==(Matrix4x4F left, Matrix4x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + public static bool operator !=(Matrix4x4F left, Matrix4x4F right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix4x4F other && Equals(other); + /// + public bool Equals(Matrix4x4F other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x4I.gen.cs b/sources/Maths/Maths/Matrix4x4I.gen.cs new file mode 100644 index 0000000000..a49923923a --- /dev/null +++ b/sources/Maths/Maths/Matrix4x4I.gen.cs @@ -0,0 +1,35 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix4x4I : IEquatable> where T : IBinaryInteger + { + public Vector4I Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public T M14 => Row1.W; + public Vector4I Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public T M24 => Row2.W; + public Vector4I Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public T M33 => Row3.Z; + public T M34 => Row3.W; + public Vector4I Row4; + public T M41 => Row4.X; + public T M42 => Row4.Y; + public T M43 => Row4.Z; + public T M44 => Row4.W; + public static bool operator ==(Matrix4x4I left, Matrix4x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + public static bool operator !=(Matrix4x4I left, Matrix4x4I right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix4x4I other && Equals(other); + /// + public bool Equals(Matrix4x4I other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix5x4F.gen.cs b/sources/Maths/Maths/Matrix5x4F.gen.cs new file mode 100644 index 0000000000..5b1b50135f --- /dev/null +++ b/sources/Maths/Maths/Matrix5x4F.gen.cs @@ -0,0 +1,40 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix5x4F : IEquatable> where T : IFloatingPointIeee754 + { + public Vector4F Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public T M14 => Row1.W; + public Vector4F Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public T M24 => Row2.W; + public Vector4F Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public T M33 => Row3.Z; + public T M34 => Row3.W; + public Vector4F Row4; + public T M41 => Row4.X; + public T M42 => Row4.Y; + public T M43 => Row4.Z; + public T M44 => Row4.W; + public Vector4F Row5; + public T M51 => Row5.X; + public T M52 => Row5.Y; + public T M53 => Row5.Z; + public T M54 => Row5.W; + public static bool operator ==(Matrix5x4F left, Matrix5x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4 && left.Row5 == right.Row5; + public static bool operator !=(Matrix5x4F left, Matrix5x4F right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix5x4F other && Equals(other); + /// + public bool Equals(Matrix5x4F other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4, Row5); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix5x4I.gen.cs b/sources/Maths/Maths/Matrix5x4I.gen.cs new file mode 100644 index 0000000000..5a072ef187 --- /dev/null +++ b/sources/Maths/Maths/Matrix5x4I.gen.cs @@ -0,0 +1,40 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Matrix5x4I : IEquatable> where T : IBinaryInteger + { + public Vector4I Row1; + public T M11 => Row1.X; + public T M12 => Row1.Y; + public T M13 => Row1.Z; + public T M14 => Row1.W; + public Vector4I Row2; + public T M21 => Row2.X; + public T M22 => Row2.Y; + public T M23 => Row2.Z; + public T M24 => Row2.W; + public Vector4I Row3; + public T M31 => Row3.X; + public T M32 => Row3.Y; + public T M33 => Row3.Z; + public T M34 => Row3.W; + public Vector4I Row4; + public T M41 => Row4.X; + public T M42 => Row4.Y; + public T M43 => Row4.Z; + public T M44 => Row4.W; + public Vector4I Row5; + public T M51 => Row5.X; + public T M52 => Row5.Y; + public T M53 => Row5.Z; + public T M54 => Row5.W; + public static bool operator ==(Matrix5x4I left, Matrix5x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4 && left.Row5 == right.Row5; + public static bool operator !=(Matrix5x4I left, Matrix5x4I right) => !(left == right); + public override bool Equals(object? obj) => obj is Matrix5x4I other && Equals(other); + /// + public bool Equals(Matrix5x4I other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4, Row5); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Vector2F.cs b/sources/Maths/Maths/Vector2F.cs index 6f563ced9e..26d8c13047 100644 --- a/sources/Maths/Maths/Vector2F.cs +++ b/sources/Maths/Maths/Vector2F.cs @@ -23,7 +23,7 @@ internal struct Vector2F : IUtf8SpanParsable>, IParsable>, IFormattable - where T : IBinaryFloatingPointIeee754 + where T : IFloatingPointIeee754 { /// The X component of the vector. public T X; diff --git a/sources/Maths/Maths/Vector3F.gen.cs b/sources/Maths/Maths/Vector3F.gen.cs new file mode 100644 index 0000000000..e37480e2c7 --- /dev/null +++ b/sources/Maths/Maths/Vector3F.gen.cs @@ -0,0 +1,18 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Vector3F : IEquatable> where T : IFloatingPointIeee754 + { + public T X; + public T Y; + public T Z; + public static bool operator ==(Vector3F left, Vector3F right) => left.X == right.X && left.Y == right.Y && left.Z == right.Z; + public static bool operator !=(Vector3F left, Vector3F right) => !(left == right); + public override bool Equals(object? obj) => obj is Vector3F other && Equals(other); + /// + public bool Equals(Vector3F other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(X, Y, Z); + } +} \ No newline at end of file diff --git a/sources/Maths/Maths/Vector4F.gen.cs b/sources/Maths/Maths/Vector4F.gen.cs new file mode 100644 index 0000000000..77defbefa4 --- /dev/null +++ b/sources/Maths/Maths/Vector4F.gen.cs @@ -0,0 +1,19 @@ +namespace Silk.NET.Maths +{ + using System.Numerics; + + partial struct Vector4F : IEquatable> where T : IFloatingPointIeee754 + { + public T X; + public T Y; + public T Z; + public T W; + public static bool operator ==(Vector4F left, Vector4F right) => left.X == right.X && left.Y == right.Y && left.Z == right.Z && left.W == right.W; + public static bool operator !=(Vector4F left, Vector4F right) => !(left == right); + public override bool Equals(object? obj) => obj is Vector4F other && Equals(other); + /// + public bool Equals(Vector4F other) => this == other; + /// + public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); + } +} \ No newline at end of file From 291ec1ed53ac3abe57838cdccb91512c37b8d3fe Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Fri, 30 May 2025 16:43:18 -0700 Subject: [PATCH 16/67] Generated constructors, operators, and indexers. --- sources/Maths/Maths/Matrix2x2F.gen.cs | 55 ++++++++++++++- sources/Maths/Maths/Matrix2x2I.gen.cs | 55 ++++++++++++++- sources/Maths/Maths/Matrix2x3F.gen.cs | 62 ++++++++++++++++- sources/Maths/Maths/Matrix2x3I.gen.cs | 62 ++++++++++++++++- sources/Maths/Maths/Matrix2x4F.gen.cs | 69 ++++++++++++++++++- sources/Maths/Maths/Matrix2x4I.gen.cs | 69 ++++++++++++++++++- sources/Maths/Maths/Matrix3x2F.gen.cs | 67 ++++++++++++++++-- sources/Maths/Maths/Matrix3x2I.gen.cs | 67 ++++++++++++++++-- sources/Maths/Maths/Matrix3x3F.gen.cs | 75 +++++++++++++++++++-- sources/Maths/Maths/Matrix3x3I.gen.cs | 75 +++++++++++++++++++-- sources/Maths/Maths/Matrix3x4F.gen.cs | 83 +++++++++++++++++++++-- sources/Maths/Maths/Matrix3x4I.gen.cs | 83 +++++++++++++++++++++-- sources/Maths/Maths/Matrix4x2F.gen.cs | 79 ++++++++++++++++++++-- sources/Maths/Maths/Matrix4x2I.gen.cs | 79 ++++++++++++++++++++-- sources/Maths/Maths/Matrix4x3F.gen.cs | 88 ++++++++++++++++++++++-- sources/Maths/Maths/Matrix4x3I.gen.cs | 88 ++++++++++++++++++++++-- sources/Maths/Maths/Matrix4x4F.gen.cs | 97 +++++++++++++++++++++++++-- sources/Maths/Maths/Matrix4x4I.gen.cs | 97 +++++++++++++++++++++++++-- sources/Maths/Maths/Matrix5x4F.gen.cs | 86 ++++++++++++++++++++++-- sources/Maths/Maths/Matrix5x4I.gen.cs | 86 ++++++++++++++++++++++-- 20 files changed, 1438 insertions(+), 84 deletions(-) diff --git a/sources/Maths/Maths/Matrix2x2F.gen.cs b/sources/Maths/Maths/Matrix2x2F.gen.cs index a4fe3486d6..89adcc9f5f 100644 --- a/sources/Maths/Maths/Matrix2x2F.gen.cs +++ b/sources/Maths/Maths/Matrix2x2F.gen.cs @@ -1,21 +1,70 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix2x2F : IEquatable> where T : IFloatingPointIeee754 { + /// The 1st row of the matrix represented as a vector. public Vector2F Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector2F Row2; + public Matrix2x2F(Vector2F row1, Vector2F row2) => (Row1, Row2) = (row1, row2); + [UnscopedRef] + public ref Vector2F this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; - public Vector2F Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; - public static bool operator ==(Matrix2x2F left, Matrix2x2F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; - public static bool operator !=(Matrix2x2F left, Matrix2x2F right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix2x2F other && Equals(other); /// public bool Equals(Matrix2x2F other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix2x2F left, Matrix2x2F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix2x2F left, Matrix2x2F right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix2x2F operator +(Matrix2x2F left, Matrix2x2F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix2x2F operator -(Matrix2x2F left, Matrix2x2F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x2F operator *(Matrix2x2F left, Matrix2x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x2I.gen.cs b/sources/Maths/Maths/Matrix2x2I.gen.cs index abb70ef018..b821cef6e4 100644 --- a/sources/Maths/Maths/Matrix2x2I.gen.cs +++ b/sources/Maths/Maths/Matrix2x2I.gen.cs @@ -1,21 +1,70 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix2x2I : IEquatable> where T : IBinaryInteger { + /// The 1st row of the matrix represented as a vector. public Vector2I Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector2I Row2; + public Matrix2x2I(Vector2I row1, Vector2I row2) => (Row1, Row2) = (row1, row2); + [UnscopedRef] + public ref Vector2I this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; - public Vector2I Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; - public static bool operator ==(Matrix2x2I left, Matrix2x2I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; - public static bool operator !=(Matrix2x2I left, Matrix2x2I right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix2x2I other && Equals(other); /// public bool Equals(Matrix2x2I other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix2x2I left, Matrix2x2I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix2x2I left, Matrix2x2I right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix2x2I operator +(Matrix2x2I left, Matrix2x2I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix2x2I operator -(Matrix2x2I left, Matrix2x2I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x2I operator *(Matrix2x2I left, Matrix2x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x3F.gen.cs b/sources/Maths/Maths/Matrix2x3F.gen.cs index 2d160ff92f..1e29c07468 100644 --- a/sources/Maths/Maths/Matrix2x3F.gen.cs +++ b/sources/Maths/Maths/Matrix2x3F.gen.cs @@ -1,23 +1,79 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix2x3F : IEquatable> where T : IFloatingPointIeee754 { + /// The 1st row of the matrix represented as a vector. public Vector3F Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector3F Row2; + public Matrix2x3F(Vector3F row1, Vector3F row2) => (Row1, Row2) = (row1, row2); + [UnscopedRef] + public ref Vector3F this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; - public Vector3F Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; - public static bool operator ==(Matrix2x3F left, Matrix2x3F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; - public static bool operator !=(Matrix2x3F left, Matrix2x3F right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix2x3F other && Equals(other); /// public bool Equals(Matrix2x3F other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix2x3F left, Matrix2x3F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix2x3F left, Matrix2x3F right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix2x3F operator +(Matrix2x3F left, Matrix2x3F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix2x3F operator -(Matrix2x3F left, Matrix2x3F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x3F operator *(Matrix2x2F left, Matrix2x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x2F operator *(Matrix2x3F left, Matrix3x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x3I.gen.cs b/sources/Maths/Maths/Matrix2x3I.gen.cs index a08cb80e05..1552290f34 100644 --- a/sources/Maths/Maths/Matrix2x3I.gen.cs +++ b/sources/Maths/Maths/Matrix2x3I.gen.cs @@ -1,23 +1,79 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix2x3I : IEquatable> where T : IBinaryInteger { + /// The 1st row of the matrix represented as a vector. public Vector3I Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector3I Row2; + public Matrix2x3I(Vector3I row1, Vector3I row2) => (Row1, Row2) = (row1, row2); + [UnscopedRef] + public ref Vector3I this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; - public Vector3I Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; - public static bool operator ==(Matrix2x3I left, Matrix2x3I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; - public static bool operator !=(Matrix2x3I left, Matrix2x3I right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix2x3I other && Equals(other); /// public bool Equals(Matrix2x3I other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix2x3I left, Matrix2x3I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix2x3I left, Matrix2x3I right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix2x3I operator +(Matrix2x3I left, Matrix2x3I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix2x3I operator -(Matrix2x3I left, Matrix2x3I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x3I operator *(Matrix2x2I left, Matrix2x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x2I operator *(Matrix2x3I left, Matrix3x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x4F.gen.cs b/sources/Maths/Maths/Matrix2x4F.gen.cs index be4bcd7a7c..e8ae19335b 100644 --- a/sources/Maths/Maths/Matrix2x4F.gen.cs +++ b/sources/Maths/Maths/Matrix2x4F.gen.cs @@ -1,25 +1,88 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix2x4F : IEquatable> where T : IFloatingPointIeee754 { + /// The 1st row of the matrix represented as a vector. public Vector4F Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector4F Row2; + public Matrix2x4F(Vector4F row1, Vector4F row2) => (Row1, Row2) = (row1, row2); + [UnscopedRef] + public ref Vector4F this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; - public Vector4F Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; - public static bool operator ==(Matrix2x4F left, Matrix2x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; - public static bool operator !=(Matrix2x4F left, Matrix2x4F right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix2x4F other && Equals(other); /// public bool Equals(Matrix2x4F other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix2x4F left, Matrix2x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix2x4F left, Matrix2x4F right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix2x4F operator +(Matrix2x4F left, Matrix2x4F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix2x4F operator -(Matrix2x4F left, Matrix2x4F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x4F operator *(Matrix2x2F left, Matrix2x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x2F operator *(Matrix2x4F left, Matrix4x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x4F operator *(Matrix3x2F left, Matrix2x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x4I.gen.cs b/sources/Maths/Maths/Matrix2x4I.gen.cs index 957ed5cd97..00d2a60fd7 100644 --- a/sources/Maths/Maths/Matrix2x4I.gen.cs +++ b/sources/Maths/Maths/Matrix2x4I.gen.cs @@ -1,25 +1,88 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix2x4I : IEquatable> where T : IBinaryInteger { + /// The 1st row of the matrix represented as a vector. public Vector4I Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector4I Row2; + public Matrix2x4I(Vector4I row1, Vector4I row2) => (Row1, Row2) = (row1, row2); + [UnscopedRef] + public ref Vector4I this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; - public Vector4I Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; - public static bool operator ==(Matrix2x4I left, Matrix2x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; - public static bool operator !=(Matrix2x4I left, Matrix2x4I right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix2x4I other && Equals(other); /// public bool Equals(Matrix2x4I other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix2x4I left, Matrix2x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix2x4I left, Matrix2x4I right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix2x4I operator +(Matrix2x4I left, Matrix2x4I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix2x4I operator -(Matrix2x4I left, Matrix2x4I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x4I operator *(Matrix2x2I left, Matrix2x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x2I operator *(Matrix2x4I left, Matrix4x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x4I operator *(Matrix3x2I left, Matrix2x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x2F.gen.cs b/sources/Maths/Maths/Matrix3x2F.gen.cs index a742b8ac7a..d3b9d23ca9 100644 --- a/sources/Maths/Maths/Matrix3x2F.gen.cs +++ b/sources/Maths/Maths/Matrix3x2F.gen.cs @@ -1,24 +1,83 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix3x2F : IEquatable> where T : IFloatingPointIeee754 { + /// The 1st row of the matrix represented as a vector. public Vector2F Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector2F Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector2F Row3; + public Matrix3x2F(Vector2F row1, Vector2F row2, Vector2F row3) => (Row1, Row2, Row3) = (row1, row2, row3); + [UnscopedRef] + public ref Vector2F this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; - public Vector2F Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; - public Vector2F Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; - public static bool operator ==(Matrix3x2F left, Matrix3x2F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; - public static bool operator !=(Matrix3x2F left, Matrix3x2F right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix3x2F other && Equals(other); /// public bool Equals(Matrix3x2F other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix3x2F left, Matrix3x2F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix3x2F left, Matrix3x2F right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix3x2F operator +(Matrix3x2F left, Matrix3x2F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix3x2F operator -(Matrix3x2F left, Matrix3x2F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x2F operator *(Matrix3x2F left, Matrix2x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x3F operator *(Matrix3x2F left, Matrix2x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x2I.gen.cs b/sources/Maths/Maths/Matrix3x2I.gen.cs index ea91c2b17c..ff42a87479 100644 --- a/sources/Maths/Maths/Matrix3x2I.gen.cs +++ b/sources/Maths/Maths/Matrix3x2I.gen.cs @@ -1,24 +1,83 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix3x2I : IEquatable> where T : IBinaryInteger { + /// The 1st row of the matrix represented as a vector. public Vector2I Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector2I Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector2I Row3; + public Matrix3x2I(Vector2I row1, Vector2I row2, Vector2I row3) => (Row1, Row2, Row3) = (row1, row2, row3); + [UnscopedRef] + public ref Vector2I this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; - public Vector2I Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; - public Vector2I Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; - public static bool operator ==(Matrix3x2I left, Matrix3x2I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; - public static bool operator !=(Matrix3x2I left, Matrix3x2I right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix3x2I other && Equals(other); /// public bool Equals(Matrix3x2I other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix3x2I left, Matrix3x2I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix3x2I left, Matrix3x2I right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix3x2I operator +(Matrix3x2I left, Matrix3x2I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix3x2I operator -(Matrix3x2I left, Matrix3x2I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x2I operator *(Matrix3x2I left, Matrix2x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x3I operator *(Matrix3x2I left, Matrix2x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x3F.gen.cs b/sources/Maths/Maths/Matrix3x3F.gen.cs index 4e99f7eeec..5e58784ba3 100644 --- a/sources/Maths/Maths/Matrix3x3F.gen.cs +++ b/sources/Maths/Maths/Matrix3x3F.gen.cs @@ -1,27 +1,94 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix3x3F : IEquatable> where T : IFloatingPointIeee754 { + /// The 1st row of the matrix represented as a vector. public Vector3F Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector3F Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector3F Row3; + public Matrix3x3F(Vector3F row1, Vector3F row2, Vector3F row3) => (Row1, Row2, Row3) = (row1, row2, row3); + [UnscopedRef] + public ref Vector3F this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; - public Vector3F Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; - public Vector3F Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; - public static bool operator ==(Matrix3x3F left, Matrix3x3F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; - public static bool operator !=(Matrix3x3F left, Matrix3x3F right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix3x3F other && Equals(other); /// public bool Equals(Matrix3x3F other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix3x3F left, Matrix3x3F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix3x3F left, Matrix3x3F right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix3x3F operator +(Matrix3x3F left, Matrix3x3F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix3x3F operator -(Matrix3x3F left, Matrix3x3F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x3F operator *(Matrix2x3F left, Matrix3x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x2F operator *(Matrix3x3F left, Matrix3x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x3F operator *(Matrix3x3F left, Matrix3x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x3I.gen.cs b/sources/Maths/Maths/Matrix3x3I.gen.cs index f87f11633a..51c31bf28f 100644 --- a/sources/Maths/Maths/Matrix3x3I.gen.cs +++ b/sources/Maths/Maths/Matrix3x3I.gen.cs @@ -1,27 +1,94 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix3x3I : IEquatable> where T : IBinaryInteger { + /// The 1st row of the matrix represented as a vector. public Vector3I Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector3I Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector3I Row3; + public Matrix3x3I(Vector3I row1, Vector3I row2, Vector3I row3) => (Row1, Row2, Row3) = (row1, row2, row3); + [UnscopedRef] + public ref Vector3I this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; - public Vector3I Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; - public Vector3I Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; - public static bool operator ==(Matrix3x3I left, Matrix3x3I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; - public static bool operator !=(Matrix3x3I left, Matrix3x3I right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix3x3I other && Equals(other); /// public bool Equals(Matrix3x3I other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix3x3I left, Matrix3x3I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix3x3I left, Matrix3x3I right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix3x3I operator +(Matrix3x3I left, Matrix3x3I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix3x3I operator -(Matrix3x3I left, Matrix3x3I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x3I operator *(Matrix2x3I left, Matrix3x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x2I operator *(Matrix3x3I left, Matrix3x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x3I operator *(Matrix3x3I left, Matrix3x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x4F.gen.cs b/sources/Maths/Maths/Matrix3x4F.gen.cs index 7cadcea5e4..1f0333ebdb 100644 --- a/sources/Maths/Maths/Matrix3x4F.gen.cs +++ b/sources/Maths/Maths/Matrix3x4F.gen.cs @@ -1,30 +1,105 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix3x4F : IEquatable> where T : IFloatingPointIeee754 { + /// The 1st row of the matrix represented as a vector. public Vector4F Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector4F Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector4F Row3; + public Matrix3x4F(Vector4F row1, Vector4F row2, Vector4F row3) => (Row1, Row2, Row3) = (row1, row2, row3); + [UnscopedRef] + public ref Vector4F this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; - public Vector4F Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; - public Vector4F Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 3rd row and 4th column of the matrix. public T M34 => Row3.W; - public static bool operator ==(Matrix3x4F left, Matrix3x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; - public static bool operator !=(Matrix3x4F left, Matrix3x4F right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix3x4F other && Equals(other); /// public bool Equals(Matrix3x4F other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix3x4F left, Matrix3x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix3x4F left, Matrix3x4F right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix3x4F operator +(Matrix3x4F left, Matrix3x4F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix3x4F operator -(Matrix3x4F left, Matrix3x4F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x4F operator *(Matrix2x3F left, Matrix3x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x4F operator *(Matrix3x3F left, Matrix3x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x2F operator *(Matrix3x4F left, Matrix4x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x3F operator *(Matrix3x4F left, Matrix4x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x4I.gen.cs b/sources/Maths/Maths/Matrix3x4I.gen.cs index 531d3ce4b8..e944c9459f 100644 --- a/sources/Maths/Maths/Matrix3x4I.gen.cs +++ b/sources/Maths/Maths/Matrix3x4I.gen.cs @@ -1,30 +1,105 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix3x4I : IEquatable> where T : IBinaryInteger { + /// The 1st row of the matrix represented as a vector. public Vector4I Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector4I Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector4I Row3; + public Matrix3x4I(Vector4I row1, Vector4I row2, Vector4I row3) => (Row1, Row2, Row3) = (row1, row2, row3); + [UnscopedRef] + public ref Vector4I this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; - public Vector4I Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; - public Vector4I Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 3rd row and 4th column of the matrix. public T M34 => Row3.W; - public static bool operator ==(Matrix3x4I left, Matrix3x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; - public static bool operator !=(Matrix3x4I left, Matrix3x4I right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix3x4I other && Equals(other); /// public bool Equals(Matrix3x4I other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix3x4I left, Matrix3x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix3x4I left, Matrix3x4I right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix3x4I operator +(Matrix3x4I left, Matrix3x4I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix3x4I operator -(Matrix3x4I left, Matrix3x4I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x4I operator *(Matrix2x3I left, Matrix3x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x4I operator *(Matrix3x3I left, Matrix3x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x2I operator *(Matrix3x4I left, Matrix4x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x3I operator *(Matrix3x4I left, Matrix4x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x2F.gen.cs b/sources/Maths/Maths/Matrix4x2F.gen.cs index 69b77a8983..1a99fc610b 100644 --- a/sources/Maths/Maths/Matrix4x2F.gen.cs +++ b/sources/Maths/Maths/Matrix4x2F.gen.cs @@ -1,27 +1,96 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix4x2F : IEquatable> where T : IFloatingPointIeee754 { + /// The 1st row of the matrix represented as a vector. public Vector2F Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector2F Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector2F Row3; + /// The 4th row of the matrix represented as a vector. + public Vector2F Row4; + public Matrix4x2F(Vector2F row1, Vector2F row2, Vector2F row3, Vector2F row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + [UnscopedRef] + public ref Vector2F this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; - public Vector2F Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; - public Vector2F Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; - public Vector2F Row4; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; - public static bool operator ==(Matrix4x2F left, Matrix4x2F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; - public static bool operator !=(Matrix4x2F left, Matrix4x2F right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix4x2F other && Equals(other); /// public bool Equals(Matrix4x2F other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix4x2F left, Matrix4x2F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix4x2F left, Matrix4x2F right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4x2F operator +(Matrix4x2F left, Matrix4x2F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4x2F operator -(Matrix4x2F left, Matrix4x2F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x2F operator *(Matrix4x2F left, Matrix2x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x3F operator *(Matrix4x2F left, Matrix2x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x4F operator *(Matrix4x2F left, Matrix2x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x2I.gen.cs b/sources/Maths/Maths/Matrix4x2I.gen.cs index 009132e9a9..56dfdfc4c8 100644 --- a/sources/Maths/Maths/Matrix4x2I.gen.cs +++ b/sources/Maths/Maths/Matrix4x2I.gen.cs @@ -1,27 +1,96 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix4x2I : IEquatable> where T : IBinaryInteger { + /// The 1st row of the matrix represented as a vector. public Vector2I Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector2I Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector2I Row3; + /// The 4th row of the matrix represented as a vector. + public Vector2I Row4; + public Matrix4x2I(Vector2I row1, Vector2I row2, Vector2I row3, Vector2I row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + [UnscopedRef] + public ref Vector2I this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; - public Vector2I Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; - public Vector2I Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; - public Vector2I Row4; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; - public static bool operator ==(Matrix4x2I left, Matrix4x2I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; - public static bool operator !=(Matrix4x2I left, Matrix4x2I right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix4x2I other && Equals(other); /// public bool Equals(Matrix4x2I other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix4x2I left, Matrix4x2I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix4x2I left, Matrix4x2I right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4x2I operator +(Matrix4x2I left, Matrix4x2I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4x2I operator -(Matrix4x2I left, Matrix4x2I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x2I operator *(Matrix4x2I left, Matrix2x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x3I operator *(Matrix4x2I left, Matrix2x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x4I operator *(Matrix4x2I left, Matrix2x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x3F.gen.cs b/sources/Maths/Maths/Matrix4x3F.gen.cs index 45645b08b7..534d3c9018 100644 --- a/sources/Maths/Maths/Matrix4x3F.gen.cs +++ b/sources/Maths/Maths/Matrix4x3F.gen.cs @@ -1,31 +1,109 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix4x3F : IEquatable> where T : IFloatingPointIeee754 { + /// The 1st row of the matrix represented as a vector. public Vector3F Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector3F Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector3F Row3; + /// The 4th row of the matrix represented as a vector. + public Vector3F Row4; + public Matrix4x3F(Vector3F row1, Vector3F row2, Vector3F row3, Vector3F row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + [UnscopedRef] + public ref Vector3F this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; - public Vector3F Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; - public Vector3F Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; - public Vector3F Row4; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// Gets the element in the 4th row and 3rd column of the matrix. public T M43 => Row4.Z; - public static bool operator ==(Matrix4x3F left, Matrix4x3F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; - public static bool operator !=(Matrix4x3F left, Matrix4x3F right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix4x3F other && Equals(other); /// public bool Equals(Matrix4x3F other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix4x3F left, Matrix4x3F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix4x3F left, Matrix4x3F right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4x3F operator +(Matrix4x3F left, Matrix4x3F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4x3F operator -(Matrix4x3F left, Matrix4x3F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x3F operator *(Matrix2x4F left, Matrix4x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x2F operator *(Matrix4x3F left, Matrix3x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x3F operator *(Matrix4x3F left, Matrix3x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x4F operator *(Matrix4x3F left, Matrix3x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x3I.gen.cs b/sources/Maths/Maths/Matrix4x3I.gen.cs index 3dd56f6000..90d2a59aec 100644 --- a/sources/Maths/Maths/Matrix4x3I.gen.cs +++ b/sources/Maths/Maths/Matrix4x3I.gen.cs @@ -1,31 +1,109 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix4x3I : IEquatable> where T : IBinaryInteger { + /// The 1st row of the matrix represented as a vector. public Vector3I Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector3I Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector3I Row3; + /// The 4th row of the matrix represented as a vector. + public Vector3I Row4; + public Matrix4x3I(Vector3I row1, Vector3I row2, Vector3I row3, Vector3I row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + [UnscopedRef] + public ref Vector3I this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; - public Vector3I Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; - public Vector3I Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; - public Vector3I Row4; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// Gets the element in the 4th row and 3rd column of the matrix. public T M43 => Row4.Z; - public static bool operator ==(Matrix4x3I left, Matrix4x3I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; - public static bool operator !=(Matrix4x3I left, Matrix4x3I right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix4x3I other && Equals(other); /// public bool Equals(Matrix4x3I other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix4x3I left, Matrix4x3I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix4x3I left, Matrix4x3I right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4x3I operator +(Matrix4x3I left, Matrix4x3I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4x3I operator -(Matrix4x3I left, Matrix4x3I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x3I operator *(Matrix2x4I left, Matrix4x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x2I operator *(Matrix4x3I left, Matrix3x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x3I operator *(Matrix4x3I left, Matrix3x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x4I operator *(Matrix4x3I left, Matrix3x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x4F.gen.cs b/sources/Maths/Maths/Matrix4x4F.gen.cs index 83804511cc..35b3d492d2 100644 --- a/sources/Maths/Maths/Matrix4x4F.gen.cs +++ b/sources/Maths/Maths/Matrix4x4F.gen.cs @@ -1,35 +1,122 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix4x4F : IEquatable> where T : IFloatingPointIeee754 { + /// The 1st row of the matrix represented as a vector. public Vector4F Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector4F Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector4F Row3; + /// The 4th row of the matrix represented as a vector. + public Vector4F Row4; + public Matrix4x4F(Vector4F row1, Vector4F row2, Vector4F row3, Vector4F row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + [UnscopedRef] + public ref Vector4F this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; - public Vector4F Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; - public Vector4F Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 3rd row and 4th column of the matrix. public T M34 => Row3.W; - public Vector4F Row4; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// Gets the element in the 4th row and 3rd column of the matrix. public T M43 => Row4.Z; + /// Gets the element in the 4th row and 4th column of the matrix. public T M44 => Row4.W; - public static bool operator ==(Matrix4x4F left, Matrix4x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; - public static bool operator !=(Matrix4x4F left, Matrix4x4F right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix4x4F other && Equals(other); /// public bool Equals(Matrix4x4F other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix4x4F left, Matrix4x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix4x4F left, Matrix4x4F right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4x4F operator +(Matrix4x4F left, Matrix4x4F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4x4F operator -(Matrix4x4F left, Matrix4x4F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x4F operator *(Matrix2x4F left, Matrix4x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x4F operator *(Matrix3x4F left, Matrix4x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x2F operator *(Matrix4x4F left, Matrix4x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x3F operator *(Matrix4x4F left, Matrix4x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x4F operator *(Matrix4x4F left, Matrix4x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x4I.gen.cs b/sources/Maths/Maths/Matrix4x4I.gen.cs index a49923923a..3745130e76 100644 --- a/sources/Maths/Maths/Matrix4x4I.gen.cs +++ b/sources/Maths/Maths/Matrix4x4I.gen.cs @@ -1,35 +1,122 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix4x4I : IEquatable> where T : IBinaryInteger { + /// The 1st row of the matrix represented as a vector. public Vector4I Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector4I Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector4I Row3; + /// The 4th row of the matrix represented as a vector. + public Vector4I Row4; + public Matrix4x4I(Vector4I row1, Vector4I row2, Vector4I row3, Vector4I row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + [UnscopedRef] + public ref Vector4I this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; - public Vector4I Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; - public Vector4I Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 3rd row and 4th column of the matrix. public T M34 => Row3.W; - public Vector4I Row4; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// Gets the element in the 4th row and 3rd column of the matrix. public T M43 => Row4.Z; + /// Gets the element in the 4th row and 4th column of the matrix. public T M44 => Row4.W; - public static bool operator ==(Matrix4x4I left, Matrix4x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; - public static bool operator !=(Matrix4x4I left, Matrix4x4I right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix4x4I other && Equals(other); /// public bool Equals(Matrix4x4I other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix4x4I left, Matrix4x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix4x4I left, Matrix4x4I right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4x4I operator +(Matrix4x4I left, Matrix4x4I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4x4I operator -(Matrix4x4I left, Matrix4x4I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2x4I operator *(Matrix2x4I left, Matrix4x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3x4I operator *(Matrix3x4I left, Matrix4x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x2I operator *(Matrix4x4I left, Matrix4x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x3I operator *(Matrix4x4I left, Matrix4x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4x4I operator *(Matrix4x4I left, Matrix4x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix5x4F.gen.cs b/sources/Maths/Maths/Matrix5x4F.gen.cs index 5b1b50135f..efdcf0a2f8 100644 --- a/sources/Maths/Maths/Matrix5x4F.gen.cs +++ b/sources/Maths/Maths/Matrix5x4F.gen.cs @@ -1,40 +1,114 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix5x4F : IEquatable> where T : IFloatingPointIeee754 { + /// The 1st row of the matrix represented as a vector. public Vector4F Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector4F Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector4F Row3; + /// The 4th row of the matrix represented as a vector. + public Vector4F Row4; + /// The 5th row of the matrix represented as a vector. + public Vector4F Row5; + public Matrix5x4F(Vector4F row1, Vector4F row2, Vector4F row3, Vector4F row4, Vector4F row5) => (Row1, Row2, Row3, Row4, Row5) = (row1, row2, row3, row4, row5); + [UnscopedRef] + public ref Vector4F this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + case 4: + return ref Row5; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; - public Vector4F Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; - public Vector4F Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 3rd row and 4th column of the matrix. public T M34 => Row3.W; - public Vector4F Row4; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// Gets the element in the 4th row and 3rd column of the matrix. public T M43 => Row4.Z; + /// Gets the element in the 4th row and 4th column of the matrix. public T M44 => Row4.W; - public Vector4F Row5; + /// Gets the element in the 5th row and 1st column of the matrix. public T M51 => Row5.X; + /// Gets the element in the 5th row and 2nd column of the matrix. public T M52 => Row5.Y; + /// Gets the element in the 5th row and 3rd column of the matrix. public T M53 => Row5.Z; + /// Gets the element in the 5th row and 4th column of the matrix. public T M54 => Row5.W; - public static bool operator ==(Matrix5x4F left, Matrix5x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4 && left.Row5 == right.Row5; - public static bool operator !=(Matrix5x4F left, Matrix5x4F right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix5x4F other && Equals(other); /// public bool Equals(Matrix5x4F other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4, Row5); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix5x4F left, Matrix5x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4 && left.Row5 == right.Row5; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix5x4F left, Matrix5x4F right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix5x4F operator +(Matrix5x4F left, Matrix5x4F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4, left.Row5 + right.Row5); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix5x4F operator -(Matrix5x4F left, Matrix5x4F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4, left.Row5 - right.Row5); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix5x4F operator *(Matrix5x4F left, Matrix4x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix5x4I.gen.cs b/sources/Maths/Maths/Matrix5x4I.gen.cs index 5a072ef187..7b794338b0 100644 --- a/sources/Maths/Maths/Matrix5x4I.gen.cs +++ b/sources/Maths/Maths/Matrix5x4I.gen.cs @@ -1,40 +1,114 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Matrix5x4I : IEquatable> where T : IBinaryInteger { + /// The 1st row of the matrix represented as a vector. public Vector4I Row1; + /// The 2nd row of the matrix represented as a vector. + public Vector4I Row2; + /// The 3rd row of the matrix represented as a vector. + public Vector4I Row3; + /// The 4th row of the matrix represented as a vector. + public Vector4I Row4; + /// The 5th row of the matrix represented as a vector. + public Vector4I Row5; + public Matrix5x4I(Vector4I row1, Vector4I row2, Vector4I row3, Vector4I row4, Vector4I row5) => (Row1, Row2, Row3, Row4, Row5) = (row1, row2, row3, row4, row5); + [UnscopedRef] + public ref Vector4I this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + case 4: + return ref Row5; + } + + throw new ArgumentOutOfRangeException(nameof(row)); + } + } + + /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; - public Vector4I Row2; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; - public Vector4I Row3; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 3rd row and 4th column of the matrix. public T M34 => Row3.W; - public Vector4I Row4; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// Gets the element in the 4th row and 3rd column of the matrix. public T M43 => Row4.Z; + /// Gets the element in the 4th row and 4th column of the matrix. public T M44 => Row4.W; - public Vector4I Row5; + /// Gets the element in the 5th row and 1st column of the matrix. public T M51 => Row5.X; + /// Gets the element in the 5th row and 2nd column of the matrix. public T M52 => Row5.Y; + /// Gets the element in the 5th row and 3rd column of the matrix. public T M53 => Row5.Z; + /// Gets the element in the 5th row and 4th column of the matrix. public T M54 => Row5.W; - public static bool operator ==(Matrix5x4I left, Matrix5x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4 && left.Row5 == right.Row5; - public static bool operator !=(Matrix5x4I left, Matrix5x4I right) => !(left == right); + /// public override bool Equals(object? obj) => obj is Matrix5x4I other && Equals(other); /// public bool Equals(Matrix5x4I other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4, Row5); + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix5x4I left, Matrix5x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4 && left.Row5 == right.Row5; + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix5x4I left, Matrix5x4I right) => !(left == right); + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix5x4I operator +(Matrix5x4I left, Matrix5x4I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4, left.Row5 + right.Row5); + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix5x4I operator -(Matrix5x4I left, Matrix5x4I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4, left.Row5 - right.Row5); + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix5x4I operator *(Matrix5x4I left, Matrix4x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); } } \ No newline at end of file From cfee01259a52e81fbc2685c63f9749e2d6a3da8e Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Fri, 30 May 2025 18:25:38 -0700 Subject: [PATCH 17/67] Whitespace and comments. --- sources/Maths/Maths/Matrix2x2F.gen.cs | 53 ++++++++---- sources/Maths/Maths/Matrix2x2I.gen.cs | 53 ++++++++---- sources/Maths/Maths/Matrix2x3F.gen.cs | 64 ++++++++++---- sources/Maths/Maths/Matrix2x3I.gen.cs | 64 ++++++++++---- sources/Maths/Maths/Matrix2x4F.gen.cs | 76 ++++++++++++----- sources/Maths/Maths/Matrix2x4I.gen.cs | 76 ++++++++++++----- sources/Maths/Maths/Matrix3x2F.gen.cs | 70 ++++++++++++---- sources/Maths/Maths/Matrix3x2I.gen.cs | 70 ++++++++++++---- sources/Maths/Maths/Matrix3x3F.gen.cs | 82 +++++++++++++----- sources/Maths/Maths/Matrix3x3I.gen.cs | 82 +++++++++++++----- sources/Maths/Maths/Matrix3x4F.gen.cs | 95 ++++++++++++++++----- sources/Maths/Maths/Matrix3x4I.gen.cs | 95 ++++++++++++++++----- sources/Maths/Maths/Matrix4x2F.gen.cs | 89 +++++++++++++++----- sources/Maths/Maths/Matrix4x2I.gen.cs | 89 +++++++++++++++----- sources/Maths/Maths/Matrix4x3F.gen.cs | 102 +++++++++++++++++----- sources/Maths/Maths/Matrix4x3I.gen.cs | 102 +++++++++++++++++----- sources/Maths/Maths/Matrix4x4F.gen.cs | 116 ++++++++++++++++++++------ sources/Maths/Maths/Matrix4x4I.gen.cs | 116 ++++++++++++++++++++------ sources/Maths/Maths/Matrix5x4F.gen.cs | 84 +++++++++++++++---- sources/Maths/Maths/Matrix5x4I.gen.cs | 84 +++++++++++++++---- 20 files changed, 1274 insertions(+), 388 deletions(-) diff --git a/sources/Maths/Maths/Matrix2x2F.gen.cs b/sources/Maths/Maths/Matrix2x2F.gen.cs index 89adcc9f5f..0f08a02fc2 100644 --- a/sources/Maths/Maths/Matrix2x2F.gen.cs +++ b/sources/Maths/Maths/Matrix2x2F.gen.cs @@ -7,9 +7,15 @@ partial struct Matrix2x2F : IEquatable> where T : IFloatingPoin { /// The 1st row of the matrix represented as a vector. public Vector2F Row1; + /// The 2nd row of the matrix represented as a vector. public Vector2F Row2; + + /// + /// Constructs a from the given rows. + /// public Matrix2x2F(Vector2F row1, Vector2F row2) => (Row1, Row2) = (row1, row2); + [UnscopedRef] public ref Vector2F this[int row] { @@ -29,42 +35,61 @@ public ref Vector2F this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// public override bool Equals(object? obj) => obj is Matrix2x2F other && Equals(other); + /// public bool Equals(Matrix2x2F other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix2x2F left, Matrix2x2F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + public static bool operator ==(Matrix2x2F left, Matrix2x2F right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix2x2F left, Matrix2x2F right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix2x2F operator +(Matrix2x2F left, Matrix2x2F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); + public static Matrix2x2F operator +(Matrix2x2F left, Matrix2x2F right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix2x2F operator -(Matrix2x2F left, Matrix2x2F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); + public static Matrix2x2F operator -(Matrix2x2F left, Matrix2x2F right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x2F operator *(Matrix2x2F left, Matrix2x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); + public static Matrix2x2F operator *(Matrix2x2F left, Matrix2x2F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x2I.gen.cs b/sources/Maths/Maths/Matrix2x2I.gen.cs index b821cef6e4..ecb2f945a4 100644 --- a/sources/Maths/Maths/Matrix2x2I.gen.cs +++ b/sources/Maths/Maths/Matrix2x2I.gen.cs @@ -7,9 +7,15 @@ partial struct Matrix2x2I : IEquatable> where T : IBinaryIntege { /// The 1st row of the matrix represented as a vector. public Vector2I Row1; + /// The 2nd row of the matrix represented as a vector. public Vector2I Row2; + + /// + /// Constructs a from the given rows. + /// public Matrix2x2I(Vector2I row1, Vector2I row2) => (Row1, Row2) = (row1, row2); + [UnscopedRef] public ref Vector2I this[int row] { @@ -29,42 +35,61 @@ public ref Vector2I this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// public override bool Equals(object? obj) => obj is Matrix2x2I other && Equals(other); + /// public bool Equals(Matrix2x2I other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix2x2I left, Matrix2x2I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + public static bool operator ==(Matrix2x2I left, Matrix2x2I right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix2x2I left, Matrix2x2I right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix2x2I operator +(Matrix2x2I left, Matrix2x2I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); + public static Matrix2x2I operator +(Matrix2x2I left, Matrix2x2I right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix2x2I operator -(Matrix2x2I left, Matrix2x2I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); + public static Matrix2x2I operator -(Matrix2x2I left, Matrix2x2I right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x2I operator *(Matrix2x2I left, Matrix2x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); + public static Matrix2x2I operator *(Matrix2x2I left, Matrix2x2I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x3F.gen.cs b/sources/Maths/Maths/Matrix2x3F.gen.cs index 1e29c07468..4d6f920ce9 100644 --- a/sources/Maths/Maths/Matrix2x3F.gen.cs +++ b/sources/Maths/Maths/Matrix2x3F.gen.cs @@ -7,9 +7,15 @@ partial struct Matrix2x3F : IEquatable> where T : IFloatingPoin { /// The 1st row of the matrix represented as a vector. public Vector3F Row1; + /// The 2nd row of the matrix represented as a vector. public Vector3F Row2; + + /// + /// Constructs a from the given rows. + /// public Matrix2x3F(Vector3F row1, Vector3F row2) => (Row1, Row2) = (row1, row2); + [UnscopedRef] public ref Vector3F this[int row] { @@ -29,51 +35,75 @@ public ref Vector3F this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// public override bool Equals(object? obj) => obj is Matrix2x3F other && Equals(other); + /// public bool Equals(Matrix2x3F other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix2x3F left, Matrix2x3F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + public static bool operator ==(Matrix2x3F left, Matrix2x3F right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix2x3F left, Matrix2x3F right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix2x3F operator +(Matrix2x3F left, Matrix2x3F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); + public static Matrix2x3F operator +(Matrix2x3F left, Matrix2x3F right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix2x3F operator -(Matrix2x3F left, Matrix2x3F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); + public static Matrix2x3F operator -(Matrix2x3F left, Matrix2x3F right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x3F operator *(Matrix2x2F left, Matrix2x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); + public static Matrix2x3F operator *(Matrix2x2F left, Matrix2x3F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x2F operator *(Matrix2x3F left, Matrix3x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + public static Matrix2x2F operator *(Matrix2x3F left, Matrix3x2F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x3I.gen.cs b/sources/Maths/Maths/Matrix2x3I.gen.cs index 1552290f34..83b682d83d 100644 --- a/sources/Maths/Maths/Matrix2x3I.gen.cs +++ b/sources/Maths/Maths/Matrix2x3I.gen.cs @@ -7,9 +7,15 @@ partial struct Matrix2x3I : IEquatable> where T : IBinaryIntege { /// The 1st row of the matrix represented as a vector. public Vector3I Row1; + /// The 2nd row of the matrix represented as a vector. public Vector3I Row2; + + /// + /// Constructs a from the given rows. + /// public Matrix2x3I(Vector3I row1, Vector3I row2) => (Row1, Row2) = (row1, row2); + [UnscopedRef] public ref Vector3I this[int row] { @@ -29,51 +35,75 @@ public ref Vector3I this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// public override bool Equals(object? obj) => obj is Matrix2x3I other && Equals(other); + /// public bool Equals(Matrix2x3I other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix2x3I left, Matrix2x3I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + public static bool operator ==(Matrix2x3I left, Matrix2x3I right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix2x3I left, Matrix2x3I right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix2x3I operator +(Matrix2x3I left, Matrix2x3I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); + public static Matrix2x3I operator +(Matrix2x3I left, Matrix2x3I right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix2x3I operator -(Matrix2x3I left, Matrix2x3I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); + public static Matrix2x3I operator -(Matrix2x3I left, Matrix2x3I right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x3I operator *(Matrix2x2I left, Matrix2x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); + public static Matrix2x3I operator *(Matrix2x2I left, Matrix2x3I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x2I operator *(Matrix2x3I left, Matrix3x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + public static Matrix2x2I operator *(Matrix2x3I left, Matrix3x2I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x4F.gen.cs b/sources/Maths/Maths/Matrix2x4F.gen.cs index e8ae19335b..a310f3fabb 100644 --- a/sources/Maths/Maths/Matrix2x4F.gen.cs +++ b/sources/Maths/Maths/Matrix2x4F.gen.cs @@ -7,9 +7,15 @@ partial struct Matrix2x4F : IEquatable> where T : IFloatingPoin { /// The 1st row of the matrix represented as a vector. public Vector4F Row1; + /// The 2nd row of the matrix represented as a vector. public Vector4F Row2; + + /// + /// Constructs a from the given rows. + /// public Matrix2x4F(Vector4F row1, Vector4F row2) => (Row1, Row2) = (row1, row2); + [UnscopedRef] public ref Vector4F this[int row] { @@ -29,60 +35,90 @@ public ref Vector4F this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; + /// public override bool Equals(object? obj) => obj is Matrix2x4F other && Equals(other); + /// public bool Equals(Matrix2x4F other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix2x4F left, Matrix2x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + public static bool operator ==(Matrix2x4F left, Matrix2x4F right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix2x4F left, Matrix2x4F right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix2x4F operator +(Matrix2x4F left, Matrix2x4F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); + public static Matrix2x4F operator +(Matrix2x4F left, Matrix2x4F right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix2x4F operator -(Matrix2x4F left, Matrix2x4F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); + public static Matrix2x4F operator -(Matrix2x4F left, Matrix2x4F right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x4F operator *(Matrix2x2F left, Matrix2x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); + public static Matrix2x4F operator *(Matrix2x2F left, Matrix2x4F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x2F operator *(Matrix2x4F left, Matrix4x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + public static Matrix2x2F operator *(Matrix2x4F left, Matrix4x2F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x4F operator *(Matrix3x2F left, Matrix2x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + public static Matrix3x4F operator *(Matrix3x2F left, Matrix2x4F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2, + left.M31 * right.Row1 + left.M32 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix2x4I.gen.cs b/sources/Maths/Maths/Matrix2x4I.gen.cs index 00d2a60fd7..a30c911a50 100644 --- a/sources/Maths/Maths/Matrix2x4I.gen.cs +++ b/sources/Maths/Maths/Matrix2x4I.gen.cs @@ -7,9 +7,15 @@ partial struct Matrix2x4I : IEquatable> where T : IBinaryIntege { /// The 1st row of the matrix represented as a vector. public Vector4I Row1; + /// The 2nd row of the matrix represented as a vector. public Vector4I Row2; + + /// + /// Constructs a from the given rows. + /// public Matrix2x4I(Vector4I row1, Vector4I row2) => (Row1, Row2) = (row1, row2); + [UnscopedRef] public ref Vector4I this[int row] { @@ -29,60 +35,90 @@ public ref Vector4I this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; + /// public override bool Equals(object? obj) => obj is Matrix2x4I other && Equals(other); + /// public bool Equals(Matrix2x4I other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix2x4I left, Matrix2x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; + public static bool operator ==(Matrix2x4I left, Matrix2x4I right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix2x4I left, Matrix2x4I right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix2x4I operator +(Matrix2x4I left, Matrix2x4I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); + public static Matrix2x4I operator +(Matrix2x4I left, Matrix2x4I right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix2x4I operator -(Matrix2x4I left, Matrix2x4I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); + public static Matrix2x4I operator -(Matrix2x4I left, Matrix2x4I right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x4I operator *(Matrix2x2I left, Matrix2x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); + public static Matrix2x4I operator *(Matrix2x2I left, Matrix2x4I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x2I operator *(Matrix2x4I left, Matrix4x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + public static Matrix2x2I operator *(Matrix2x4I left, Matrix4x2I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x4I operator *(Matrix3x2I left, Matrix2x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + public static Matrix3x4I operator *(Matrix3x2I left, Matrix2x4I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2, + left.M31 * right.Row1 + left.M32 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x2F.gen.cs b/sources/Maths/Maths/Matrix3x2F.gen.cs index d3b9d23ca9..42d2c7d49c 100644 --- a/sources/Maths/Maths/Matrix3x2F.gen.cs +++ b/sources/Maths/Maths/Matrix3x2F.gen.cs @@ -7,11 +7,18 @@ partial struct Matrix3x2F : IEquatable> where T : IFloatingPoin { /// The 1st row of the matrix represented as a vector. public Vector2F Row1; + /// The 2nd row of the matrix represented as a vector. public Vector2F Row2; + /// The 3rd row of the matrix represented as a vector. public Vector2F Row3; + + /// + /// Constructs a from the given rows. + /// public Matrix3x2F(Vector2F row1, Vector2F row2, Vector2F row3) => (Row1, Row2, Row3) = (row1, row2, row3); + [UnscopedRef] public ref Vector2F this[int row] { @@ -33,51 +40,80 @@ public ref Vector2F this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// public override bool Equals(object? obj) => obj is Matrix3x2F other && Equals(other); + /// public bool Equals(Matrix3x2F other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix3x2F left, Matrix3x2F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + public static bool operator ==(Matrix3x2F left, Matrix3x2F right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix3x2F left, Matrix3x2F right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix3x2F operator +(Matrix3x2F left, Matrix3x2F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); + public static Matrix3x2F operator +(Matrix3x2F left, Matrix3x2F right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix3x2F operator -(Matrix3x2F left, Matrix3x2F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); + public static Matrix3x2F operator -(Matrix3x2F left, Matrix3x2F right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x2F operator *(Matrix3x2F left, Matrix2x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + public static Matrix3x2F operator *(Matrix3x2F left, Matrix2x2F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2, + left.M31 * right.Row1 + left.M32 * right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x3F operator *(Matrix3x2F left, Matrix2x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + public static Matrix3x3F operator *(Matrix3x2F left, Matrix2x3F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2, + left.M31 * right.Row1 + left.M32 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x2I.gen.cs b/sources/Maths/Maths/Matrix3x2I.gen.cs index ff42a87479..84c0054f95 100644 --- a/sources/Maths/Maths/Matrix3x2I.gen.cs +++ b/sources/Maths/Maths/Matrix3x2I.gen.cs @@ -7,11 +7,18 @@ partial struct Matrix3x2I : IEquatable> where T : IBinaryIntege { /// The 1st row of the matrix represented as a vector. public Vector2I Row1; + /// The 2nd row of the matrix represented as a vector. public Vector2I Row2; + /// The 3rd row of the matrix represented as a vector. public Vector2I Row3; + + /// + /// Constructs a from the given rows. + /// public Matrix3x2I(Vector2I row1, Vector2I row2, Vector2I row3) => (Row1, Row2, Row3) = (row1, row2, row3); + [UnscopedRef] public ref Vector2I this[int row] { @@ -33,51 +40,80 @@ public ref Vector2I this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// public override bool Equals(object? obj) => obj is Matrix3x2I other && Equals(other); + /// public bool Equals(Matrix3x2I other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix3x2I left, Matrix3x2I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + public static bool operator ==(Matrix3x2I left, Matrix3x2I right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix3x2I left, Matrix3x2I right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix3x2I operator +(Matrix3x2I left, Matrix3x2I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); + public static Matrix3x2I operator +(Matrix3x2I left, Matrix3x2I right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix3x2I operator -(Matrix3x2I left, Matrix3x2I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); + public static Matrix3x2I operator -(Matrix3x2I left, Matrix3x2I right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x2I operator *(Matrix3x2I left, Matrix2x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + public static Matrix3x2I operator *(Matrix3x2I left, Matrix2x2I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2, + left.M31 * right.Row1 + left.M32 * right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x3I operator *(Matrix3x2I left, Matrix2x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + public static Matrix3x3I operator *(Matrix3x2I left, Matrix2x3I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2, + left.M31 * right.Row1 + left.M32 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x3F.gen.cs b/sources/Maths/Maths/Matrix3x3F.gen.cs index 5e58784ba3..35c045ea23 100644 --- a/sources/Maths/Maths/Matrix3x3F.gen.cs +++ b/sources/Maths/Maths/Matrix3x3F.gen.cs @@ -7,11 +7,18 @@ partial struct Matrix3x3F : IEquatable> where T : IFloatingPoin { /// The 1st row of the matrix represented as a vector. public Vector3F Row1; + /// The 2nd row of the matrix represented as a vector. public Vector3F Row2; + /// The 3rd row of the matrix represented as a vector. public Vector3F Row3; + + /// + /// Constructs a from the given rows. + /// public Matrix3x3F(Vector3F row1, Vector3F row2, Vector3F row3) => (Row1, Row2, Row3) = (row1, row2, row3); + [UnscopedRef] public ref Vector3F this[int row] { @@ -33,62 +40,97 @@ public ref Vector3F this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// public override bool Equals(object? obj) => obj is Matrix3x3F other && Equals(other); + /// public bool Equals(Matrix3x3F other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix3x3F left, Matrix3x3F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + public static bool operator ==(Matrix3x3F left, Matrix3x3F right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix3x3F left, Matrix3x3F right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix3x3F operator +(Matrix3x3F left, Matrix3x3F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); + public static Matrix3x3F operator +(Matrix3x3F left, Matrix3x3F right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix3x3F operator -(Matrix3x3F left, Matrix3x3F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); + public static Matrix3x3F operator -(Matrix3x3F left, Matrix3x3F right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x3F operator *(Matrix2x3F left, Matrix3x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + public static Matrix2x3F operator *(Matrix2x3F left, Matrix3x3F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x2F operator *(Matrix3x3F left, Matrix3x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + public static Matrix3x2F operator *(Matrix3x3F left, Matrix3x2F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x3F operator *(Matrix3x3F left, Matrix3x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + public static Matrix3x3F operator *(Matrix3x3F left, Matrix3x3F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x3I.gen.cs b/sources/Maths/Maths/Matrix3x3I.gen.cs index 51c31bf28f..b5d63fd42c 100644 --- a/sources/Maths/Maths/Matrix3x3I.gen.cs +++ b/sources/Maths/Maths/Matrix3x3I.gen.cs @@ -7,11 +7,18 @@ partial struct Matrix3x3I : IEquatable> where T : IBinaryIntege { /// The 1st row of the matrix represented as a vector. public Vector3I Row1; + /// The 2nd row of the matrix represented as a vector. public Vector3I Row2; + /// The 3rd row of the matrix represented as a vector. public Vector3I Row3; + + /// + /// Constructs a from the given rows. + /// public Matrix3x3I(Vector3I row1, Vector3I row2, Vector3I row3) => (Row1, Row2, Row3) = (row1, row2, row3); + [UnscopedRef] public ref Vector3I this[int row] { @@ -33,62 +40,97 @@ public ref Vector3I this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// public override bool Equals(object? obj) => obj is Matrix3x3I other && Equals(other); + /// public bool Equals(Matrix3x3I other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix3x3I left, Matrix3x3I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + public static bool operator ==(Matrix3x3I left, Matrix3x3I right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix3x3I left, Matrix3x3I right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix3x3I operator +(Matrix3x3I left, Matrix3x3I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); + public static Matrix3x3I operator +(Matrix3x3I left, Matrix3x3I right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix3x3I operator -(Matrix3x3I left, Matrix3x3I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); + public static Matrix3x3I operator -(Matrix3x3I left, Matrix3x3I right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x3I operator *(Matrix2x3I left, Matrix3x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + public static Matrix2x3I operator *(Matrix2x3I left, Matrix3x3I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x2I operator *(Matrix3x3I left, Matrix3x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + public static Matrix3x2I operator *(Matrix3x3I left, Matrix3x2I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x3I operator *(Matrix3x3I left, Matrix3x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + public static Matrix3x3I operator *(Matrix3x3I left, Matrix3x3I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x4F.gen.cs b/sources/Maths/Maths/Matrix3x4F.gen.cs index 1f0333ebdb..124a15c20e 100644 --- a/sources/Maths/Maths/Matrix3x4F.gen.cs +++ b/sources/Maths/Maths/Matrix3x4F.gen.cs @@ -7,11 +7,18 @@ partial struct Matrix3x4F : IEquatable> where T : IFloatingPoin { /// The 1st row of the matrix represented as a vector. public Vector4F Row1; + /// The 2nd row of the matrix represented as a vector. public Vector4F Row2; + /// The 3rd row of the matrix represented as a vector. public Vector4F Row3; + + /// + /// Constructs a from the given rows. + /// public Matrix3x4F(Vector4F row1, Vector4F row2, Vector4F row3) => (Row1, Row2, Row3) = (row1, row2, row3); + [UnscopedRef] public ref Vector4F this[int row] { @@ -33,73 +40,115 @@ public ref Vector4F this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 3rd row and 4th column of the matrix. public T M34 => Row3.W; + /// public override bool Equals(object? obj) => obj is Matrix3x4F other && Equals(other); + /// public bool Equals(Matrix3x4F other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix3x4F left, Matrix3x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + public static bool operator ==(Matrix3x4F left, Matrix3x4F right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix3x4F left, Matrix3x4F right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix3x4F operator +(Matrix3x4F left, Matrix3x4F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); + public static Matrix3x4F operator +(Matrix3x4F left, Matrix3x4F right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix3x4F operator -(Matrix3x4F left, Matrix3x4F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); + public static Matrix3x4F operator -(Matrix3x4F left, Matrix3x4F right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x4F operator *(Matrix2x3F left, Matrix3x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + public static Matrix2x4F operator *(Matrix2x3F left, Matrix3x4F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x4F operator *(Matrix3x3F left, Matrix3x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + public static Matrix3x4F operator *(Matrix3x3F left, Matrix3x4F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x2F operator *(Matrix3x4F left, Matrix4x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + public static Matrix3x2F operator *(Matrix3x4F left, Matrix4x2F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x3F operator *(Matrix3x4F left, Matrix4x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + public static Matrix3x3F operator *(Matrix3x4F left, Matrix4x3F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix3x4I.gen.cs b/sources/Maths/Maths/Matrix3x4I.gen.cs index e944c9459f..c91be5692a 100644 --- a/sources/Maths/Maths/Matrix3x4I.gen.cs +++ b/sources/Maths/Maths/Matrix3x4I.gen.cs @@ -7,11 +7,18 @@ partial struct Matrix3x4I : IEquatable> where T : IBinaryIntege { /// The 1st row of the matrix represented as a vector. public Vector4I Row1; + /// The 2nd row of the matrix represented as a vector. public Vector4I Row2; + /// The 3rd row of the matrix represented as a vector. public Vector4I Row3; + + /// + /// Constructs a from the given rows. + /// public Matrix3x4I(Vector4I row1, Vector4I row2, Vector4I row3) => (Row1, Row2, Row3) = (row1, row2, row3); + [UnscopedRef] public ref Vector4I this[int row] { @@ -33,73 +40,115 @@ public ref Vector4I this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 3rd row and 4th column of the matrix. public T M34 => Row3.W; + /// public override bool Equals(object? obj) => obj is Matrix3x4I other && Equals(other); + /// public bool Equals(Matrix3x4I other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix3x4I left, Matrix3x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; + public static bool operator ==(Matrix3x4I left, Matrix3x4I right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix3x4I left, Matrix3x4I right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix3x4I operator +(Matrix3x4I left, Matrix3x4I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); + public static Matrix3x4I operator +(Matrix3x4I left, Matrix3x4I right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix3x4I operator -(Matrix3x4I left, Matrix3x4I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); + public static Matrix3x4I operator -(Matrix3x4I left, Matrix3x4I right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x4I operator *(Matrix2x3I left, Matrix3x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + public static Matrix2x4I operator *(Matrix2x3I left, Matrix3x4I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x4I operator *(Matrix3x3I left, Matrix3x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + public static Matrix3x4I operator *(Matrix3x3I left, Matrix3x4I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x2I operator *(Matrix3x4I left, Matrix4x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + public static Matrix3x2I operator *(Matrix3x4I left, Matrix4x2I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x3I operator *(Matrix3x4I left, Matrix4x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + public static Matrix3x3I operator *(Matrix3x4I left, Matrix4x3I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x2F.gen.cs b/sources/Maths/Maths/Matrix4x2F.gen.cs index 1a99fc610b..227a09e12c 100644 --- a/sources/Maths/Maths/Matrix4x2F.gen.cs +++ b/sources/Maths/Maths/Matrix4x2F.gen.cs @@ -7,13 +7,21 @@ partial struct Matrix4x2F : IEquatable> where T : IFloatingPoin { /// The 1st row of the matrix represented as a vector. public Vector2F Row1; + /// The 2nd row of the matrix represented as a vector. public Vector2F Row2; + /// The 3rd row of the matrix represented as a vector. public Vector2F Row3; + /// The 4th row of the matrix represented as a vector. public Vector2F Row4; + + /// + /// Constructs a from the given rows. + /// public Matrix4x2F(Vector2F row1, Vector2F row2, Vector2F row3, Vector2F row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + [UnscopedRef] public ref Vector2F this[int row] { @@ -37,60 +45,101 @@ public ref Vector2F this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// public override bool Equals(object? obj) => obj is Matrix4x2F other && Equals(other); + /// public bool Equals(Matrix4x2F other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix4x2F left, Matrix4x2F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + public static bool operator ==(Matrix4x2F left, Matrix4x2F right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3 && + left.Row4 == right.Row4; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix4x2F left, Matrix4x2F right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix4x2F operator +(Matrix4x2F left, Matrix4x2F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4); + public static Matrix4x2F operator +(Matrix4x2F left, Matrix4x2F right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3, + left.Row4 + right.Row4); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix4x2F operator -(Matrix4x2F left, Matrix4x2F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4); + public static Matrix4x2F operator -(Matrix4x2F left, Matrix4x2F right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3, + left.Row4 - right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x2F operator *(Matrix4x2F left, Matrix2x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); + public static Matrix4x2F operator *(Matrix4x2F left, Matrix2x2F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2, + left.M31 * right.Row1 + left.M32 * right.Row2, + left.M41 * right.Row1 + left.M42 * right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x3F operator *(Matrix4x2F left, Matrix2x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); + public static Matrix4x3F operator *(Matrix4x2F left, Matrix2x3F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2, + left.M31 * right.Row1 + left.M32 * right.Row2, + left.M41 * right.Row1 + left.M42 * right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x4F operator *(Matrix4x2F left, Matrix2x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); + public static Matrix4x4F operator *(Matrix4x2F left, Matrix2x4F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2, + left.M31 * right.Row1 + left.M32 * right.Row2, + left.M41 * right.Row1 + left.M42 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x2I.gen.cs b/sources/Maths/Maths/Matrix4x2I.gen.cs index 56dfdfc4c8..9d688dc387 100644 --- a/sources/Maths/Maths/Matrix4x2I.gen.cs +++ b/sources/Maths/Maths/Matrix4x2I.gen.cs @@ -7,13 +7,21 @@ partial struct Matrix4x2I : IEquatable> where T : IBinaryIntege { /// The 1st row of the matrix represented as a vector. public Vector2I Row1; + /// The 2nd row of the matrix represented as a vector. public Vector2I Row2; + /// The 3rd row of the matrix represented as a vector. public Vector2I Row3; + /// The 4th row of the matrix represented as a vector. public Vector2I Row4; + + /// + /// Constructs a from the given rows. + /// public Matrix4x2I(Vector2I row1, Vector2I row2, Vector2I row3, Vector2I row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + [UnscopedRef] public ref Vector2I this[int row] { @@ -37,60 +45,101 @@ public ref Vector2I this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// public override bool Equals(object? obj) => obj is Matrix4x2I other && Equals(other); + /// public bool Equals(Matrix4x2I other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix4x2I left, Matrix4x2I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + public static bool operator ==(Matrix4x2I left, Matrix4x2I right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3 && + left.Row4 == right.Row4; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix4x2I left, Matrix4x2I right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix4x2I operator +(Matrix4x2I left, Matrix4x2I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4); + public static Matrix4x2I operator +(Matrix4x2I left, Matrix4x2I right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3, + left.Row4 + right.Row4); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix4x2I operator -(Matrix4x2I left, Matrix4x2I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4); + public static Matrix4x2I operator -(Matrix4x2I left, Matrix4x2I right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3, + left.Row4 - right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x2I operator *(Matrix4x2I left, Matrix2x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); + public static Matrix4x2I operator *(Matrix4x2I left, Matrix2x2I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2, + left.M31 * right.Row1 + left.M32 * right.Row2, + left.M41 * right.Row1 + left.M42 * right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x3I operator *(Matrix4x2I left, Matrix2x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); + public static Matrix4x3I operator *(Matrix4x2I left, Matrix2x3I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2, + left.M31 * right.Row1 + left.M32 * right.Row2, + left.M41 * right.Row1 + left.M42 * right.Row2); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x4I operator *(Matrix4x2I left, Matrix2x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); + public static Matrix4x4I operator *(Matrix4x2I left, Matrix2x4I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2, + left.M21 * right.Row1 + left.M22 * right.Row2, + left.M31 * right.Row1 + left.M32 * right.Row2, + left.M41 * right.Row1 + left.M42 * right.Row2); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x3F.gen.cs b/sources/Maths/Maths/Matrix4x3F.gen.cs index 534d3c9018..28b958a85c 100644 --- a/sources/Maths/Maths/Matrix4x3F.gen.cs +++ b/sources/Maths/Maths/Matrix4x3F.gen.cs @@ -7,13 +7,21 @@ partial struct Matrix4x3F : IEquatable> where T : IFloatingPoin { /// The 1st row of the matrix represented as a vector. public Vector3F Row1; + /// The 2nd row of the matrix represented as a vector. public Vector3F Row2; + /// The 3rd row of the matrix represented as a vector. public Vector3F Row3; + /// The 4th row of the matrix represented as a vector. public Vector3F Row4; + + /// + /// Constructs a from the given rows. + /// public Matrix4x3F(Vector3F row1, Vector3F row2, Vector3F row3, Vector3F row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + [UnscopedRef] public ref Vector3F this[int row] { @@ -37,73 +45,121 @@ public ref Vector3F this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// Gets the element in the 4th row and 3rd column of the matrix. public T M43 => Row4.Z; + /// public override bool Equals(object? obj) => obj is Matrix4x3F other && Equals(other); + /// public bool Equals(Matrix4x3F other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix4x3F left, Matrix4x3F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + public static bool operator ==(Matrix4x3F left, Matrix4x3F right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3 && + left.Row4 == right.Row4; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix4x3F left, Matrix4x3F right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix4x3F operator +(Matrix4x3F left, Matrix4x3F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4); + public static Matrix4x3F operator +(Matrix4x3F left, Matrix4x3F right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3, + left.Row4 + right.Row4); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix4x3F operator -(Matrix4x3F left, Matrix4x3F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4); + public static Matrix4x3F operator -(Matrix4x3F left, Matrix4x3F right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3, + left.Row4 - right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x3F operator *(Matrix2x4F left, Matrix4x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + public static Matrix2x3F operator *(Matrix2x4F left, Matrix4x3F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x2F operator *(Matrix4x3F left, Matrix3x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + public static Matrix4x2F operator *(Matrix4x3F left, Matrix3x2F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x3F operator *(Matrix4x3F left, Matrix3x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + public static Matrix4x3F operator *(Matrix4x3F left, Matrix3x3F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x4F operator *(Matrix4x3F left, Matrix3x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + public static Matrix4x4F operator *(Matrix4x3F left, Matrix3x4F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x3I.gen.cs b/sources/Maths/Maths/Matrix4x3I.gen.cs index 90d2a59aec..662211575c 100644 --- a/sources/Maths/Maths/Matrix4x3I.gen.cs +++ b/sources/Maths/Maths/Matrix4x3I.gen.cs @@ -7,13 +7,21 @@ partial struct Matrix4x3I : IEquatable> where T : IBinaryIntege { /// The 1st row of the matrix represented as a vector. public Vector3I Row1; + /// The 2nd row of the matrix represented as a vector. public Vector3I Row2; + /// The 3rd row of the matrix represented as a vector. public Vector3I Row3; + /// The 4th row of the matrix represented as a vector. public Vector3I Row4; + + /// + /// Constructs a from the given rows. + /// public Matrix4x3I(Vector3I row1, Vector3I row2, Vector3I row3, Vector3I row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + [UnscopedRef] public ref Vector3I this[int row] { @@ -37,73 +45,121 @@ public ref Vector3I this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// Gets the element in the 4th row and 3rd column of the matrix. public T M43 => Row4.Z; + /// public override bool Equals(object? obj) => obj is Matrix4x3I other && Equals(other); + /// public bool Equals(Matrix4x3I other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix4x3I left, Matrix4x3I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + public static bool operator ==(Matrix4x3I left, Matrix4x3I right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3 && + left.Row4 == right.Row4; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix4x3I left, Matrix4x3I right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix4x3I operator +(Matrix4x3I left, Matrix4x3I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4); + public static Matrix4x3I operator +(Matrix4x3I left, Matrix4x3I right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3, + left.Row4 + right.Row4); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix4x3I operator -(Matrix4x3I left, Matrix4x3I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4); + public static Matrix4x3I operator -(Matrix4x3I left, Matrix4x3I right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3, + left.Row4 - right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x3I operator *(Matrix2x4I left, Matrix4x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + public static Matrix2x3I operator *(Matrix2x4I left, Matrix4x3I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x2I operator *(Matrix4x3I left, Matrix3x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + public static Matrix4x2I operator *(Matrix4x3I left, Matrix3x2I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x3I operator *(Matrix4x3I left, Matrix3x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + public static Matrix4x3I operator *(Matrix4x3I left, Matrix3x3I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x4I operator *(Matrix4x3I left, Matrix3x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + public static Matrix4x4I operator *(Matrix4x3I left, Matrix3x4I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x4F.gen.cs b/sources/Maths/Maths/Matrix4x4F.gen.cs index 35b3d492d2..a93bd5a9f9 100644 --- a/sources/Maths/Maths/Matrix4x4F.gen.cs +++ b/sources/Maths/Maths/Matrix4x4F.gen.cs @@ -7,13 +7,21 @@ partial struct Matrix4x4F : IEquatable> where T : IFloatingPoin { /// The 1st row of the matrix represented as a vector. public Vector4F Row1; + /// The 2nd row of the matrix represented as a vector. public Vector4F Row2; + /// The 3rd row of the matrix represented as a vector. public Vector4F Row3; + /// The 4th row of the matrix represented as a vector. public Vector4F Row4; + + /// + /// Constructs a from the given rows. + /// public Matrix4x4F(Vector4F row1, Vector4F row2, Vector4F row3, Vector4F row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + [UnscopedRef] public ref Vector4F this[int row] { @@ -37,86 +45,142 @@ public ref Vector4F this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 3rd row and 4th column of the matrix. public T M34 => Row3.W; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// Gets the element in the 4th row and 3rd column of the matrix. public T M43 => Row4.Z; + /// Gets the element in the 4th row and 4th column of the matrix. public T M44 => Row4.W; + /// public override bool Equals(object? obj) => obj is Matrix4x4F other && Equals(other); + /// public bool Equals(Matrix4x4F other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix4x4F left, Matrix4x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + public static bool operator ==(Matrix4x4F left, Matrix4x4F right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3 && + left.Row4 == right.Row4; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix4x4F left, Matrix4x4F right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix4x4F operator +(Matrix4x4F left, Matrix4x4F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4); + public static Matrix4x4F operator +(Matrix4x4F left, Matrix4x4F right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3, + left.Row4 + right.Row4); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix4x4F operator -(Matrix4x4F left, Matrix4x4F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4); + public static Matrix4x4F operator -(Matrix4x4F left, Matrix4x4F right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3, + left.Row4 - right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x4F operator *(Matrix2x4F left, Matrix4x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + public static Matrix2x4F operator *(Matrix2x4F left, Matrix4x4F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x4F operator *(Matrix3x4F left, Matrix4x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + public static Matrix3x4F operator *(Matrix3x4F left, Matrix4x4F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x2F operator *(Matrix4x4F left, Matrix4x2F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + public static Matrix4x2F operator *(Matrix4x4F left, Matrix4x2F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x3F operator *(Matrix4x4F left, Matrix4x3F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + public static Matrix4x3F operator *(Matrix4x4F left, Matrix4x3F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x4F operator *(Matrix4x4F left, Matrix4x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + public static Matrix4x4F operator *(Matrix4x4F left, Matrix4x4F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix4x4I.gen.cs b/sources/Maths/Maths/Matrix4x4I.gen.cs index 3745130e76..27db725337 100644 --- a/sources/Maths/Maths/Matrix4x4I.gen.cs +++ b/sources/Maths/Maths/Matrix4x4I.gen.cs @@ -7,13 +7,21 @@ partial struct Matrix4x4I : IEquatable> where T : IBinaryIntege { /// The 1st row of the matrix represented as a vector. public Vector4I Row1; + /// The 2nd row of the matrix represented as a vector. public Vector4I Row2; + /// The 3rd row of the matrix represented as a vector. public Vector4I Row3; + /// The 4th row of the matrix represented as a vector. public Vector4I Row4; + + /// + /// Constructs a from the given rows. + /// public Matrix4x4I(Vector4I row1, Vector4I row2, Vector4I row3, Vector4I row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + [UnscopedRef] public ref Vector4I this[int row] { @@ -37,86 +45,142 @@ public ref Vector4I this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 3rd row and 4th column of the matrix. public T M34 => Row3.W; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// Gets the element in the 4th row and 3rd column of the matrix. public T M43 => Row4.Z; + /// Gets the element in the 4th row and 4th column of the matrix. public T M44 => Row4.W; + /// public override bool Equals(object? obj) => obj is Matrix4x4I other && Equals(other); + /// public bool Equals(Matrix4x4I other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix4x4I left, Matrix4x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4; + public static bool operator ==(Matrix4x4I left, Matrix4x4I right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3 && + left.Row4 == right.Row4; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix4x4I left, Matrix4x4I right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix4x4I operator +(Matrix4x4I left, Matrix4x4I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4); + public static Matrix4x4I operator +(Matrix4x4I left, Matrix4x4I right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3, + left.Row4 + right.Row4); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix4x4I operator -(Matrix4x4I left, Matrix4x4I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4); + public static Matrix4x4I operator -(Matrix4x4I left, Matrix4x4I right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3, + left.Row4 - right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix2x4I operator *(Matrix2x4I left, Matrix4x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + public static Matrix2x4I operator *(Matrix2x4I left, Matrix4x4I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix3x4I operator *(Matrix3x4I left, Matrix4x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + public static Matrix3x4I operator *(Matrix3x4I left, Matrix4x4I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x2I operator *(Matrix4x4I left, Matrix4x2I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + public static Matrix4x2I operator *(Matrix4x4I left, Matrix4x2I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x3I operator *(Matrix4x4I left, Matrix4x3I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + public static Matrix4x3I operator *(Matrix4x4I left, Matrix4x3I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix4x4I operator *(Matrix4x4I left, Matrix4x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + public static Matrix4x4I operator *(Matrix4x4I left, Matrix4x4I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix5x4F.gen.cs b/sources/Maths/Maths/Matrix5x4F.gen.cs index efdcf0a2f8..353f89cd9d 100644 --- a/sources/Maths/Maths/Matrix5x4F.gen.cs +++ b/sources/Maths/Maths/Matrix5x4F.gen.cs @@ -7,15 +7,24 @@ partial struct Matrix5x4F : IEquatable> where T : IFloatingPoin { /// The 1st row of the matrix represented as a vector. public Vector4F Row1; + /// The 2nd row of the matrix represented as a vector. public Vector4F Row2; + /// The 3rd row of the matrix represented as a vector. public Vector4F Row3; + /// The 4th row of the matrix represented as a vector. public Vector4F Row4; + /// The 5th row of the matrix represented as a vector. public Vector4F Row5; + + /// + /// Constructs a from the given rows. + /// public Matrix5x4F(Vector4F row1, Vector4F row2, Vector4F row3, Vector4F row4, Vector4F row5) => (Row1, Row2, Row3, Row4, Row5) = (row1, row2, row3, row4, row5); + [UnscopedRef] public ref Vector4F this[int row] { @@ -41,74 +50,121 @@ public ref Vector4F this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 3rd row and 4th column of the matrix. public T M34 => Row3.W; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// Gets the element in the 4th row and 3rd column of the matrix. public T M43 => Row4.Z; + /// Gets the element in the 4th row and 4th column of the matrix. public T M44 => Row4.W; + /// Gets the element in the 5th row and 1st column of the matrix. public T M51 => Row5.X; + /// Gets the element in the 5th row and 2nd column of the matrix. public T M52 => Row5.Y; + /// Gets the element in the 5th row and 3rd column of the matrix. public T M53 => Row5.Z; + /// Gets the element in the 5th row and 4th column of the matrix. public T M54 => Row5.W; + /// public override bool Equals(object? obj) => obj is Matrix5x4F other && Equals(other); + /// public bool Equals(Matrix5x4F other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4, Row5); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix5x4F left, Matrix5x4F right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4 && left.Row5 == right.Row5; + public static bool operator ==(Matrix5x4F left, Matrix5x4F right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3 && + left.Row4 == right.Row4 && + left.Row5 == right.Row5; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix5x4F left, Matrix5x4F right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix5x4F operator +(Matrix5x4F left, Matrix5x4F right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4, left.Row5 + right.Row5); + public static Matrix5x4F operator +(Matrix5x4F left, Matrix5x4F right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3, + left.Row4 + right.Row4, + left.Row5 + right.Row5); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix5x4F operator -(Matrix5x4F left, Matrix5x4F right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4, left.Row5 - right.Row5); + public static Matrix5x4F operator -(Matrix5x4F left, Matrix5x4F right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3, + left.Row4 - right.Row4, + left.Row5 - right.Row5); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix5x4F operator *(Matrix5x4F left, Matrix4x4F right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); + public static Matrix5x4F operator *(Matrix5x4F left, Matrix4x4F right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, + left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); } } \ No newline at end of file diff --git a/sources/Maths/Maths/Matrix5x4I.gen.cs b/sources/Maths/Maths/Matrix5x4I.gen.cs index 7b794338b0..34c888afcf 100644 --- a/sources/Maths/Maths/Matrix5x4I.gen.cs +++ b/sources/Maths/Maths/Matrix5x4I.gen.cs @@ -7,15 +7,24 @@ partial struct Matrix5x4I : IEquatable> where T : IBinaryIntege { /// The 1st row of the matrix represented as a vector. public Vector4I Row1; + /// The 2nd row of the matrix represented as a vector. public Vector4I Row2; + /// The 3rd row of the matrix represented as a vector. public Vector4I Row3; + /// The 4th row of the matrix represented as a vector. public Vector4I Row4; + /// The 5th row of the matrix represented as a vector. public Vector4I Row5; + + /// + /// Constructs a from the given rows. + /// public Matrix5x4I(Vector4I row1, Vector4I row2, Vector4I row3, Vector4I row4, Vector4I row5) => (Row1, Row2, Row3, Row4, Row5) = (row1, row2, row3, row4, row5); + [UnscopedRef] public ref Vector4I this[int row] { @@ -41,74 +50,121 @@ public ref Vector4I this[int row] /// Gets the element in the 1st row and 1st column of the matrix. public T M11 => Row1.X; + /// Gets the element in the 1st row and 2nd column of the matrix. public T M12 => Row1.Y; + /// Gets the element in the 1st row and 3rd column of the matrix. public T M13 => Row1.Z; + /// Gets the element in the 1st row and 4th column of the matrix. public T M14 => Row1.W; + /// Gets the element in the 2nd row and 1st column of the matrix. public T M21 => Row2.X; + /// Gets the element in the 2nd row and 2nd column of the matrix. public T M22 => Row2.Y; + /// Gets the element in the 2nd row and 3rd column of the matrix. public T M23 => Row2.Z; + /// Gets the element in the 2nd row and 4th column of the matrix. public T M24 => Row2.W; + /// Gets the element in the 3rd row and 1st column of the matrix. public T M31 => Row3.X; + /// Gets the element in the 3rd row and 2nd column of the matrix. public T M32 => Row3.Y; + /// Gets the element in the 3rd row and 3rd column of the matrix. public T M33 => Row3.Z; + /// Gets the element in the 3rd row and 4th column of the matrix. public T M34 => Row3.W; + /// Gets the element in the 4th row and 1st column of the matrix. public T M41 => Row4.X; + /// Gets the element in the 4th row and 2nd column of the matrix. public T M42 => Row4.Y; + /// Gets the element in the 4th row and 3rd column of the matrix. public T M43 => Row4.Z; + /// Gets the element in the 4th row and 4th column of the matrix. public T M44 => Row4.W; + /// Gets the element in the 5th row and 1st column of the matrix. public T M51 => Row5.X; + /// Gets the element in the 5th row and 2nd column of the matrix. public T M52 => Row5.Y; + /// Gets the element in the 5th row and 3rd column of the matrix. public T M53 => Row5.Z; + /// Gets the element in the 5th row and 4th column of the matrix. public T M54 => Row5.W; + /// public override bool Equals(object? obj) => obj is Matrix5x4I other && Equals(other); + /// public bool Equals(Matrix5x4I other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4, Row5); + /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix5x4I left, Matrix5x4I right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && left.Row4 == right.Row4 && left.Row5 == right.Row5; + public static bool operator ==(Matrix5x4I left, Matrix5x4I right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3 && + left.Row4 == right.Row4 && + left.Row5 == right.Row5; + /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. + /// The first matrix to compare. + /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. public static bool operator !=(Matrix5x4I left, Matrix5x4I right) => !(left == right); + /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the addition. - public static Matrix5x4I operator +(Matrix5x4I left, Matrix5x4I right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, left.Row4 + right.Row4, left.Row5 + right.Row5); + public static Matrix5x4I operator +(Matrix5x4I left, Matrix5x4I right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3, + left.Row4 + right.Row4, + left.Row5 + right.Row5); + /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the subtraction. - public static Matrix5x4I operator -(Matrix5x4I left, Matrix5x4I right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, left.Row4 - right.Row4, left.Row5 - right.Row5); + public static Matrix5x4I operator -(Matrix5x4I left, Matrix5x4I right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3, + left.Row4 - right.Row4, + left.Row5 - right.Row5); + /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. + /// The first source matrix. + /// The second source matrix. /// The result of the multiplication. - public static Matrix5x4I operator *(Matrix5x4I left, Matrix4x4I right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); + public static Matrix5x4I operator *(Matrix5x4I left, Matrix4x4I right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, + left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); } } \ No newline at end of file From 91c79827a1464740349810296e3fd4b5d22e3ca9 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Fri, 30 May 2025 19:10:52 -0700 Subject: [PATCH 18/67] Added transpose, negate, and identity. --- sources/Maths/Maths/Matrix2x2F.gen.cs | 34 ++++++++++-- sources/Maths/Maths/Matrix2x2I.gen.cs | 34 ++++++++++-- sources/Maths/Maths/Matrix2x3F.gen.cs | 36 ++++++++++--- sources/Maths/Maths/Matrix2x3I.gen.cs | 36 ++++++++++--- sources/Maths/Maths/Matrix2x4F.gen.cs | 43 +++++++++++---- sources/Maths/Maths/Matrix2x4I.gen.cs | 43 +++++++++++---- sources/Maths/Maths/Matrix3x2F.gen.cs | 36 ++++++++++--- sources/Maths/Maths/Matrix3x2I.gen.cs | 36 ++++++++++--- sources/Maths/Maths/Matrix3x3F.gen.cs | 52 ++++++++++++++---- sources/Maths/Maths/Matrix3x3I.gen.cs | 52 ++++++++++++++---- sources/Maths/Maths/Matrix3x4F.gen.cs | 56 +++++++++++++++----- sources/Maths/Maths/Matrix3x4I.gen.cs | 56 +++++++++++++++----- sources/Maths/Maths/Matrix4x2F.gen.cs | 43 +++++++++++---- sources/Maths/Maths/Matrix4x2I.gen.cs | 43 +++++++++++---- sources/Maths/Maths/Matrix4x3F.gen.cs | 56 +++++++++++++++----- sources/Maths/Maths/Matrix4x3I.gen.cs | 56 +++++++++++++++----- sources/Maths/Maths/Matrix4x4F.gen.cs | 76 +++++++++++++++++++++------ sources/Maths/Maths/Matrix4x4I.gen.cs | 76 +++++++++++++++++++++------ sources/Maths/Maths/Matrix5x4F.gen.cs | 75 ++++++++++++++++++-------- sources/Maths/Maths/Matrix5x4I.gen.cs | 75 ++++++++++++++++++-------- 20 files changed, 792 insertions(+), 222 deletions(-) diff --git a/sources/Maths/Maths/Matrix2x2F.gen.cs b/sources/Maths/Maths/Matrix2x2F.gen.cs index 0f08a02fc2..8580bd92a7 100644 --- a/sources/Maths/Maths/Matrix2x2F.gen.cs +++ b/sources/Maths/Maths/Matrix2x2F.gen.cs @@ -5,6 +5,11 @@ namespace Silk.NET.Maths partial struct Matrix2x2F : IEquatable> where T : IFloatingPointIeee754 { + /// The multiplicative identity matrix of size 2x2. + public static readonly Matrix2x2F Identity = new( + new(T.MultiplicativeIdentity, T.Zero), + new(T.Zero, T.MultiplicativeIdentity)); + /// The 1st row of the matrix represented as a vector. public Vector2F Row1; @@ -33,17 +38,24 @@ public ref Vector2F this[int row] } } + [UnscopedRef] + public ref Vector2F this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// public override bool Equals(object? obj) => obj is Matrix2x2F other && Equals(other); @@ -54,6 +66,11 @@ public ref Vector2F this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Computes the transpose of the matrix. + public Matrix2x2F Transpose() => + new(new(M11, M21), + new(M12, M22)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -84,6 +101,13 @@ public ref Vector2F this[int row] new(left.Row1 - right.Row1, left.Row2 - right.Row2); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix2x2F operator -(Matrix2x2F value) => + new(-value.Row1, + -value.Row2); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -92,4 +116,4 @@ public ref Vector2F this[int row] new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix2x2I.gen.cs b/sources/Maths/Maths/Matrix2x2I.gen.cs index ecb2f945a4..7b0fa16268 100644 --- a/sources/Maths/Maths/Matrix2x2I.gen.cs +++ b/sources/Maths/Maths/Matrix2x2I.gen.cs @@ -5,6 +5,11 @@ namespace Silk.NET.Maths partial struct Matrix2x2I : IEquatable> where T : IBinaryInteger { + /// The multiplicative identity matrix of size 2x2. + public static readonly Matrix2x2I Identity = new( + new(T.MultiplicativeIdentity, T.Zero), + new(T.Zero, T.MultiplicativeIdentity)); + /// The 1st row of the matrix represented as a vector. public Vector2I Row1; @@ -33,17 +38,24 @@ public ref Vector2I this[int row] } } + [UnscopedRef] + public ref Vector2I this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// public override bool Equals(object? obj) => obj is Matrix2x2I other && Equals(other); @@ -54,6 +66,11 @@ public ref Vector2I this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Computes the transpose of the matrix. + public Matrix2x2I Transpose() => + new(new(M11, M21), + new(M12, M22)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -84,6 +101,13 @@ public ref Vector2I this[int row] new(left.Row1 - right.Row1, left.Row2 - right.Row2); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix2x2I operator -(Matrix2x2I value) => + new(-value.Row1, + -value.Row2); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -92,4 +116,4 @@ public ref Vector2I this[int row] new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix2x3F.gen.cs b/sources/Maths/Maths/Matrix2x3F.gen.cs index 4d6f920ce9..24cc8473f7 100644 --- a/sources/Maths/Maths/Matrix2x3F.gen.cs +++ b/sources/Maths/Maths/Matrix2x3F.gen.cs @@ -33,23 +33,32 @@ public ref Vector3F this[int row] } } + [UnscopedRef] + public ref Vector3F this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// public override bool Equals(object? obj) => obj is Matrix2x3F other && Equals(other); @@ -60,6 +69,12 @@ public ref Vector3F this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Computes the transpose of the matrix. + public Matrix3x2F Transpose() => + new(new(M11, M21), + new(M12, M22), + new(M13, M23)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -90,6 +105,13 @@ public ref Vector3F this[int row] new(left.Row1 - right.Row1, left.Row2 - right.Row2); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix2x3F operator -(Matrix2x3F value) => + new(-value.Row1, + -value.Row2); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -106,4 +128,4 @@ public ref Vector3F this[int row] new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix2x3I.gen.cs b/sources/Maths/Maths/Matrix2x3I.gen.cs index 83b682d83d..a231700d91 100644 --- a/sources/Maths/Maths/Matrix2x3I.gen.cs +++ b/sources/Maths/Maths/Matrix2x3I.gen.cs @@ -33,23 +33,32 @@ public ref Vector3I this[int row] } } + [UnscopedRef] + public ref Vector3I this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// public override bool Equals(object? obj) => obj is Matrix2x3I other && Equals(other); @@ -60,6 +69,12 @@ public ref Vector3I this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Computes the transpose of the matrix. + public Matrix3x2I Transpose() => + new(new(M11, M21), + new(M12, M22), + new(M13, M23)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -90,6 +105,13 @@ public ref Vector3I this[int row] new(left.Row1 - right.Row1, left.Row2 - right.Row2); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix2x3I operator -(Matrix2x3I value) => + new(-value.Row1, + -value.Row2); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -106,4 +128,4 @@ public ref Vector3I this[int row] new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix2x4F.gen.cs b/sources/Maths/Maths/Matrix2x4F.gen.cs index a310f3fabb..924c3e890b 100644 --- a/sources/Maths/Maths/Matrix2x4F.gen.cs +++ b/sources/Maths/Maths/Matrix2x4F.gen.cs @@ -33,29 +33,40 @@ public ref Vector4F this[int row] } } + [UnscopedRef] + public ref Vector4F this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 1st row and 4th column of the matrix. - public T M14 => Row1.W; + [UnscopedRef] + public ref T M14 => ref Row1.W; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// Gets the element in the 2nd row and 4th column of the matrix. - public T M24 => Row2.W; + [UnscopedRef] + public ref T M24 => ref Row2.W; /// public override bool Equals(object? obj) => obj is Matrix2x4F other && Equals(other); @@ -66,6 +77,13 @@ public ref Vector4F this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Computes the transpose of the matrix. + public Matrix4x2F Transpose() => + new(new(M11, M21), + new(M12, M22), + new(M13, M23), + new(M14, M24)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -96,6 +114,13 @@ public ref Vector4F this[int row] new(left.Row1 - right.Row1, left.Row2 - right.Row2); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix2x4F operator -(Matrix2x4F value) => + new(-value.Row1, + -value.Row2); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -121,4 +146,4 @@ public ref Vector4F this[int row] left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix2x4I.gen.cs b/sources/Maths/Maths/Matrix2x4I.gen.cs index a30c911a50..c73c789245 100644 --- a/sources/Maths/Maths/Matrix2x4I.gen.cs +++ b/sources/Maths/Maths/Matrix2x4I.gen.cs @@ -33,29 +33,40 @@ public ref Vector4I this[int row] } } + [UnscopedRef] + public ref Vector4I this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 1st row and 4th column of the matrix. - public T M14 => Row1.W; + [UnscopedRef] + public ref T M14 => ref Row1.W; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// Gets the element in the 2nd row and 4th column of the matrix. - public T M24 => Row2.W; + [UnscopedRef] + public ref T M24 => ref Row2.W; /// public override bool Equals(object? obj) => obj is Matrix2x4I other && Equals(other); @@ -66,6 +77,13 @@ public ref Vector4I this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Computes the transpose of the matrix. + public Matrix4x2I Transpose() => + new(new(M11, M21), + new(M12, M22), + new(M13, M23), + new(M14, M24)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -96,6 +114,13 @@ public ref Vector4I this[int row] new(left.Row1 - right.Row1, left.Row2 - right.Row2); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix2x4I operator -(Matrix2x4I value) => + new(-value.Row1, + -value.Row2); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -121,4 +146,4 @@ public ref Vector4I this[int row] left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix3x2F.gen.cs b/sources/Maths/Maths/Matrix3x2F.gen.cs index 42d2c7d49c..71024879d9 100644 --- a/sources/Maths/Maths/Matrix3x2F.gen.cs +++ b/sources/Maths/Maths/Matrix3x2F.gen.cs @@ -38,23 +38,32 @@ public ref Vector2F this[int row] } } + [UnscopedRef] + public ref Vector2F this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// public override bool Equals(object? obj) => obj is Matrix3x2F other && Equals(other); @@ -65,6 +74,11 @@ public ref Vector2F this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Computes the transpose of the matrix. + public Matrix2x3F Transpose() => + new(new(M11, M21, M31), + new(M12, M22, M32)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -98,6 +112,14 @@ public ref Vector2F this[int row] left.Row2 - right.Row2, left.Row3 - right.Row3); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix3x2F operator -(Matrix3x2F value) => + new(-value.Row1, + -value.Row2, + -value.Row3); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -116,4 +138,4 @@ public ref Vector2F this[int row] left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix3x2I.gen.cs b/sources/Maths/Maths/Matrix3x2I.gen.cs index 84c0054f95..51e0e01299 100644 --- a/sources/Maths/Maths/Matrix3x2I.gen.cs +++ b/sources/Maths/Maths/Matrix3x2I.gen.cs @@ -38,23 +38,32 @@ public ref Vector2I this[int row] } } + [UnscopedRef] + public ref Vector2I this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// public override bool Equals(object? obj) => obj is Matrix3x2I other && Equals(other); @@ -65,6 +74,11 @@ public ref Vector2I this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Computes the transpose of the matrix. + public Matrix2x3I Transpose() => + new(new(M11, M21, M31), + new(M12, M22, M32)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -98,6 +112,14 @@ public ref Vector2I this[int row] left.Row2 - right.Row2, left.Row3 - right.Row3); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix3x2I operator -(Matrix3x2I value) => + new(-value.Row1, + -value.Row2, + -value.Row3); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -116,4 +138,4 @@ public ref Vector2I this[int row] left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix3x3F.gen.cs b/sources/Maths/Maths/Matrix3x3F.gen.cs index 35c045ea23..7be68e7e10 100644 --- a/sources/Maths/Maths/Matrix3x3F.gen.cs +++ b/sources/Maths/Maths/Matrix3x3F.gen.cs @@ -5,6 +5,12 @@ namespace Silk.NET.Maths partial struct Matrix3x3F : IEquatable> where T : IFloatingPointIeee754 { + /// The multiplicative identity matrix of size 3x3. + public static readonly Matrix3x3F Identity = new( + new(T.MultiplicativeIdentity, T.Zero, T.Zero), + new(T.Zero, T.MultiplicativeIdentity, T.Zero), + new(T.Zero, T.Zero, T.MultiplicativeIdentity)); + /// The 1st row of the matrix represented as a vector. public Vector3F Row1; @@ -38,32 +44,44 @@ public ref Vector3F this[int row] } } + [UnscopedRef] + public ref Vector3F this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. - public T M33 => Row3.Z; + [UnscopedRef] + public ref T M33 => ref Row3.Z; /// public override bool Equals(object? obj) => obj is Matrix3x3F other && Equals(other); @@ -74,6 +92,12 @@ public ref Vector3F this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Computes the transpose of the matrix. + public Matrix3x3F Transpose() => + new(new(M11, M21, M31), + new(M12, M22, M32), + new(M13, M23, M33)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -107,6 +131,14 @@ public ref Vector3F this[int row] left.Row2 - right.Row2, left.Row3 - right.Row3); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix3x3F operator -(Matrix3x3F value) => + new(-value.Row1, + -value.Row2, + -value.Row3); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -133,4 +165,4 @@ public ref Vector3F this[int row] left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix3x3I.gen.cs b/sources/Maths/Maths/Matrix3x3I.gen.cs index b5d63fd42c..55412a04c0 100644 --- a/sources/Maths/Maths/Matrix3x3I.gen.cs +++ b/sources/Maths/Maths/Matrix3x3I.gen.cs @@ -5,6 +5,12 @@ namespace Silk.NET.Maths partial struct Matrix3x3I : IEquatable> where T : IBinaryInteger { + /// The multiplicative identity matrix of size 3x3. + public static readonly Matrix3x3I Identity = new( + new(T.MultiplicativeIdentity, T.Zero, T.Zero), + new(T.Zero, T.MultiplicativeIdentity, T.Zero), + new(T.Zero, T.Zero, T.MultiplicativeIdentity)); + /// The 1st row of the matrix represented as a vector. public Vector3I Row1; @@ -38,32 +44,44 @@ public ref Vector3I this[int row] } } + [UnscopedRef] + public ref Vector3I this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. - public T M33 => Row3.Z; + [UnscopedRef] + public ref T M33 => ref Row3.Z; /// public override bool Equals(object? obj) => obj is Matrix3x3I other && Equals(other); @@ -74,6 +92,12 @@ public ref Vector3I this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Computes the transpose of the matrix. + public Matrix3x3I Transpose() => + new(new(M11, M21, M31), + new(M12, M22, M32), + new(M13, M23, M33)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -107,6 +131,14 @@ public ref Vector3I this[int row] left.Row2 - right.Row2, left.Row3 - right.Row3); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix3x3I operator -(Matrix3x3I value) => + new(-value.Row1, + -value.Row2, + -value.Row3); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -133,4 +165,4 @@ public ref Vector3I this[int row] left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix3x4F.gen.cs b/sources/Maths/Maths/Matrix3x4F.gen.cs index 124a15c20e..902cfa787f 100644 --- a/sources/Maths/Maths/Matrix3x4F.gen.cs +++ b/sources/Maths/Maths/Matrix3x4F.gen.cs @@ -38,41 +38,56 @@ public ref Vector4F this[int row] } } + [UnscopedRef] + public ref Vector4F this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 1st row and 4th column of the matrix. - public T M14 => Row1.W; + [UnscopedRef] + public ref T M14 => ref Row1.W; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// Gets the element in the 2nd row and 4th column of the matrix. - public T M24 => Row2.W; + [UnscopedRef] + public ref T M24 => ref Row2.W; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. - public T M33 => Row3.Z; + [UnscopedRef] + public ref T M33 => ref Row3.Z; /// Gets the element in the 3rd row and 4th column of the matrix. - public T M34 => Row3.W; + [UnscopedRef] + public ref T M34 => ref Row3.W; /// public override bool Equals(object? obj) => obj is Matrix3x4F other && Equals(other); @@ -83,6 +98,13 @@ public ref Vector4F this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Computes the transpose of the matrix. + public Matrix4x3F Transpose() => + new(new(M11, M21, M31), + new(M12, M22, M32), + new(M13, M23, M33), + new(M14, M24, M34)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -116,6 +138,14 @@ public ref Vector4F this[int row] left.Row2 - right.Row2, left.Row3 - right.Row3); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix3x4F operator -(Matrix3x4F value) => + new(-value.Row1, + -value.Row2, + -value.Row3); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -151,4 +181,4 @@ public ref Vector4F this[int row] left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix3x4I.gen.cs b/sources/Maths/Maths/Matrix3x4I.gen.cs index c91be5692a..b79567801c 100644 --- a/sources/Maths/Maths/Matrix3x4I.gen.cs +++ b/sources/Maths/Maths/Matrix3x4I.gen.cs @@ -38,41 +38,56 @@ public ref Vector4I this[int row] } } + [UnscopedRef] + public ref Vector4I this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 1st row and 4th column of the matrix. - public T M14 => Row1.W; + [UnscopedRef] + public ref T M14 => ref Row1.W; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// Gets the element in the 2nd row and 4th column of the matrix. - public T M24 => Row2.W; + [UnscopedRef] + public ref T M24 => ref Row2.W; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. - public T M33 => Row3.Z; + [UnscopedRef] + public ref T M33 => ref Row3.Z; /// Gets the element in the 3rd row and 4th column of the matrix. - public T M34 => Row3.W; + [UnscopedRef] + public ref T M34 => ref Row3.W; /// public override bool Equals(object? obj) => obj is Matrix3x4I other && Equals(other); @@ -83,6 +98,13 @@ public ref Vector4I this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Computes the transpose of the matrix. + public Matrix4x3I Transpose() => + new(new(M11, M21, M31), + new(M12, M22, M32), + new(M13, M23, M33), + new(M14, M24, M34)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -116,6 +138,14 @@ public ref Vector4I this[int row] left.Row2 - right.Row2, left.Row3 - right.Row3); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix3x4I operator -(Matrix3x4I value) => + new(-value.Row1, + -value.Row2, + -value.Row3); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -151,4 +181,4 @@ public ref Vector4I this[int row] left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix4x2F.gen.cs b/sources/Maths/Maths/Matrix4x2F.gen.cs index 227a09e12c..eda549ff75 100644 --- a/sources/Maths/Maths/Matrix4x2F.gen.cs +++ b/sources/Maths/Maths/Matrix4x2F.gen.cs @@ -43,29 +43,40 @@ public ref Vector2F this[int row] } } + [UnscopedRef] + public ref Vector2F this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// Gets the element in the 4th row and 1st column of the matrix. - public T M41 => Row4.X; + [UnscopedRef] + public ref T M41 => ref Row4.X; /// Gets the element in the 4th row and 2nd column of the matrix. - public T M42 => Row4.Y; + [UnscopedRef] + public ref T M42 => ref Row4.Y; /// public override bool Equals(object? obj) => obj is Matrix4x2F other && Equals(other); @@ -76,6 +87,11 @@ public ref Vector2F this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Computes the transpose of the matrix. + public Matrix2x4F Transpose() => + new(new(M11, M21, M31, M41), + new(M12, M22, M32, M42)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -112,6 +128,15 @@ public ref Vector2F this[int row] left.Row3 - right.Row3, left.Row4 - right.Row4); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4x2F operator -(Matrix4x2F value) => + new(-value.Row1, + -value.Row2, + -value.Row3, + -value.Row4); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -142,4 +167,4 @@ public ref Vector2F this[int row] left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix4x2I.gen.cs b/sources/Maths/Maths/Matrix4x2I.gen.cs index 9d688dc387..9650f89dd0 100644 --- a/sources/Maths/Maths/Matrix4x2I.gen.cs +++ b/sources/Maths/Maths/Matrix4x2I.gen.cs @@ -43,29 +43,40 @@ public ref Vector2I this[int row] } } + [UnscopedRef] + public ref Vector2I this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// Gets the element in the 4th row and 1st column of the matrix. - public T M41 => Row4.X; + [UnscopedRef] + public ref T M41 => ref Row4.X; /// Gets the element in the 4th row and 2nd column of the matrix. - public T M42 => Row4.Y; + [UnscopedRef] + public ref T M42 => ref Row4.Y; /// public override bool Equals(object? obj) => obj is Matrix4x2I other && Equals(other); @@ -76,6 +87,11 @@ public ref Vector2I this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Computes the transpose of the matrix. + public Matrix2x4I Transpose() => + new(new(M11, M21, M31, M41), + new(M12, M22, M32, M42)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -112,6 +128,15 @@ public ref Vector2I this[int row] left.Row3 - right.Row3, left.Row4 - right.Row4); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4x2I operator -(Matrix4x2I value) => + new(-value.Row1, + -value.Row2, + -value.Row3, + -value.Row4); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -142,4 +167,4 @@ public ref Vector2I this[int row] left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix4x3F.gen.cs b/sources/Maths/Maths/Matrix4x3F.gen.cs index 28b958a85c..9ca4684385 100644 --- a/sources/Maths/Maths/Matrix4x3F.gen.cs +++ b/sources/Maths/Maths/Matrix4x3F.gen.cs @@ -43,41 +43,56 @@ public ref Vector3F this[int row] } } + [UnscopedRef] + public ref Vector3F this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. - public T M33 => Row3.Z; + [UnscopedRef] + public ref T M33 => ref Row3.Z; /// Gets the element in the 4th row and 1st column of the matrix. - public T M41 => Row4.X; + [UnscopedRef] + public ref T M41 => ref Row4.X; /// Gets the element in the 4th row and 2nd column of the matrix. - public T M42 => Row4.Y; + [UnscopedRef] + public ref T M42 => ref Row4.Y; /// Gets the element in the 4th row and 3rd column of the matrix. - public T M43 => Row4.Z; + [UnscopedRef] + public ref T M43 => ref Row4.Z; /// public override bool Equals(object? obj) => obj is Matrix4x3F other && Equals(other); @@ -88,6 +103,12 @@ public ref Vector3F this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Computes the transpose of the matrix. + public Matrix3x4F Transpose() => + new(new(M11, M21, M31, M41), + new(M12, M22, M32, M42), + new(M13, M23, M33, M43)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -124,6 +145,15 @@ public ref Vector3F this[int row] left.Row3 - right.Row3, left.Row4 - right.Row4); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4x3F operator -(Matrix4x3F value) => + new(-value.Row1, + -value.Row2, + -value.Row3, + -value.Row4); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -162,4 +192,4 @@ public ref Vector3F this[int row] left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix4x3I.gen.cs b/sources/Maths/Maths/Matrix4x3I.gen.cs index 662211575c..f6bb070cd6 100644 --- a/sources/Maths/Maths/Matrix4x3I.gen.cs +++ b/sources/Maths/Maths/Matrix4x3I.gen.cs @@ -43,41 +43,56 @@ public ref Vector3I this[int row] } } + [UnscopedRef] + public ref Vector3I this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. - public T M33 => Row3.Z; + [UnscopedRef] + public ref T M33 => ref Row3.Z; /// Gets the element in the 4th row and 1st column of the matrix. - public T M41 => Row4.X; + [UnscopedRef] + public ref T M41 => ref Row4.X; /// Gets the element in the 4th row and 2nd column of the matrix. - public T M42 => Row4.Y; + [UnscopedRef] + public ref T M42 => ref Row4.Y; /// Gets the element in the 4th row and 3rd column of the matrix. - public T M43 => Row4.Z; + [UnscopedRef] + public ref T M43 => ref Row4.Z; /// public override bool Equals(object? obj) => obj is Matrix4x3I other && Equals(other); @@ -88,6 +103,12 @@ public ref Vector3I this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Computes the transpose of the matrix. + public Matrix3x4I Transpose() => + new(new(M11, M21, M31, M41), + new(M12, M22, M32, M42), + new(M13, M23, M33, M43)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -124,6 +145,15 @@ public ref Vector3I this[int row] left.Row3 - right.Row3, left.Row4 - right.Row4); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4x3I operator -(Matrix4x3I value) => + new(-value.Row1, + -value.Row2, + -value.Row3, + -value.Row4); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -162,4 +192,4 @@ public ref Vector3I this[int row] left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix4x4F.gen.cs b/sources/Maths/Maths/Matrix4x4F.gen.cs index a93bd5a9f9..57beae3c7c 100644 --- a/sources/Maths/Maths/Matrix4x4F.gen.cs +++ b/sources/Maths/Maths/Matrix4x4F.gen.cs @@ -5,6 +5,13 @@ namespace Silk.NET.Maths partial struct Matrix4x4F : IEquatable> where T : IFloatingPointIeee754 { + /// The multiplicative identity matrix of size 4x4. + public static readonly Matrix4x4F Identity = new( + new(T.MultiplicativeIdentity, T.Zero, T.Zero, T.Zero), + new(T.Zero, T.MultiplicativeIdentity, T.Zero, T.Zero), + new(T.Zero, T.Zero, T.MultiplicativeIdentity, T.Zero), + new(T.Zero, T.Zero, T.Zero, T.MultiplicativeIdentity)); + /// The 1st row of the matrix represented as a vector. public Vector4F Row1; @@ -43,53 +50,72 @@ public ref Vector4F this[int row] } } + [UnscopedRef] + public ref Vector4F this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 1st row and 4th column of the matrix. - public T M14 => Row1.W; + [UnscopedRef] + public ref T M14 => ref Row1.W; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// Gets the element in the 2nd row and 4th column of the matrix. - public T M24 => Row2.W; + [UnscopedRef] + public ref T M24 => ref Row2.W; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. - public T M33 => Row3.Z; + [UnscopedRef] + public ref T M33 => ref Row3.Z; /// Gets the element in the 3rd row and 4th column of the matrix. - public T M34 => Row3.W; + [UnscopedRef] + public ref T M34 => ref Row3.W; /// Gets the element in the 4th row and 1st column of the matrix. - public T M41 => Row4.X; + [UnscopedRef] + public ref T M41 => ref Row4.X; /// Gets the element in the 4th row and 2nd column of the matrix. - public T M42 => Row4.Y; + [UnscopedRef] + public ref T M42 => ref Row4.Y; /// Gets the element in the 4th row and 3rd column of the matrix. - public T M43 => Row4.Z; + [UnscopedRef] + public ref T M43 => ref Row4.Z; /// Gets the element in the 4th row and 4th column of the matrix. - public T M44 => Row4.W; + [UnscopedRef] + public ref T M44 => ref Row4.W; /// public override bool Equals(object? obj) => obj is Matrix4x4F other && Equals(other); @@ -100,6 +126,13 @@ public ref Vector4F this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Computes the transpose of the matrix. + public Matrix4x4F Transpose() => + new(new(M11, M21, M31, M41), + new(M12, M22, M32, M42), + new(M13, M23, M33, M43), + new(M14, M24, M34, M44)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -136,6 +169,15 @@ public ref Vector4F this[int row] left.Row3 - right.Row3, left.Row4 - right.Row4); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4x4F operator -(Matrix4x4F value) => + new(-value.Row1, + -value.Row2, + -value.Row3, + -value.Row4); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -183,4 +225,4 @@ public ref Vector4F this[int row] left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix4x4I.gen.cs b/sources/Maths/Maths/Matrix4x4I.gen.cs index 27db725337..bcb214be32 100644 --- a/sources/Maths/Maths/Matrix4x4I.gen.cs +++ b/sources/Maths/Maths/Matrix4x4I.gen.cs @@ -5,6 +5,13 @@ namespace Silk.NET.Maths partial struct Matrix4x4I : IEquatable> where T : IBinaryInteger { + /// The multiplicative identity matrix of size 4x4. + public static readonly Matrix4x4I Identity = new( + new(T.MultiplicativeIdentity, T.Zero, T.Zero, T.Zero), + new(T.Zero, T.MultiplicativeIdentity, T.Zero, T.Zero), + new(T.Zero, T.Zero, T.MultiplicativeIdentity, T.Zero), + new(T.Zero, T.Zero, T.Zero, T.MultiplicativeIdentity)); + /// The 1st row of the matrix represented as a vector. public Vector4I Row1; @@ -43,53 +50,72 @@ public ref Vector4I this[int row] } } + [UnscopedRef] + public ref Vector4I this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 1st row and 4th column of the matrix. - public T M14 => Row1.W; + [UnscopedRef] + public ref T M14 => ref Row1.W; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// Gets the element in the 2nd row and 4th column of the matrix. - public T M24 => Row2.W; + [UnscopedRef] + public ref T M24 => ref Row2.W; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. - public T M33 => Row3.Z; + [UnscopedRef] + public ref T M33 => ref Row3.Z; /// Gets the element in the 3rd row and 4th column of the matrix. - public T M34 => Row3.W; + [UnscopedRef] + public ref T M34 => ref Row3.W; /// Gets the element in the 4th row and 1st column of the matrix. - public T M41 => Row4.X; + [UnscopedRef] + public ref T M41 => ref Row4.X; /// Gets the element in the 4th row and 2nd column of the matrix. - public T M42 => Row4.Y; + [UnscopedRef] + public ref T M42 => ref Row4.Y; /// Gets the element in the 4th row and 3rd column of the matrix. - public T M43 => Row4.Z; + [UnscopedRef] + public ref T M43 => ref Row4.Z; /// Gets the element in the 4th row and 4th column of the matrix. - public T M44 => Row4.W; + [UnscopedRef] + public ref T M44 => ref Row4.W; /// public override bool Equals(object? obj) => obj is Matrix4x4I other && Equals(other); @@ -100,6 +126,13 @@ public ref Vector4I this[int row] /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Computes the transpose of the matrix. + public Matrix4x4I Transpose() => + new(new(M11, M21, M31, M41), + new(M12, M22, M32, M42), + new(M13, M23, M33, M43), + new(M14, M24, M34, M44)) + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -136,6 +169,15 @@ public ref Vector4I this[int row] left.Row3 - right.Row3, left.Row4 - right.Row4); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4x4I operator -(Matrix4x4I value) => + new(-value.Row1, + -value.Row2, + -value.Row3, + -value.Row4); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -183,4 +225,4 @@ public ref Vector4I this[int row] left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix5x4F.gen.cs b/sources/Maths/Maths/Matrix5x4F.gen.cs index 353f89cd9d..21d92e2e86 100644 --- a/sources/Maths/Maths/Matrix5x4F.gen.cs +++ b/sources/Maths/Maths/Matrix5x4F.gen.cs @@ -48,65 +48,88 @@ public ref Vector4F this[int row] } } + [UnscopedRef] + public ref Vector4F this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 1st row and 4th column of the matrix. - public T M14 => Row1.W; + [UnscopedRef] + public ref T M14 => ref Row1.W; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// Gets the element in the 2nd row and 4th column of the matrix. - public T M24 => Row2.W; + [UnscopedRef] + public ref T M24 => ref Row2.W; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. - public T M33 => Row3.Z; + [UnscopedRef] + public ref T M33 => ref Row3.Z; /// Gets the element in the 3rd row and 4th column of the matrix. - public T M34 => Row3.W; + [UnscopedRef] + public ref T M34 => ref Row3.W; /// Gets the element in the 4th row and 1st column of the matrix. - public T M41 => Row4.X; + [UnscopedRef] + public ref T M41 => ref Row4.X; /// Gets the element in the 4th row and 2nd column of the matrix. - public T M42 => Row4.Y; + [UnscopedRef] + public ref T M42 => ref Row4.Y; /// Gets the element in the 4th row and 3rd column of the matrix. - public T M43 => Row4.Z; + [UnscopedRef] + public ref T M43 => ref Row4.Z; /// Gets the element in the 4th row and 4th column of the matrix. - public T M44 => Row4.W; + [UnscopedRef] + public ref T M44 => ref Row4.W; /// Gets the element in the 5th row and 1st column of the matrix. - public T M51 => Row5.X; + [UnscopedRef] + public ref T M51 => ref Row5.X; /// Gets the element in the 5th row and 2nd column of the matrix. - public T M52 => Row5.Y; + [UnscopedRef] + public ref T M52 => ref Row5.Y; /// Gets the element in the 5th row and 3rd column of the matrix. - public T M53 => Row5.Z; + [UnscopedRef] + public ref T M53 => ref Row5.Z; /// Gets the element in the 5th row and 4th column of the matrix. - public T M54 => Row5.W; + [UnscopedRef] + public ref T M54 => ref Row5.W; /// public override bool Equals(object? obj) => obj is Matrix5x4F other && Equals(other); @@ -156,6 +179,16 @@ public ref Vector4F this[int row] left.Row4 - right.Row4, left.Row5 - right.Row5); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix5x4F operator -(Matrix5x4F value) => + new(-value.Row1, + -value.Row2, + -value.Row3, + -value.Row4, + -value.Row5); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -167,4 +200,4 @@ public ref Vector4F this[int row] left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix5x4I.gen.cs b/sources/Maths/Maths/Matrix5x4I.gen.cs index 34c888afcf..3a6b10fc9a 100644 --- a/sources/Maths/Maths/Matrix5x4I.gen.cs +++ b/sources/Maths/Maths/Matrix5x4I.gen.cs @@ -48,65 +48,88 @@ public ref Vector4I this[int row] } } + [UnscopedRef] + public ref Vector4I this[int row, int column] => ref this[row][column]; + /// Gets the element in the 1st row and 1st column of the matrix. - public T M11 => Row1.X; + [UnscopedRef] + public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. - public T M12 => Row1.Y; + [UnscopedRef] + public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. - public T M13 => Row1.Z; + [UnscopedRef] + public ref T M13 => ref Row1.Z; /// Gets the element in the 1st row and 4th column of the matrix. - public T M14 => Row1.W; + [UnscopedRef] + public ref T M14 => ref Row1.W; /// Gets the element in the 2nd row and 1st column of the matrix. - public T M21 => Row2.X; + [UnscopedRef] + public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. - public T M22 => Row2.Y; + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. - public T M23 => Row2.Z; + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// Gets the element in the 2nd row and 4th column of the matrix. - public T M24 => Row2.W; + [UnscopedRef] + public ref T M24 => ref Row2.W; /// Gets the element in the 3rd row and 1st column of the matrix. - public T M31 => Row3.X; + [UnscopedRef] + public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. - public T M32 => Row3.Y; + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. - public T M33 => Row3.Z; + [UnscopedRef] + public ref T M33 => ref Row3.Z; /// Gets the element in the 3rd row and 4th column of the matrix. - public T M34 => Row3.W; + [UnscopedRef] + public ref T M34 => ref Row3.W; /// Gets the element in the 4th row and 1st column of the matrix. - public T M41 => Row4.X; + [UnscopedRef] + public ref T M41 => ref Row4.X; /// Gets the element in the 4th row and 2nd column of the matrix. - public T M42 => Row4.Y; + [UnscopedRef] + public ref T M42 => ref Row4.Y; /// Gets the element in the 4th row and 3rd column of the matrix. - public T M43 => Row4.Z; + [UnscopedRef] + public ref T M43 => ref Row4.Z; /// Gets the element in the 4th row and 4th column of the matrix. - public T M44 => Row4.W; + [UnscopedRef] + public ref T M44 => ref Row4.W; /// Gets the element in the 5th row and 1st column of the matrix. - public T M51 => Row5.X; + [UnscopedRef] + public ref T M51 => ref Row5.X; /// Gets the element in the 5th row and 2nd column of the matrix. - public T M52 => Row5.Y; + [UnscopedRef] + public ref T M52 => ref Row5.Y; /// Gets the element in the 5th row and 3rd column of the matrix. - public T M53 => Row5.Z; + [UnscopedRef] + public ref T M53 => ref Row5.Z; /// Gets the element in the 5th row and 4th column of the matrix. - public T M54 => Row5.W; + [UnscopedRef] + public ref T M54 => ref Row5.W; /// public override bool Equals(object? obj) => obj is Matrix5x4I other && Equals(other); @@ -156,6 +179,16 @@ public ref Vector4I this[int row] left.Row4 - right.Row4, left.Row5 - right.Row5); + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix5x4I operator -(Matrix5x4I value) => + new(-value.Row1, + -value.Row2, + -value.Row3, + -value.Row4, + -value.Row5); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -167,4 +200,4 @@ public ref Vector4I this[int row] left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); } -} \ No newline at end of file +} From 650f30b9602af33915b0c7d25b84eaca9f608991 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Fri, 30 May 2025 19:53:13 -0700 Subject: [PATCH 19/67] Added some necessary vector bits for testing. --- sources/Maths/Maths/Vector3F.gen.cs | 67 +++++++++++++++++++++++++++- sources/Maths/Maths/Vector4F.gen.cs | 68 ++++++++++++++++++++++++++++- 2 files changed, 133 insertions(+), 2 deletions(-) diff --git a/sources/Maths/Maths/Vector3F.gen.cs b/sources/Maths/Maths/Vector3F.gen.cs index e37480e2c7..91200da492 100644 --- a/sources/Maths/Maths/Vector3F.gen.cs +++ b/sources/Maths/Maths/Vector3F.gen.cs @@ -5,14 +5,79 @@ namespace Silk.NET.Maths partial struct Vector3F : IEquatable> where T : IFloatingPointIeee754 { public T X; + public T Y; + public T Z; + + public Vector3F(T x, T y, T z) => (X, Y, Z) = (x, y, z); + public static bool operator ==(Vector3F left, Vector3F right) => left.X == right.X && left.Y == right.Y && left.Z == right.Z; + public static bool operator !=(Vector3F left, Vector3F right) => !(left == right); + + /// public override bool Equals(object? obj) => obj is Vector3F other && Equals(other); + /// public bool Equals(Vector3F other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(X, Y, Z); } -} \ No newline at end of file + + static partial class Vector3F + { + public static Vector3F Log(this Vector3F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z)); + + public static Vector3F Log(this Vector3F x, Vector3F newBase) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z)); + + public static Vector3F LogP1(this Vector3F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z)); + + public static Vector3F Log2(this Vector3F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z)); + + public static Vector3F Log2P1(this Vector3F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z)); + + public static Vector3F Log10(this Vector3F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z)); + + public static Vector3F Log10P1(this Vector3F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z)); + + public static Vector3F Exp(this Vector3F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z)); + + public static Vector3F ExpM1(this Vector3F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z)); + + public static Vector3F Exp2(this Vector3F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z)); + + public static Vector3F Exp2M1(this Vector3F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z)); + + public static Vector3F Exp10(this Vector3F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z)); + + public static Vector3F Exp10M1(this Vector3F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z)); + } +} diff --git a/sources/Maths/Maths/Vector4F.gen.cs b/sources/Maths/Maths/Vector4F.gen.cs index 77defbefa4..71382c9d43 100644 --- a/sources/Maths/Maths/Vector4F.gen.cs +++ b/sources/Maths/Maths/Vector4F.gen.cs @@ -5,15 +5,81 @@ namespace Silk.NET.Maths partial struct Vector4F : IEquatable> where T : IFloatingPointIeee754 { public T X; + public T Y; + public T Z; + public T W; + + public Vector4F(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); + public static bool operator ==(Vector4F left, Vector4F right) => left.X == right.X && left.Y == right.Y && left.Z == right.Z && left.W == right.W; + public static bool operator !=(Vector4F left, Vector4F right) => !(left == right); + + /// public override bool Equals(object? obj) => obj is Vector4F other && Equals(other); + /// public bool Equals(Vector4F other) => this == other; + /// public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); } -} \ No newline at end of file + + static partial class Vector4F + { + public static Vector4F Log(this Vector4F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z), TSelf.Log(x.W)); + + public static Vector4F Log(this Vector4F x, Vector4F newBase) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z), TSelf.Log(x.W, newBase.W)); + + public static Vector4F LogP1(this Vector4F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z), TSelf.LogP1(x.W)); + + public static Vector4F Log2(this Vector4F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z), TSelf.Log2(x.W)); + + public static Vector4F Log2P1(this Vector4F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z), TSelf.Log2P1(x.W)); + + public static Vector4F Log10(this Vector4F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z), TSelf.Log10(x.W)); + + public static Vector4F Log10P1(this Vector4F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z), TSelf.Log10P1(x.W)); + + public static Vector4F Exp(this Vector4F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z), TSelf.Exp(x.W)); + + public static Vector4F ExpM1(this Vector4F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z), TSelf.ExpM1(x.W)); + + public static Vector4F Exp2(this Vector4F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z), TSelf.Exp2(x.W)); + + public static Vector4F Exp2M1(this Vector4F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z), TSelf.Exp2M1(x.W)); + + public static Vector4F Exp10(this Vector4F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z), TSelf.Exp10(x.W)); + + public static Vector4F Exp10M1(this Vector4F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z), TSelf.Exp10M1(x.W)); + } +} From 9bd27fea999dc5bf8f5e46a7662a5684a4b3b1c8 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 31 May 2025 00:27:34 -0700 Subject: [PATCH 20/67] Add Lerp and a couple of bugfixes. --- sources/Maths/Maths/Matrix2x2F.gen.cs | 12 ++++++++++-- sources/Maths/Maths/Matrix2x2I.gen.cs | 5 +++-- sources/Maths/Maths/Matrix2x3F.gen.cs | 12 ++++++++++-- sources/Maths/Maths/Matrix2x3I.gen.cs | 5 +++-- sources/Maths/Maths/Matrix2x4F.gen.cs | 12 ++++++++++-- sources/Maths/Maths/Matrix2x4I.gen.cs | 5 +++-- sources/Maths/Maths/Matrix3x2F.gen.cs | 13 +++++++++++-- sources/Maths/Maths/Matrix3x2I.gen.cs | 5 +++-- sources/Maths/Maths/Matrix3x3F.gen.cs | 13 +++++++++++-- sources/Maths/Maths/Matrix3x3I.gen.cs | 5 +++-- sources/Maths/Maths/Matrix3x4F.gen.cs | 13 +++++++++++-- sources/Maths/Maths/Matrix3x4I.gen.cs | 5 +++-- sources/Maths/Maths/Matrix4x2F.gen.cs | 14 ++++++++++++-- sources/Maths/Maths/Matrix4x2I.gen.cs | 5 +++-- sources/Maths/Maths/Matrix4x3F.gen.cs | 14 ++++++++++++-- sources/Maths/Maths/Matrix4x3I.gen.cs | 5 +++-- sources/Maths/Maths/Matrix4x4F.gen.cs | 14 ++++++++++++-- sources/Maths/Maths/Matrix4x4I.gen.cs | 5 +++-- sources/Maths/Maths/Matrix5x4F.gen.cs | 13 ++++++++++++- sources/Maths/Maths/Matrix5x4I.gen.cs | 3 ++- sources/Maths/Maths/Vector3F.gen.cs | 19 +++++++++++++++++++ sources/Maths/Maths/Vector4F.gen.cs | 21 +++++++++++++++++++++ 22 files changed, 180 insertions(+), 38 deletions(-) diff --git a/sources/Maths/Maths/Matrix2x2F.gen.cs b/sources/Maths/Maths/Matrix2x2F.gen.cs index 8580bd92a7..c62683fff5 100644 --- a/sources/Maths/Maths/Matrix2x2F.gen.cs +++ b/sources/Maths/Maths/Matrix2x2F.gen.cs @@ -39,7 +39,7 @@ public ref Vector2F this[int row] } [UnscopedRef] - public ref Vector2F this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -69,7 +69,7 @@ public ref Vector2F this[int row] /// Computes the transpose of the matrix. public Matrix2x2F Transpose() => new(new(M11, M21), - new(M12, M22)) + new(M12, M22)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -116,4 +116,12 @@ public Matrix2x2F Transpose() => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); } + + static partial class Matrix2x2F + { + public static Matrix2x2F Lerp(Matrix2x2F value1, Matrix2x2F value2, T amount) + where T : IFloatingPointIeee754 => + new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount)), + new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount))); + } } diff --git a/sources/Maths/Maths/Matrix2x2I.gen.cs b/sources/Maths/Maths/Matrix2x2I.gen.cs index 7b0fa16268..16c8a107ec 100644 --- a/sources/Maths/Maths/Matrix2x2I.gen.cs +++ b/sources/Maths/Maths/Matrix2x2I.gen.cs @@ -39,7 +39,7 @@ public ref Vector2I this[int row] } [UnscopedRef] - public ref Vector2I this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -69,7 +69,7 @@ public ref Vector2I this[int row] /// Computes the transpose of the matrix. public Matrix2x2I Transpose() => new(new(M11, M21), - new(M12, M22)) + new(M12, M22)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -116,4 +116,5 @@ public Matrix2x2I Transpose() => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); } + } diff --git a/sources/Maths/Maths/Matrix2x3F.gen.cs b/sources/Maths/Maths/Matrix2x3F.gen.cs index 24cc8473f7..cac16010eb 100644 --- a/sources/Maths/Maths/Matrix2x3F.gen.cs +++ b/sources/Maths/Maths/Matrix2x3F.gen.cs @@ -34,7 +34,7 @@ public ref Vector3F this[int row] } [UnscopedRef] - public ref Vector3F this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -73,7 +73,7 @@ public ref Vector3F this[int row] public Matrix3x2F Transpose() => new(new(M11, M21), new(M12, M22), - new(M13, M23)) + new(M13, M23)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -128,4 +128,12 @@ public Matrix3x2F Transpose() => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); } + + static partial class Matrix2x3F + { + public static Matrix2x3F Lerp(Matrix2x3F value1, Matrix2x3F value2, T amount) + where T : IFloatingPointIeee754 => + new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount)), + new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount))); + } } diff --git a/sources/Maths/Maths/Matrix2x3I.gen.cs b/sources/Maths/Maths/Matrix2x3I.gen.cs index a231700d91..6c6850f7d3 100644 --- a/sources/Maths/Maths/Matrix2x3I.gen.cs +++ b/sources/Maths/Maths/Matrix2x3I.gen.cs @@ -34,7 +34,7 @@ public ref Vector3I this[int row] } [UnscopedRef] - public ref Vector3I this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -73,7 +73,7 @@ public ref Vector3I this[int row] public Matrix3x2I Transpose() => new(new(M11, M21), new(M12, M22), - new(M13, M23)) + new(M13, M23)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -128,4 +128,5 @@ public Matrix3x2I Transpose() => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); } + } diff --git a/sources/Maths/Maths/Matrix2x4F.gen.cs b/sources/Maths/Maths/Matrix2x4F.gen.cs index 924c3e890b..39f678fdbf 100644 --- a/sources/Maths/Maths/Matrix2x4F.gen.cs +++ b/sources/Maths/Maths/Matrix2x4F.gen.cs @@ -34,7 +34,7 @@ public ref Vector4F this[int row] } [UnscopedRef] - public ref Vector4F this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -82,7 +82,7 @@ public Matrix4x2F Transpose() => new(new(M11, M21), new(M12, M22), new(M13, M23), - new(M14, M24)) + new(M14, M24)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -146,4 +146,12 @@ public Matrix4x2F Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } + + static partial class Matrix2x4F + { + public static Matrix2x4F Lerp(Matrix2x4F value1, Matrix2x4F value2, T amount) + where T : IFloatingPointIeee754 => + new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount), T.Lerp(value1.M14, value2.M14, amount)), + new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount), T.Lerp(value1.M24, value2.M24, amount))); + } } diff --git a/sources/Maths/Maths/Matrix2x4I.gen.cs b/sources/Maths/Maths/Matrix2x4I.gen.cs index c73c789245..83ccbf2915 100644 --- a/sources/Maths/Maths/Matrix2x4I.gen.cs +++ b/sources/Maths/Maths/Matrix2x4I.gen.cs @@ -34,7 +34,7 @@ public ref Vector4I this[int row] } [UnscopedRef] - public ref Vector4I this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -82,7 +82,7 @@ public Matrix4x2I Transpose() => new(new(M11, M21), new(M12, M22), new(M13, M23), - new(M14, M24)) + new(M14, M24)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -146,4 +146,5 @@ public Matrix4x2I Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } + } diff --git a/sources/Maths/Maths/Matrix3x2F.gen.cs b/sources/Maths/Maths/Matrix3x2F.gen.cs index 71024879d9..5466041d8e 100644 --- a/sources/Maths/Maths/Matrix3x2F.gen.cs +++ b/sources/Maths/Maths/Matrix3x2F.gen.cs @@ -39,7 +39,7 @@ public ref Vector2F this[int row] } [UnscopedRef] - public ref Vector2F this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -77,7 +77,7 @@ public ref Vector2F this[int row] /// Computes the transpose of the matrix. public Matrix2x3F Transpose() => new(new(M11, M21, M31), - new(M12, M22, M32)) + new(M12, M22, M32)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -138,4 +138,13 @@ public Matrix2x3F Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } + + static partial class Matrix3x2F + { + public static Matrix3x2F Lerp(Matrix3x2F value1, Matrix3x2F value2, T amount) + where T : IFloatingPointIeee754 => + new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount)), + new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount)), + new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount))); + } } diff --git a/sources/Maths/Maths/Matrix3x2I.gen.cs b/sources/Maths/Maths/Matrix3x2I.gen.cs index 51e0e01299..dd4b7655c5 100644 --- a/sources/Maths/Maths/Matrix3x2I.gen.cs +++ b/sources/Maths/Maths/Matrix3x2I.gen.cs @@ -39,7 +39,7 @@ public ref Vector2I this[int row] } [UnscopedRef] - public ref Vector2I this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -77,7 +77,7 @@ public ref Vector2I this[int row] /// Computes the transpose of the matrix. public Matrix2x3I Transpose() => new(new(M11, M21, M31), - new(M12, M22, M32)) + new(M12, M22, M32)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -138,4 +138,5 @@ public Matrix2x3I Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } + } diff --git a/sources/Maths/Maths/Matrix3x3F.gen.cs b/sources/Maths/Maths/Matrix3x3F.gen.cs index 7be68e7e10..c3415735dd 100644 --- a/sources/Maths/Maths/Matrix3x3F.gen.cs +++ b/sources/Maths/Maths/Matrix3x3F.gen.cs @@ -45,7 +45,7 @@ public ref Vector3F this[int row] } [UnscopedRef] - public ref Vector3F this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -96,7 +96,7 @@ public ref Vector3F this[int row] public Matrix3x3F Transpose() => new(new(M11, M21, M31), new(M12, M22, M32), - new(M13, M23, M33)) + new(M13, M23, M33)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -165,4 +165,13 @@ public Matrix3x3F Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); } + + static partial class Matrix3x3F + { + public static Matrix3x3F Lerp(Matrix3x3F value1, Matrix3x3F value2, T amount) + where T : IFloatingPointIeee754 => + new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount)), + new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount)), + new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount), T.Lerp(value1.M33, value2.M33, amount))); + } } diff --git a/sources/Maths/Maths/Matrix3x3I.gen.cs b/sources/Maths/Maths/Matrix3x3I.gen.cs index 55412a04c0..13c28c90e0 100644 --- a/sources/Maths/Maths/Matrix3x3I.gen.cs +++ b/sources/Maths/Maths/Matrix3x3I.gen.cs @@ -45,7 +45,7 @@ public ref Vector3I this[int row] } [UnscopedRef] - public ref Vector3I this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -96,7 +96,7 @@ public ref Vector3I this[int row] public Matrix3x3I Transpose() => new(new(M11, M21, M31), new(M12, M22, M32), - new(M13, M23, M33)) + new(M13, M23, M33)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -165,4 +165,5 @@ public Matrix3x3I Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); } + } diff --git a/sources/Maths/Maths/Matrix3x4F.gen.cs b/sources/Maths/Maths/Matrix3x4F.gen.cs index 902cfa787f..43533089d8 100644 --- a/sources/Maths/Maths/Matrix3x4F.gen.cs +++ b/sources/Maths/Maths/Matrix3x4F.gen.cs @@ -39,7 +39,7 @@ public ref Vector4F this[int row] } [UnscopedRef] - public ref Vector4F this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -103,7 +103,7 @@ public Matrix4x3F Transpose() => new(new(M11, M21, M31), new(M12, M22, M32), new(M13, M23, M33), - new(M14, M24, M34)) + new(M14, M24, M34)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -181,4 +181,13 @@ public Matrix4x3F Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); } + + static partial class Matrix3x4F + { + public static Matrix3x4F Lerp(Matrix3x4F value1, Matrix3x4F value2, T amount) + where T : IFloatingPointIeee754 => + new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount), T.Lerp(value1.M14, value2.M14, amount)), + new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount), T.Lerp(value1.M24, value2.M24, amount)), + new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount), T.Lerp(value1.M33, value2.M33, amount), T.Lerp(value1.M34, value2.M34, amount))); + } } diff --git a/sources/Maths/Maths/Matrix3x4I.gen.cs b/sources/Maths/Maths/Matrix3x4I.gen.cs index b79567801c..b67f9c975c 100644 --- a/sources/Maths/Maths/Matrix3x4I.gen.cs +++ b/sources/Maths/Maths/Matrix3x4I.gen.cs @@ -39,7 +39,7 @@ public ref Vector4I this[int row] } [UnscopedRef] - public ref Vector4I this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -103,7 +103,7 @@ public Matrix4x3I Transpose() => new(new(M11, M21, M31), new(M12, M22, M32), new(M13, M23, M33), - new(M14, M24, M34)) + new(M14, M24, M34)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -181,4 +181,5 @@ public Matrix4x3I Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); } + } diff --git a/sources/Maths/Maths/Matrix4x2F.gen.cs b/sources/Maths/Maths/Matrix4x2F.gen.cs index eda549ff75..b0857a7e97 100644 --- a/sources/Maths/Maths/Matrix4x2F.gen.cs +++ b/sources/Maths/Maths/Matrix4x2F.gen.cs @@ -44,7 +44,7 @@ public ref Vector2F this[int row] } [UnscopedRef] - public ref Vector2F this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -90,7 +90,7 @@ public ref Vector2F this[int row] /// Computes the transpose of the matrix. public Matrix2x4F Transpose() => new(new(M11, M21, M31, M41), - new(M12, M22, M32, M42)) + new(M12, M22, M32, M42)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -167,4 +167,14 @@ public Matrix2x4F Transpose() => left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); } + + static partial class Matrix4x2F + { + public static Matrix4x2F Lerp(Matrix4x2F value1, Matrix4x2F value2, T amount) + where T : IFloatingPointIeee754 => + new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount)), + new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount)), + new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount)), + new(T.Lerp(value1.M41, value2.M41, amount), T.Lerp(value1.M42, value2.M42, amount))); + } } diff --git a/sources/Maths/Maths/Matrix4x2I.gen.cs b/sources/Maths/Maths/Matrix4x2I.gen.cs index 9650f89dd0..c1a69252e8 100644 --- a/sources/Maths/Maths/Matrix4x2I.gen.cs +++ b/sources/Maths/Maths/Matrix4x2I.gen.cs @@ -44,7 +44,7 @@ public ref Vector2I this[int row] } [UnscopedRef] - public ref Vector2I this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -90,7 +90,7 @@ public ref Vector2I this[int row] /// Computes the transpose of the matrix. public Matrix2x4I Transpose() => new(new(M11, M21, M31, M41), - new(M12, M22, M32, M42)) + new(M12, M22, M32, M42)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -167,4 +167,5 @@ public Matrix2x4I Transpose() => left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); } + } diff --git a/sources/Maths/Maths/Matrix4x3F.gen.cs b/sources/Maths/Maths/Matrix4x3F.gen.cs index 9ca4684385..0c9b09f564 100644 --- a/sources/Maths/Maths/Matrix4x3F.gen.cs +++ b/sources/Maths/Maths/Matrix4x3F.gen.cs @@ -44,7 +44,7 @@ public ref Vector3F this[int row] } [UnscopedRef] - public ref Vector3F this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -107,7 +107,7 @@ public ref Vector3F this[int row] public Matrix3x4F Transpose() => new(new(M11, M21, M31, M41), new(M12, M22, M32, M42), - new(M13, M23, M33, M43)) + new(M13, M23, M33, M43)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -192,4 +192,14 @@ public Matrix3x4F Transpose() => left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); } + + static partial class Matrix4x3F + { + public static Matrix4x3F Lerp(Matrix4x3F value1, Matrix4x3F value2, T amount) + where T : IFloatingPointIeee754 => + new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount)), + new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount)), + new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount), T.Lerp(value1.M33, value2.M33, amount)), + new(T.Lerp(value1.M41, value2.M41, amount), T.Lerp(value1.M42, value2.M42, amount), T.Lerp(value1.M43, value2.M43, amount))); + } } diff --git a/sources/Maths/Maths/Matrix4x3I.gen.cs b/sources/Maths/Maths/Matrix4x3I.gen.cs index f6bb070cd6..61a169be3c 100644 --- a/sources/Maths/Maths/Matrix4x3I.gen.cs +++ b/sources/Maths/Maths/Matrix4x3I.gen.cs @@ -44,7 +44,7 @@ public ref Vector3I this[int row] } [UnscopedRef] - public ref Vector3I this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -107,7 +107,7 @@ public ref Vector3I this[int row] public Matrix3x4I Transpose() => new(new(M11, M21, M31, M41), new(M12, M22, M32, M42), - new(M13, M23, M33, M43)) + new(M13, M23, M33, M43)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -192,4 +192,5 @@ public Matrix3x4I Transpose() => left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); } + } diff --git a/sources/Maths/Maths/Matrix4x4F.gen.cs b/sources/Maths/Maths/Matrix4x4F.gen.cs index 57beae3c7c..0a0ebcd076 100644 --- a/sources/Maths/Maths/Matrix4x4F.gen.cs +++ b/sources/Maths/Maths/Matrix4x4F.gen.cs @@ -51,7 +51,7 @@ public ref Vector4F this[int row] } [UnscopedRef] - public ref Vector4F this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -131,7 +131,7 @@ public Matrix4x4F Transpose() => new(new(M11, M21, M31, M41), new(M12, M22, M32, M42), new(M13, M23, M33, M43), - new(M14, M24, M34, M44)) + new(M14, M24, M34, M44)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -225,4 +225,14 @@ public Matrix4x4F Transpose() => left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); } + + static partial class Matrix4x4F + { + public static Matrix4x4F Lerp(Matrix4x4F value1, Matrix4x4F value2, T amount) + where T : IFloatingPointIeee754 => + new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount), T.Lerp(value1.M14, value2.M14, amount)), + new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount), T.Lerp(value1.M24, value2.M24, amount)), + new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount), T.Lerp(value1.M33, value2.M33, amount), T.Lerp(value1.M34, value2.M34, amount)), + new(T.Lerp(value1.M41, value2.M41, amount), T.Lerp(value1.M42, value2.M42, amount), T.Lerp(value1.M43, value2.M43, amount), T.Lerp(value1.M44, value2.M44, amount))); + } } diff --git a/sources/Maths/Maths/Matrix4x4I.gen.cs b/sources/Maths/Maths/Matrix4x4I.gen.cs index bcb214be32..c0104e5347 100644 --- a/sources/Maths/Maths/Matrix4x4I.gen.cs +++ b/sources/Maths/Maths/Matrix4x4I.gen.cs @@ -51,7 +51,7 @@ public ref Vector4I this[int row] } [UnscopedRef] - public ref Vector4I this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -131,7 +131,7 @@ public Matrix4x4I Transpose() => new(new(M11, M21, M31, M41), new(M12, M22, M32, M42), new(M13, M23, M33, M43), - new(M14, M24, M34, M44)) + new(M14, M24, M34, M44)); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. @@ -225,4 +225,5 @@ public Matrix4x4I Transpose() => left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); } + } diff --git a/sources/Maths/Maths/Matrix5x4F.gen.cs b/sources/Maths/Maths/Matrix5x4F.gen.cs index 21d92e2e86..24eeb8e2e8 100644 --- a/sources/Maths/Maths/Matrix5x4F.gen.cs +++ b/sources/Maths/Maths/Matrix5x4F.gen.cs @@ -49,7 +49,7 @@ public ref Vector4F this[int row] } [UnscopedRef] - public ref Vector4F this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -200,4 +200,15 @@ public ref Vector4F this[int row] left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); } + + static partial class Matrix5x4F + { + public static Matrix5x4F Lerp(Matrix5x4F value1, Matrix5x4F value2, T amount) + where T : IFloatingPointIeee754 => + new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount), T.Lerp(value1.M14, value2.M14, amount)), + new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount), T.Lerp(value1.M24, value2.M24, amount)), + new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount), T.Lerp(value1.M33, value2.M33, amount), T.Lerp(value1.M34, value2.M34, amount)), + new(T.Lerp(value1.M41, value2.M41, amount), T.Lerp(value1.M42, value2.M42, amount), T.Lerp(value1.M43, value2.M43, amount), T.Lerp(value1.M44, value2.M44, amount)), + new(T.Lerp(value1.M51, value2.M51, amount), T.Lerp(value1.M52, value2.M52, amount), T.Lerp(value1.M53, value2.M53, amount), T.Lerp(value1.M54, value2.M54, amount))); + } } diff --git a/sources/Maths/Maths/Matrix5x4I.gen.cs b/sources/Maths/Maths/Matrix5x4I.gen.cs index 3a6b10fc9a..0b9a7bbf08 100644 --- a/sources/Maths/Maths/Matrix5x4I.gen.cs +++ b/sources/Maths/Maths/Matrix5x4I.gen.cs @@ -49,7 +49,7 @@ public ref Vector4I this[int row] } [UnscopedRef] - public ref Vector4I this[int row, int column] => ref this[row][column]; + public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. [UnscopedRef] @@ -200,4 +200,5 @@ public ref Vector4I this[int row] left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); } + } diff --git a/sources/Maths/Maths/Vector3F.gen.cs b/sources/Maths/Maths/Vector3F.gen.cs index 91200da492..5403e5fa56 100644 --- a/sources/Maths/Maths/Vector3F.gen.cs +++ b/sources/Maths/Maths/Vector3F.gen.cs @@ -12,6 +12,25 @@ partial struct Vector3F : IEquatable> where T : IFloatingPointIee public Vector3F(T x, T y, T z) => (X, Y, Z) = (x, y, z); + [UnscopedRef] + public ref T this[int index] + { + get + { + switch (index) + { + case 0: + return ref X; + case 1: + return ref Y; + case 2: + return ref Z; + } + + throw new ArgumentOutOfRangeException(nameof(index)); + } + } + public static bool operator ==(Vector3F left, Vector3F right) => left.X == right.X && left.Y == right.Y && left.Z == right.Z; public static bool operator !=(Vector3F left, Vector3F right) => !(left == right); diff --git a/sources/Maths/Maths/Vector4F.gen.cs b/sources/Maths/Maths/Vector4F.gen.cs index 71382c9d43..7b3050ed5a 100644 --- a/sources/Maths/Maths/Vector4F.gen.cs +++ b/sources/Maths/Maths/Vector4F.gen.cs @@ -14,6 +14,27 @@ partial struct Vector4F : IEquatable> where T : IFloatingPointIee public Vector4F(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); + [UnscopedRef] + public ref T this[int index] + { + get + { + switch (index) + { + case 0: + return ref X; + case 1: + return ref Y; + case 2: + return ref Z; + case 3: + return ref W; + } + + throw new ArgumentOutOfRangeException(nameof(index)); + } + } + public static bool operator ==(Vector4F left, Vector4F right) => left.X == right.X && left.Y == right.Y && left.Z == right.Z && left.W == right.W; public static bool operator !=(Vector4F left, Vector4F right) => !(left == right); From a617eb865bedcb80ce6fdb27e5fab1cb45822999 Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Sat, 31 May 2025 17:42:25 +1000 Subject: [PATCH 21/67] Remove `IBinaryFloatingPointIeee754` reference. --- sources/Maths/Maths/Vector2F.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/Maths/Maths/Vector2F.cs b/sources/Maths/Maths/Vector2F.cs index 26d8c13047..f5a807d4ec 100644 --- a/sources/Maths/Maths/Vector2F.cs +++ b/sources/Maths/Maths/Vector2F.cs @@ -477,7 +477,7 @@ public static explicit operator System.Numerics.Vector2(Vector2F v) => public static bool operator !=(Vector2F left, Vector2F right) => left.X != right.X || left.Y != right.Y; - // IBinaryFloatingPointIeee754 + // IFloatingPointIeee754 public static Vector2F Sqrt(Vector2F x) => new(T.Sqrt(x.X), T.Sqrt(x.Y)); From d57f94d0433b710ed59412a42196223631bf6f18 Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Sat, 31 May 2025 17:58:00 +1000 Subject: [PATCH 22/67] Make `VectorNI` Vectors use a `ref` indexer. --- sources/Maths/Maths/Vector2I.cs | 30 +++++++++++++++++++++++------- sources/Maths/Maths/Vector3I.cs | 29 ++++++++++++++++++++++------- sources/Maths/Maths/Vector4I.cs | 31 +++++++++++++++++++++++-------- 3 files changed, 68 insertions(+), 22 deletions(-) diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index 2fde654cb2..1b5f7e9d31 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -5,6 +5,7 @@ using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; @@ -65,13 +66,27 @@ public Vector2I(ReadOnlySpan values) /// The number of elements in the vector. public int Count => 2; - ///Gets the component at the specified index: 0 = X, 1 = Y. - // TODO: Make this a ref - public T this[int index] => index switch { - 0 => X, - 1 => Y, - _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1.") - }; + + /// Gets or sets the component at the specified index: 0 = X, 1 = Y. + [UnscopedRef] + public ref T this[int index] + { + get + { + switch (index) + { + case 0: + return ref X; + case 1: + return ref Y; + default: + throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1."); + } + } + } + + /// Gets the component at the specified index (). + T IReadOnlyList.this[int index] => this[index]; /// Returns a boolean indicating whether the given Object is equal to this instance. public override bool Equals(object? obj) => obj is Vector2I other && Equals(other); @@ -238,6 +253,7 @@ public void CopyTo(Span span, int startIndex) { if (startIndex < 0 || startIndex + 2 > span.Length) throw new ArgumentOutOfRangeException(nameof(startIndex)); + span[startIndex] = X; span[startIndex + 1] = Y; } diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index 9aa815c588..f8dc86aac0 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -5,6 +5,7 @@ using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; @@ -77,13 +78,27 @@ public Vector3I(ReadOnlySpan values) public int Count => 3; ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z. - // TODO: Make this a ref - public T this[int index] => index switch { - 0 => X, - 1 => Y, - 2 => Z, - _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0, 1, or 2.") - }; + [UnscopedRef] + public ref T this[int index] + { + get + { + switch (index) + { + case 0: + return ref X; + case 1: + return ref Y; + case 2: + return ref Z; + default: + throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1."); + } + } + } + + /// Gets the component at the specified index (). + T IReadOnlyList.this[int index] => this[index]; /// Returns a boolean indicating whether the given Object is equal to this instance. public override bool Equals(object? obj) => obj is Vector3I other && Equals(other); diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs index 038c4be24b..28c04301f8 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4I.cs @@ -87,14 +87,29 @@ public Vector4I(ReadOnlySpan values) public int Count => 4; ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z, 3 = W. - // TODO: Make this a ref - public T this[int index] => index switch { - 0 => X, - 1 => Y, - 2 => Z, - 3 => W, - _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0, 1, 2, or 3.") - }; + [UnscopedRef] + public ref T this[int index] + { + get + { + switch (index) + { + case 0: + return ref X; + case 1: + return ref Y; + case 2: + return ref Z; + case 3: + return ref W; + default: + throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1."); + } + } + } + + /// Gets the component at the specified index (). + T IReadOnlyList.this[int index] => this[index]; /// Returns a boolean indicating whether the given Object is equal to this instance. public override bool Equals(object? obj) => obj is Vector4I other && Equals(other); From d5a8b540b1e5dea0b1a5609b840c28c1be827527 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 31 May 2025 00:59:32 -0700 Subject: [PATCH 23/67] Use partial implementations from code gen. --- sources/Maths/Maths/Vector2F.cs | 34 +------- sources/Maths/Maths/Vector2F.gen.cs | 116 +++++++++++++++++++++++++ sources/Maths/Maths/Vector2I.cs | 35 +------- sources/Maths/Maths/Vector2I.gen.cs | 116 +++++++++++++++++++++++++ sources/Maths/Maths/Vector3F.gen.cs | 21 ++++- sources/Maths/Maths/Vector3I.cs | 39 +-------- sources/Maths/Maths/Vector3I.gen.cs | 122 ++++++++++++++++++++++++++ sources/Maths/Maths/Vector4F.gen.cs | 23 ++++- sources/Maths/Maths/Vector4I.cs | 49 +---------- sources/Maths/Maths/Vector4I.gen.cs | 128 ++++++++++++++++++++++++++++ 10 files changed, 526 insertions(+), 157 deletions(-) create mode 100644 sources/Maths/Maths/Vector2F.gen.cs create mode 100644 sources/Maths/Maths/Vector2I.gen.cs create mode 100644 sources/Maths/Maths/Vector3I.gen.cs create mode 100644 sources/Maths/Maths/Vector4I.gen.cs diff --git a/sources/Maths/Maths/Vector2F.cs b/sources/Maths/Maths/Vector2F.cs index 26d8c13047..ab01de7af5 100644 --- a/sources/Maths/Maths/Vector2F.cs +++ b/sources/Maths/Maths/Vector2F.cs @@ -14,7 +14,7 @@ namespace Silk.NET.Maths { /// A structure representing a 2D floating-point vector. - internal struct Vector2F : + internal partial struct Vector2F : IEquatable>, IReadOnlyList, ISpanFormattable, @@ -25,18 +25,9 @@ internal struct Vector2F : IFormattable where T : IFloatingPointIeee754 { - /// The X component of the vector. - public T X; - - /// The Y component of the vector. - public T Y; - /// Initializes both components to the same value. public Vector2F(T value) => (X, Y) = (value, value); - /// Initializes the vector with individual values for X and Y. - public Vector2F(T x, T y) => (X, Y) = (x, y); - /// Initializes the vector from a span of two values. public Vector2F(ReadOnlySpan values) { @@ -71,22 +62,6 @@ public Vector2F(ReadOnlySpan values) /// The number of elements in the vector. public int Count => 2; - ///Gets the component at the specified index: 0 = X, 1 = Y. - public T this[int index] => index switch { - 0 => X, - 1 => Y, - _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1.") - }; - - /// Returns a boolean indicating whether the given Object is equal to this instance. - public override bool Equals(object? obj) => obj is Vector2F other && Equals(other); - - /// Returns a boolean indicating whether the given Vector2F is equal to this instance. - public bool Equals(Vector2F other) => this == other; - - /// Returns the hash code for this instance. - public override int GetHashCode() => HashCode.Combine(X, Y); - /// Returns an enumerator that iterates through the vector components. public IEnumerator GetEnumerator() { @@ -470,13 +445,6 @@ public static explicit operator System.Numerics.Vector2(Vector2F v) => public static Vector2F operator -(Vector2F vector) => new(-vector.X, -vector.Y); - // Equality Operators - public static bool operator ==(Vector2F left, Vector2F right) => - left.X == right.X && left.Y == right.Y; - - public static bool operator !=(Vector2F left, Vector2F right) => - left.X != right.X || left.Y != right.Y; - // IBinaryFloatingPointIeee754 public static Vector2F Sqrt(Vector2F x) => new(T.Sqrt(x.X), T.Sqrt(x.Y)); diff --git a/sources/Maths/Maths/Vector2F.gen.cs b/sources/Maths/Maths/Vector2F.gen.cs new file mode 100644 index 0000000000..0598251141 --- /dev/null +++ b/sources/Maths/Maths/Vector2F.gen.cs @@ -0,0 +1,116 @@ +namespace Silk.NET.Maths +{ + using System.Diagnostics.CodeAnalysis; + using System.Numerics; + + partial struct Vector2F : IEquatable> where T : IFloatingPointIeee754 + { + /// The X component of the vector. + public T X; + + /// The Y component of the vector. + public T Y; + + /// Initializes the vector with individual component values. + public Vector2F(T x, T y) => (X, Y) = (x, y); + + /// + T IReadOnlyList.this[int index] => this[index]; + + ///Gets the component at the specified index: 0 = X, 1 = Y. + [UnscopedRef] + public ref T this[int index] + { + get + { + switch (index) + { + case 0: + return ref X; + case 1: + return ref Y; + } + + throw new ArgumentOutOfRangeException(nameof(index)); + } + } + + /// Returns a boolean indicating whether the given two vectors are equal. + /// The first vector to compare. + /// The second vector to compare. + /// true if the given vectors are equal; false otherwise. + public static bool operator ==(Vector2F left, Vector2F right) => + left.X == right.X && + left.Y == right.Y; + + /// Returns a boolean indicating whether the given two vectors are not equal. + /// The first vector to compare. + /// The second vector to compare. + /// true if the given vectors are not equal; false otherwise. + public static bool operator !=(Vector2F left, Vector2F right) => !(left == right); + + /// + public override bool Equals(object? obj) => obj is Vector2F other && Equals(other); + + /// + public bool Equals(Vector2F other) => this == other; + + /// + public override int GetHashCode() => HashCode.Combine(X, Y); + } + + static partial class Vector2F + { + public static Vector2F Log(this Vector2F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log(x.X), TSelf.Log(x.Y)); + + public static Vector2F Log(this Vector2F x, Vector2F newBase) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y)); + + public static Vector2F LogP1(this Vector2F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y)); + + public static Vector2F Log2(this Vector2F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log2(x.X), TSelf.Log2(x.Y)); + + public static Vector2F Log2P1(this Vector2F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y)); + + public static Vector2F Log10(this Vector2F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log10(x.X), TSelf.Log10(x.Y)); + + public static Vector2F Log10P1(this Vector2F x) + where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y)); + + public static Vector2F Exp(this Vector2F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp(x.X), TSelf.Exp(x.Y)); + + public static Vector2F ExpM1(this Vector2F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y)); + + public static Vector2F Exp2(this Vector2F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y)); + + public static Vector2F Exp2M1(this Vector2F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y)); + + public static Vector2F Exp10(this Vector2F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y)); + + public static Vector2F Exp10M1(this Vector2F x) + where TSelf : IFloatingPointIeee754, IExponentialFunctions => + new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y)); + } +} diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index 2fde654cb2..7defbc1030 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Maths { /// A structure representing a 2D integer vector. - internal struct Vector2I : + internal partial struct Vector2I : IEquatable>, IReadOnlyList, ISpanFormattable, @@ -22,18 +22,9 @@ internal struct Vector2I : IFormattable where T : IBinaryInteger { - /// The X component of the vector. - public T X; - - /// The Y component of the vector. - public T Y; - /// Initializes both components to the same value. public Vector2I(T value) => (X, Y) = (value, value); - /// Initializes the vector with individual values for X and Y. - public Vector2I(T x, T y) => (X, Y) = (x, y); - /// Initializes the vector from a span of two values. public Vector2I(ReadOnlySpan values) { @@ -65,23 +56,6 @@ public Vector2I(ReadOnlySpan values) /// The number of elements in the vector. public int Count => 2; - ///Gets the component at the specified index: 0 = X, 1 = Y. - // TODO: Make this a ref - public T this[int index] => index switch { - 0 => X, - 1 => Y, - _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1.") - }; - - /// Returns a boolean indicating whether the given Object is equal to this instance. - public override bool Equals(object? obj) => obj is Vector2I other && Equals(other); - - /// Returns a boolean indicating whether the given Vector2I is equal to this instance. - public bool Equals(Vector2I other) => this == other; - - /// Returns the hash code for this instance. - public override int GetHashCode() => HashCode.Combine(X, Y); - /// Returns an enumerator that iterates through the vector components. public IEnumerator GetEnumerator() { @@ -457,13 +431,6 @@ public static explicit operator System.Numerics.Vector2(Vector2I v) => public static Vector2I operator ~(Vector2I vector) => new Vector2I(~vector.X, ~vector.Y); - // Equality Operators - public static bool operator ==(Vector2I left, Vector2I right) => - left.X == right.X && left.Y == right.Y; - - public static bool operator !=(Vector2I left, Vector2I right) => - left.X != right.X || left.Y != right.Y; - // IBinaryInteger // TODO: Verify these are actually correct diff --git a/sources/Maths/Maths/Vector2I.gen.cs b/sources/Maths/Maths/Vector2I.gen.cs new file mode 100644 index 0000000000..4d4cb76295 --- /dev/null +++ b/sources/Maths/Maths/Vector2I.gen.cs @@ -0,0 +1,116 @@ +namespace Silk.NET.Maths +{ + using System.Diagnostics.CodeAnalysis; + using System.Numerics; + + partial struct Vector2I : IEquatable> where T : IBinaryInteger + { + /// The X component of the vector. + public T X; + + /// The Y component of the vector. + public T Y; + + /// Initializes the vector with individual component values. + public Vector2I(T x, T y) => (X, Y) = (x, y); + + /// + T IReadOnlyList.this[int index] => this[index]; + + ///Gets the component at the specified index: 0 = X, 1 = Y. + [UnscopedRef] + public ref T this[int index] + { + get + { + switch (index) + { + case 0: + return ref X; + case 1: + return ref Y; + } + + throw new ArgumentOutOfRangeException(nameof(index)); + } + } + + /// Returns a boolean indicating whether the given two vectors are equal. + /// The first vector to compare. + /// The second vector to compare. + /// true if the given vectors are equal; false otherwise. + public static bool operator ==(Vector2I left, Vector2I right) => + left.X == right.X && + left.Y == right.Y; + + /// Returns a boolean indicating whether the given two vectors are not equal. + /// The first vector to compare. + /// The second vector to compare. + /// true if the given vectors are not equal; false otherwise. + public static bool operator !=(Vector2I left, Vector2I right) => !(left == right); + + /// + public override bool Equals(object? obj) => obj is Vector2I other && Equals(other); + + /// + public bool Equals(Vector2I other) => this == other; + + /// + public override int GetHashCode() => HashCode.Combine(X, Y); + } + + static partial class Vector2I + { + public static Vector2I Log(this Vector2I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log(x.X), TSelf.Log(x.Y)); + + public static Vector2I Log(this Vector2I x, Vector2I newBase) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y)); + + public static Vector2I LogP1(this Vector2I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y)); + + public static Vector2I Log2(this Vector2I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log2(x.X), TSelf.Log2(x.Y)); + + public static Vector2I Log2P1(this Vector2I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y)); + + public static Vector2I Log10(this Vector2I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log10(x.X), TSelf.Log10(x.Y)); + + public static Vector2I Log10P1(this Vector2I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y)); + + public static Vector2I Exp(this Vector2I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp(x.X), TSelf.Exp(x.Y)); + + public static Vector2I ExpM1(this Vector2I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y)); + + public static Vector2I Exp2(this Vector2I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y)); + + public static Vector2I Exp2M1(this Vector2I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y)); + + public static Vector2I Exp10(this Vector2I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y)); + + public static Vector2I Exp10M1(this Vector2I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y)); + } +} diff --git a/sources/Maths/Maths/Vector3F.gen.cs b/sources/Maths/Maths/Vector3F.gen.cs index 5403e5fa56..89631e8d92 100644 --- a/sources/Maths/Maths/Vector3F.gen.cs +++ b/sources/Maths/Maths/Vector3F.gen.cs @@ -1,17 +1,23 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Vector3F : IEquatable> where T : IFloatingPointIeee754 { + /// The X component of the vector. public T X; + /// The Y component of the vector. public T Y; + /// The Z component of the vector. public T Z; + /// Initializes the vector with individual component values. public Vector3F(T x, T y, T z) => (X, Y, Z) = (x, y, z); + ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z. [UnscopedRef] public ref T this[int index] { @@ -31,8 +37,19 @@ public ref T this[int index] } } - public static bool operator ==(Vector3F left, Vector3F right) => left.X == right.X && left.Y == right.Y && left.Z == right.Z; - + /// Returns a boolean indicating whether the given two vectors are equal. + /// The first vector to compare. + /// The second vector to compare. + /// true if the given vectors are equal; false otherwise. + public static bool operator ==(Vector3F left, Vector3F right) => + left.X == right.X && + left.Y == right.Y && + left.Z == right.Z; + + /// Returns a boolean indicating whether the given two vectors are not equal. + /// The first vector to compare. + /// The second vector to compare. + /// true if the given vectors are not equal; false otherwise. public static bool operator !=(Vector3F left, Vector3F right) => !(left == right); /// diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index 9aa815c588..7417b9cf4a 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Maths { /// A structure representing a 3D integer vector. - internal struct Vector3I : + internal partial struct Vector3I : IEquatable>, IReadOnlyList, ISpanFormattable, @@ -22,21 +22,9 @@ internal struct Vector3I : IFormattable where T : IBinaryInteger { - /// The X component of the vector. - public T X; - - /// The Y component of the vector. - public T Y; - - /// The Z component of the vector. - public T Z; - /// Initializes all components to the same value. public Vector3I(T value) => (X, Y, Z) = (value, value, value); - /// Initializes the vector with individual values for X, Y and Z. - public Vector3I(T x, T y, T z) => (X, Y, Z) = (x, y, z); - /// Initializes the vector from a span of three values. public Vector3I(ReadOnlySpan values) { @@ -76,24 +64,6 @@ public Vector3I(ReadOnlySpan values) /// The number of elements in the vector. public int Count => 3; - ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z. - // TODO: Make this a ref - public T this[int index] => index switch { - 0 => X, - 1 => Y, - 2 => Z, - _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0, 1, or 2.") - }; - - /// Returns a boolean indicating whether the given Object is equal to this instance. - public override bool Equals(object? obj) => obj is Vector3I other && Equals(other); - - /// Returns a boolean indicating whether the given Vector3I is equal to this instance. - public bool Equals(Vector3I other) => this == other; - - /// Returns the hash code for this instance. - public override int GetHashCode() => HashCode.Combine(X, Y, Z); - /// Returns an enumerator that iterates through the vector components. public IEnumerator GetEnumerator() { @@ -523,13 +493,6 @@ public static explicit operator System.Numerics.Vector3(Vector3I v) => public static Vector3I operator ~(Vector3I vector) => new Vector3I(~vector.X, ~vector.Y, ~vector.Z); - // Equality Operators - public static bool operator ==(Vector3I left, Vector3I right) => - left.X == right.X && left.Y == right.Y && left.Z == right.Z; - - public static bool operator !=(Vector3I left, Vector3I right) => - left.X != right.X || left.Y != right.Y || left.Z != right.Z; - // IBinaryInteger public static Vector3I Log2(Vector3I x) => new Vector3I(T.Log2(x.X), T.Log2(x.Y), T.Log2(x.Z)); diff --git a/sources/Maths/Maths/Vector3I.gen.cs b/sources/Maths/Maths/Vector3I.gen.cs new file mode 100644 index 0000000000..6eccdb4014 --- /dev/null +++ b/sources/Maths/Maths/Vector3I.gen.cs @@ -0,0 +1,122 @@ +namespace Silk.NET.Maths +{ + using System.Diagnostics.CodeAnalysis; + using System.Numerics; + + partial struct Vector3I : IEquatable> where T : IBinaryInteger + { + /// The X component of the vector. + public T X; + + /// The Y component of the vector. + public T Y; + + /// The Z component of the vector. + public T Z; + + /// Initializes the vector with individual component values. + public Vector3I(T x, T y, T z) => (X, Y, Z) = (x, y, z); + + /// + T IReadOnlyList.this[int index] => this[index]; + + ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z. + [UnscopedRef] + public ref T this[int index] + { + get + { + switch (index) + { + case 0: + return ref X; + case 1: + return ref Y; + case 2: + return ref Z; + } + + throw new ArgumentOutOfRangeException(nameof(index)); + } + } + + /// Returns a boolean indicating whether the given two vectors are equal. + /// The first vector to compare. + /// The second vector to compare. + /// true if the given vectors are equal; false otherwise. + public static bool operator ==(Vector3I left, Vector3I right) => + left.X == right.X && + left.Y == right.Y && + left.Z == right.Z; + + /// Returns a boolean indicating whether the given two vectors are not equal. + /// The first vector to compare. + /// The second vector to compare. + /// true if the given vectors are not equal; false otherwise. + public static bool operator !=(Vector3I left, Vector3I right) => !(left == right); + + /// + public override bool Equals(object? obj) => obj is Vector3I other && Equals(other); + + /// + public bool Equals(Vector3I other) => this == other; + + /// + public override int GetHashCode() => HashCode.Combine(X, Y, Z); + } + + static partial class Vector3I + { + public static Vector3I Log(this Vector3I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z)); + + public static Vector3I Log(this Vector3I x, Vector3I newBase) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z)); + + public static Vector3I LogP1(this Vector3I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z)); + + public static Vector3I Log2(this Vector3I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z)); + + public static Vector3I Log2P1(this Vector3I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z)); + + public static Vector3I Log10(this Vector3I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z)); + + public static Vector3I Log10P1(this Vector3I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z)); + + public static Vector3I Exp(this Vector3I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z)); + + public static Vector3I ExpM1(this Vector3I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z)); + + public static Vector3I Exp2(this Vector3I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z)); + + public static Vector3I Exp2M1(this Vector3I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z)); + + public static Vector3I Exp10(this Vector3I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z)); + + public static Vector3I Exp10M1(this Vector3I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z)); + } +} diff --git a/sources/Maths/Maths/Vector4F.gen.cs b/sources/Maths/Maths/Vector4F.gen.cs index 7b3050ed5a..ca9b99b9f5 100644 --- a/sources/Maths/Maths/Vector4F.gen.cs +++ b/sources/Maths/Maths/Vector4F.gen.cs @@ -1,19 +1,26 @@ namespace Silk.NET.Maths { + using System.Diagnostics.CodeAnalysis; using System.Numerics; partial struct Vector4F : IEquatable> where T : IFloatingPointIeee754 { + /// The X component of the vector. public T X; + /// The Y component of the vector. public T Y; + /// The Z component of the vector. public T Z; + /// The W component of the vector. public T W; + /// Initializes the vector with individual component values. public Vector4F(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); + ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z, 3 = W. [UnscopedRef] public ref T this[int index] { @@ -35,8 +42,20 @@ public ref T this[int index] } } - public static bool operator ==(Vector4F left, Vector4F right) => left.X == right.X && left.Y == right.Y && left.Z == right.Z && left.W == right.W; - + /// Returns a boolean indicating whether the given two vectors are equal. + /// The first vector to compare. + /// The second vector to compare. + /// true if the given vectors are equal; false otherwise. + public static bool operator ==(Vector4F left, Vector4F right) => + left.X == right.X && + left.Y == right.Y && + left.Z == right.Z && + left.W == right.W; + + /// Returns a boolean indicating whether the given two vectors are not equal. + /// The first vector to compare. + /// The second vector to compare. + /// true if the given vectors are not equal; false otherwise. public static bool operator !=(Vector4F left, Vector4F right) => !(left == right); /// diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs index 038c4be24b..78ba2afc49 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4I.cs @@ -11,7 +11,7 @@ namespace Silk.NET.Maths { /// A structure representing a 4D integer vector. - internal struct Vector4I : + internal partial struct Vector4I : IEquatable>, IReadOnlyList, ISpanFormattable, @@ -22,24 +22,9 @@ internal struct Vector4I : IFormattable where T : IBinaryInteger { - /// The X component of the vector. - public T X; - - /// The Y component of the vector. - public T Y; - - /// The Z component of the vector. - public T Z; - - /// The W component of the vector. - public T W; - /// Initializes all components to the same value. public Vector4I(T value) => (X, Y, Z, W) = (value, value, value, value); - /// Initializes the vector with individual values for X, Y, Z and W. - public Vector4I(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); - /// Initializes the vector from a span of four values. public Vector4I(ReadOnlySpan values) { @@ -86,25 +71,6 @@ public Vector4I(ReadOnlySpan values) /// The number of elements in the vector. public int Count => 4; - ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z, 3 = W. - // TODO: Make this a ref - public T this[int index] => index switch { - 0 => X, - 1 => Y, - 2 => Z, - 3 => W, - _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0, 1, 2, or 3.") - }; - - /// Returns a boolean indicating whether the given Object is equal to this instance. - public override bool Equals(object? obj) => obj is Vector4I other && Equals(other); - - /// Returns a boolean indicating whether the given Vector4I is equal to this instance. - public bool Equals(Vector4I other) => this == other; - - /// Returns the hash code for this instance. - public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); - /// Returns an enumerator that iterates through the vector components. public IEnumerator GetEnumerator() { @@ -541,19 +507,6 @@ public static explicit operator System.Numerics.Vector4(Vector4I v) => public static Vector4I operator ~(Vector4I vector) => new Vector4I(~vector.X, ~vector.Y, ~vector.Z, ~vector.W); - // Equality Operators - public static bool operator ==(Vector4I left, Vector4I right) => - left.X == right.X && - left.Y == right.Y && - left.Z == right.Z && - left.W == right.W; - - public static bool operator !=(Vector4I left, Vector4I right) => - left.X != right.X || - left.Y != right.Y || - left.Z != right.Z || - left.W != right.W; - // IBinaryInteger public static Vector4I Log2(Vector4I x) => new Vector4I(T.Log2(x.X), T.Log2(x.Y), T.Log2(x.Z), T.Log2(x.W)); diff --git a/sources/Maths/Maths/Vector4I.gen.cs b/sources/Maths/Maths/Vector4I.gen.cs new file mode 100644 index 0000000000..e433fd0f7b --- /dev/null +++ b/sources/Maths/Maths/Vector4I.gen.cs @@ -0,0 +1,128 @@ +namespace Silk.NET.Maths +{ + using System.Diagnostics.CodeAnalysis; + using System.Numerics; + + partial struct Vector4I : IEquatable> where T : IBinaryInteger + { + /// The X component of the vector. + public T X; + + /// The Y component of the vector. + public T Y; + + /// The Z component of the vector. + public T Z; + + /// The W component of the vector. + public T W; + + /// Initializes the vector with individual component values. + public Vector4I(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); + + /// + T IReadOnlyList.this[int index] => this[index]; + + ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z, 3 = W. + [UnscopedRef] + public ref T this[int index] + { + get + { + switch (index) + { + case 0: + return ref X; + case 1: + return ref Y; + case 2: + return ref Z; + case 3: + return ref W; + } + + throw new ArgumentOutOfRangeException(nameof(index)); + } + } + + /// Returns a boolean indicating whether the given two vectors are equal. + /// The first vector to compare. + /// The second vector to compare. + /// true if the given vectors are equal; false otherwise. + public static bool operator ==(Vector4I left, Vector4I right) => + left.X == right.X && + left.Y == right.Y && + left.Z == right.Z && + left.W == right.W; + + /// Returns a boolean indicating whether the given two vectors are not equal. + /// The first vector to compare. + /// The second vector to compare. + /// true if the given vectors are not equal; false otherwise. + public static bool operator !=(Vector4I left, Vector4I right) => !(left == right); + + /// + public override bool Equals(object? obj) => obj is Vector4I other && Equals(other); + + /// + public bool Equals(Vector4I other) => this == other; + + /// + public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); + } + + static partial class Vector4I + { + public static Vector4I Log(this Vector4I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z), TSelf.Log(x.W)); + + public static Vector4I Log(this Vector4I x, Vector4I newBase) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z), TSelf.Log(x.W, newBase.W)); + + public static Vector4I LogP1(this Vector4I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z), TSelf.LogP1(x.W)); + + public static Vector4I Log2(this Vector4I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z), TSelf.Log2(x.W)); + + public static Vector4I Log2P1(this Vector4I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z), TSelf.Log2P1(x.W)); + + public static Vector4I Log10(this Vector4I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z), TSelf.Log10(x.W)); + + public static Vector4I Log10P1(this Vector4I x) + where TSelf : IBinaryInteger, ILogarithmicFunctions => + new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z), TSelf.Log10P1(x.W)); + + public static Vector4I Exp(this Vector4I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z), TSelf.Exp(x.W)); + + public static Vector4I ExpM1(this Vector4I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z), TSelf.ExpM1(x.W)); + + public static Vector4I Exp2(this Vector4I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z), TSelf.Exp2(x.W)); + + public static Vector4I Exp2M1(this Vector4I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z), TSelf.Exp2M1(x.W)); + + public static Vector4I Exp10(this Vector4I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z), TSelf.Exp10(x.W)); + + public static Vector4I Exp10M1(this Vector4I x) + where TSelf : IBinaryInteger, IExponentialFunctions => + new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z), TSelf.Exp10M1(x.W)); + } +} From 3c538bd8b77fd6296415300716d8582d3e8f685b Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Sat, 31 May 2025 18:02:15 +1000 Subject: [PATCH 24/67] Make `Vector2F` Vector use a `ref` indexer. --- sources/Maths/Maths/Vector2F.cs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/sources/Maths/Maths/Vector2F.cs b/sources/Maths/Maths/Vector2F.cs index f5a807d4ec..7085246bae 100644 --- a/sources/Maths/Maths/Vector2F.cs +++ b/sources/Maths/Maths/Vector2F.cs @@ -72,11 +72,25 @@ public Vector2F(ReadOnlySpan values) public int Count => 2; ///Gets the component at the specified index: 0 = X, 1 = Y. - public T this[int index] => index switch { - 0 => X, - 1 => Y, - _ => throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1.") - }; + [UnscopedRef] + public ref T this[int index] + { + get + { + switch (index) + { + case 0: + return ref X; + case 1: + return ref Y; + default: + throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1."); + } + } + } + + /// Gets the component at the specified index (). + T IReadOnlyList.this[int index] => this[index]; /// Returns a boolean indicating whether the given Object is equal to this instance. public override bool Equals(object? obj) => obj is Vector2F other && Equals(other); From 4f74ab3d7c9f52d23b9f0424f7240c28a9ac28f1 Mon Sep 17 00:00:00 2001 From: Tweety-lab <108560864+Tweety-lab@users.noreply.github.com> Date: Sat, 31 May 2025 18:05:07 +1000 Subject: [PATCH 25/67] Fix vector `ref` indexer exception messages. --- sources/Maths/Maths/Vector3I.cs | 2 +- sources/Maths/Maths/Vector4I.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index f8dc86aac0..5f1da1af1b 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -92,7 +92,7 @@ public ref T this[int index] case 2: return ref Z; default: - throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1."); + throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0, 1 or 2."); } } } diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs index 28c04301f8..24253f044b 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4I.cs @@ -103,7 +103,7 @@ public ref T this[int index] case 3: return ref W; default: - throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0 or 1."); + throw new ArgumentOutOfRangeException(nameof(index), "Index must be 0, 1, 2 or 3."); } } } From a4b8a6cfb1e110166d0bd26654c5443af3ba57db Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 31 May 2025 01:15:12 -0700 Subject: [PATCH 26/67] Move constructors & existing interfaces. --- sources/Maths/Maths/Matrix2x2F.gen.cs | 4 +++- sources/Maths/Maths/Matrix2x2I.gen.cs | 4 +++- sources/Maths/Maths/Matrix2x3F.gen.cs | 4 +++- sources/Maths/Maths/Matrix2x3I.gen.cs | 4 +++- sources/Maths/Maths/Matrix2x4F.gen.cs | 4 +++- sources/Maths/Maths/Matrix2x4I.gen.cs | 4 +++- sources/Maths/Maths/Matrix3x2F.gen.cs | 4 +++- sources/Maths/Maths/Matrix3x2I.gen.cs | 4 +++- sources/Maths/Maths/Matrix3x3F.gen.cs | 4 +++- sources/Maths/Maths/Matrix3x3I.gen.cs | 4 +++- sources/Maths/Maths/Matrix3x4F.gen.cs | 4 +++- sources/Maths/Maths/Matrix3x4I.gen.cs | 4 +++- sources/Maths/Maths/Matrix4x2F.gen.cs | 4 +++- sources/Maths/Maths/Matrix4x2I.gen.cs | 4 +++- sources/Maths/Maths/Matrix4x3F.gen.cs | 4 +++- sources/Maths/Maths/Matrix4x3I.gen.cs | 4 +++- sources/Maths/Maths/Matrix4x4F.gen.cs | 4 +++- sources/Maths/Maths/Matrix4x4I.gen.cs | 4 +++- sources/Maths/Maths/Matrix5x4F.gen.cs | 4 +++- sources/Maths/Maths/Matrix5x4I.gen.cs | 4 +++- sources/Maths/Maths/Vector2F.cs | 5 ----- sources/Maths/Maths/Vector2F.gen.cs | 8 +++++++- sources/Maths/Maths/Vector2I.cs | 5 ----- sources/Maths/Maths/Vector2I.gen.cs | 8 +++++++- sources/Maths/Maths/Vector3F.gen.cs | 11 ++++++++++- sources/Maths/Maths/Vector3I.cs | 5 ----- sources/Maths/Maths/Vector3I.gen.cs | 8 +++++++- sources/Maths/Maths/Vector4F.gen.cs | 11 ++++++++++- sources/Maths/Maths/Vector4I.cs | 5 ----- sources/Maths/Maths/Vector4I.gen.cs | 8 +++++++- 30 files changed, 108 insertions(+), 46 deletions(-) diff --git a/sources/Maths/Maths/Matrix2x2F.gen.cs b/sources/Maths/Maths/Matrix2x2F.gen.cs index c62683fff5..0d43a43ed1 100644 --- a/sources/Maths/Maths/Matrix2x2F.gen.cs +++ b/sources/Maths/Maths/Matrix2x2F.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix2x2F : IEquatable> where T : IFloatingPointIeee754 + partial struct Matrix2x2F : + IEquatable> + where T : IFloatingPointIeee754 { /// The multiplicative identity matrix of size 2x2. public static readonly Matrix2x2F Identity = new( diff --git a/sources/Maths/Maths/Matrix2x2I.gen.cs b/sources/Maths/Maths/Matrix2x2I.gen.cs index 16c8a107ec..662608b49d 100644 --- a/sources/Maths/Maths/Matrix2x2I.gen.cs +++ b/sources/Maths/Maths/Matrix2x2I.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix2x2I : IEquatable> where T : IBinaryInteger + partial struct Matrix2x2I : + IEquatable> + where T : IBinaryInteger { /// The multiplicative identity matrix of size 2x2. public static readonly Matrix2x2I Identity = new( diff --git a/sources/Maths/Maths/Matrix2x3F.gen.cs b/sources/Maths/Maths/Matrix2x3F.gen.cs index cac16010eb..9c946035c6 100644 --- a/sources/Maths/Maths/Matrix2x3F.gen.cs +++ b/sources/Maths/Maths/Matrix2x3F.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix2x3F : IEquatable> where T : IFloatingPointIeee754 + partial struct Matrix2x3F : + IEquatable> + where T : IFloatingPointIeee754 { /// The 1st row of the matrix represented as a vector. public Vector3F Row1; diff --git a/sources/Maths/Maths/Matrix2x3I.gen.cs b/sources/Maths/Maths/Matrix2x3I.gen.cs index 6c6850f7d3..03431eaac6 100644 --- a/sources/Maths/Maths/Matrix2x3I.gen.cs +++ b/sources/Maths/Maths/Matrix2x3I.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix2x3I : IEquatable> where T : IBinaryInteger + partial struct Matrix2x3I : + IEquatable> + where T : IBinaryInteger { /// The 1st row of the matrix represented as a vector. public Vector3I Row1; diff --git a/sources/Maths/Maths/Matrix2x4F.gen.cs b/sources/Maths/Maths/Matrix2x4F.gen.cs index 39f678fdbf..b4d4f8c6f0 100644 --- a/sources/Maths/Maths/Matrix2x4F.gen.cs +++ b/sources/Maths/Maths/Matrix2x4F.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix2x4F : IEquatable> where T : IFloatingPointIeee754 + partial struct Matrix2x4F : + IEquatable> + where T : IFloatingPointIeee754 { /// The 1st row of the matrix represented as a vector. public Vector4F Row1; diff --git a/sources/Maths/Maths/Matrix2x4I.gen.cs b/sources/Maths/Maths/Matrix2x4I.gen.cs index 83ccbf2915..e116d0b528 100644 --- a/sources/Maths/Maths/Matrix2x4I.gen.cs +++ b/sources/Maths/Maths/Matrix2x4I.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix2x4I : IEquatable> where T : IBinaryInteger + partial struct Matrix2x4I : + IEquatable> + where T : IBinaryInteger { /// The 1st row of the matrix represented as a vector. public Vector4I Row1; diff --git a/sources/Maths/Maths/Matrix3x2F.gen.cs b/sources/Maths/Maths/Matrix3x2F.gen.cs index 5466041d8e..fa7209a596 100644 --- a/sources/Maths/Maths/Matrix3x2F.gen.cs +++ b/sources/Maths/Maths/Matrix3x2F.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix3x2F : IEquatable> where T : IFloatingPointIeee754 + partial struct Matrix3x2F : + IEquatable> + where T : IFloatingPointIeee754 { /// The 1st row of the matrix represented as a vector. public Vector2F Row1; diff --git a/sources/Maths/Maths/Matrix3x2I.gen.cs b/sources/Maths/Maths/Matrix3x2I.gen.cs index dd4b7655c5..868cfc9584 100644 --- a/sources/Maths/Maths/Matrix3x2I.gen.cs +++ b/sources/Maths/Maths/Matrix3x2I.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix3x2I : IEquatable> where T : IBinaryInteger + partial struct Matrix3x2I : + IEquatable> + where T : IBinaryInteger { /// The 1st row of the matrix represented as a vector. public Vector2I Row1; diff --git a/sources/Maths/Maths/Matrix3x3F.gen.cs b/sources/Maths/Maths/Matrix3x3F.gen.cs index c3415735dd..2c94325eb2 100644 --- a/sources/Maths/Maths/Matrix3x3F.gen.cs +++ b/sources/Maths/Maths/Matrix3x3F.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix3x3F : IEquatable> where T : IFloatingPointIeee754 + partial struct Matrix3x3F : + IEquatable> + where T : IFloatingPointIeee754 { /// The multiplicative identity matrix of size 3x3. public static readonly Matrix3x3F Identity = new( diff --git a/sources/Maths/Maths/Matrix3x3I.gen.cs b/sources/Maths/Maths/Matrix3x3I.gen.cs index 13c28c90e0..3cee1adfaf 100644 --- a/sources/Maths/Maths/Matrix3x3I.gen.cs +++ b/sources/Maths/Maths/Matrix3x3I.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix3x3I : IEquatable> where T : IBinaryInteger + partial struct Matrix3x3I : + IEquatable> + where T : IBinaryInteger { /// The multiplicative identity matrix of size 3x3. public static readonly Matrix3x3I Identity = new( diff --git a/sources/Maths/Maths/Matrix3x4F.gen.cs b/sources/Maths/Maths/Matrix3x4F.gen.cs index 43533089d8..45de27a659 100644 --- a/sources/Maths/Maths/Matrix3x4F.gen.cs +++ b/sources/Maths/Maths/Matrix3x4F.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix3x4F : IEquatable> where T : IFloatingPointIeee754 + partial struct Matrix3x4F : + IEquatable> + where T : IFloatingPointIeee754 { /// The 1st row of the matrix represented as a vector. public Vector4F Row1; diff --git a/sources/Maths/Maths/Matrix3x4I.gen.cs b/sources/Maths/Maths/Matrix3x4I.gen.cs index b67f9c975c..83fba2ab2f 100644 --- a/sources/Maths/Maths/Matrix3x4I.gen.cs +++ b/sources/Maths/Maths/Matrix3x4I.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix3x4I : IEquatable> where T : IBinaryInteger + partial struct Matrix3x4I : + IEquatable> + where T : IBinaryInteger { /// The 1st row of the matrix represented as a vector. public Vector4I Row1; diff --git a/sources/Maths/Maths/Matrix4x2F.gen.cs b/sources/Maths/Maths/Matrix4x2F.gen.cs index b0857a7e97..b5d608a7e0 100644 --- a/sources/Maths/Maths/Matrix4x2F.gen.cs +++ b/sources/Maths/Maths/Matrix4x2F.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix4x2F : IEquatable> where T : IFloatingPointIeee754 + partial struct Matrix4x2F : + IEquatable> + where T : IFloatingPointIeee754 { /// The 1st row of the matrix represented as a vector. public Vector2F Row1; diff --git a/sources/Maths/Maths/Matrix4x2I.gen.cs b/sources/Maths/Maths/Matrix4x2I.gen.cs index c1a69252e8..a1d468858e 100644 --- a/sources/Maths/Maths/Matrix4x2I.gen.cs +++ b/sources/Maths/Maths/Matrix4x2I.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix4x2I : IEquatable> where T : IBinaryInteger + partial struct Matrix4x2I : + IEquatable> + where T : IBinaryInteger { /// The 1st row of the matrix represented as a vector. public Vector2I Row1; diff --git a/sources/Maths/Maths/Matrix4x3F.gen.cs b/sources/Maths/Maths/Matrix4x3F.gen.cs index 0c9b09f564..5600ad456c 100644 --- a/sources/Maths/Maths/Matrix4x3F.gen.cs +++ b/sources/Maths/Maths/Matrix4x3F.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix4x3F : IEquatable> where T : IFloatingPointIeee754 + partial struct Matrix4x3F : + IEquatable> + where T : IFloatingPointIeee754 { /// The 1st row of the matrix represented as a vector. public Vector3F Row1; diff --git a/sources/Maths/Maths/Matrix4x3I.gen.cs b/sources/Maths/Maths/Matrix4x3I.gen.cs index 61a169be3c..49b3576f0a 100644 --- a/sources/Maths/Maths/Matrix4x3I.gen.cs +++ b/sources/Maths/Maths/Matrix4x3I.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix4x3I : IEquatable> where T : IBinaryInteger + partial struct Matrix4x3I : + IEquatable> + where T : IBinaryInteger { /// The 1st row of the matrix represented as a vector. public Vector3I Row1; diff --git a/sources/Maths/Maths/Matrix4x4F.gen.cs b/sources/Maths/Maths/Matrix4x4F.gen.cs index 0a0ebcd076..9c2acdddf3 100644 --- a/sources/Maths/Maths/Matrix4x4F.gen.cs +++ b/sources/Maths/Maths/Matrix4x4F.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix4x4F : IEquatable> where T : IFloatingPointIeee754 + partial struct Matrix4x4F : + IEquatable> + where T : IFloatingPointIeee754 { /// The multiplicative identity matrix of size 4x4. public static readonly Matrix4x4F Identity = new( diff --git a/sources/Maths/Maths/Matrix4x4I.gen.cs b/sources/Maths/Maths/Matrix4x4I.gen.cs index c0104e5347..ebae4c3681 100644 --- a/sources/Maths/Maths/Matrix4x4I.gen.cs +++ b/sources/Maths/Maths/Matrix4x4I.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix4x4I : IEquatable> where T : IBinaryInteger + partial struct Matrix4x4I : + IEquatable> + where T : IBinaryInteger { /// The multiplicative identity matrix of size 4x4. public static readonly Matrix4x4I Identity = new( diff --git a/sources/Maths/Maths/Matrix5x4F.gen.cs b/sources/Maths/Maths/Matrix5x4F.gen.cs index 24eeb8e2e8..0c299fd514 100644 --- a/sources/Maths/Maths/Matrix5x4F.gen.cs +++ b/sources/Maths/Maths/Matrix5x4F.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix5x4F : IEquatable> where T : IFloatingPointIeee754 + partial struct Matrix5x4F : + IEquatable> + where T : IFloatingPointIeee754 { /// The 1st row of the matrix represented as a vector. public Vector4F Row1; diff --git a/sources/Maths/Maths/Matrix5x4I.gen.cs b/sources/Maths/Maths/Matrix5x4I.gen.cs index 0b9a7bbf08..a57e492891 100644 --- a/sources/Maths/Maths/Matrix5x4I.gen.cs +++ b/sources/Maths/Maths/Matrix5x4I.gen.cs @@ -3,7 +3,9 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix5x4I : IEquatable> where T : IBinaryInteger + partial struct Matrix5x4I : + IEquatable> + where T : IBinaryInteger { /// The 1st row of the matrix represented as a vector. public Vector4I Row1; diff --git a/sources/Maths/Maths/Vector2F.cs b/sources/Maths/Maths/Vector2F.cs index 7b32f7533b..21506767f7 100644 --- a/sources/Maths/Maths/Vector2F.cs +++ b/sources/Maths/Maths/Vector2F.cs @@ -15,8 +15,6 @@ namespace Silk.NET.Maths { /// A structure representing a 2D floating-point vector. internal partial struct Vector2F : - IEquatable>, - IReadOnlyList, ISpanFormattable, ISpanParsable>, IUtf8SpanFormattable, @@ -25,9 +23,6 @@ internal partial struct Vector2F : IFormattable where T : IFloatingPointIeee754 { - /// Initializes both components to the same value. - public Vector2F(T value) => (X, Y) = (value, value); - /// Initializes the vector from a span of two values. public Vector2F(ReadOnlySpan values) { diff --git a/sources/Maths/Maths/Vector2F.gen.cs b/sources/Maths/Maths/Vector2F.gen.cs index 0598251141..fa98f7d834 100644 --- a/sources/Maths/Maths/Vector2F.gen.cs +++ b/sources/Maths/Maths/Vector2F.gen.cs @@ -3,7 +3,10 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Vector2F : IEquatable> where T : IFloatingPointIeee754 + partial struct Vector2F : + IEquatable>, + IReadOnlyList + where T : IFloatingPointIeee754 { /// The X component of the vector. public T X; @@ -11,6 +14,9 @@ partial struct Vector2F : IEquatable> where T : IFloatingPointIee /// The Y component of the vector. public T Y; + /// Initializes all components of the vector to the same value. + public Vector2F(T value) => (X, Y) = (value, value); + /// Initializes the vector with individual component values. public Vector2F(T x, T y) => (X, Y) = (x, y); diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index fe3c8316c8..b8865ad065 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -13,8 +13,6 @@ namespace Silk.NET.Maths { /// A structure representing a 2D integer vector. internal partial struct Vector2I : - IEquatable>, - IReadOnlyList, ISpanFormattable, ISpanParsable>, IUtf8SpanFormattable, @@ -23,9 +21,6 @@ internal partial struct Vector2I : IFormattable where T : IBinaryInteger { - /// Initializes both components to the same value. - public Vector2I(T value) => (X, Y) = (value, value); - /// Initializes the vector from a span of two values. public Vector2I(ReadOnlySpan values) { diff --git a/sources/Maths/Maths/Vector2I.gen.cs b/sources/Maths/Maths/Vector2I.gen.cs index 4d4cb76295..92bb8715a1 100644 --- a/sources/Maths/Maths/Vector2I.gen.cs +++ b/sources/Maths/Maths/Vector2I.gen.cs @@ -3,7 +3,10 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Vector2I : IEquatable> where T : IBinaryInteger + partial struct Vector2I : + IEquatable>, + IReadOnlyList + where T : IBinaryInteger { /// The X component of the vector. public T X; @@ -11,6 +14,9 @@ partial struct Vector2I : IEquatable> where T : IBinaryInteger /// The Y component of the vector. public T Y; + /// Initializes all components of the vector to the same value. + public Vector2I(T value) => (X, Y) = (value, value); + /// Initializes the vector with individual component values. public Vector2I(T x, T y) => (X, Y) = (x, y); diff --git a/sources/Maths/Maths/Vector3F.gen.cs b/sources/Maths/Maths/Vector3F.gen.cs index 89631e8d92..00b3a4cc63 100644 --- a/sources/Maths/Maths/Vector3F.gen.cs +++ b/sources/Maths/Maths/Vector3F.gen.cs @@ -3,7 +3,10 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Vector3F : IEquatable> where T : IFloatingPointIeee754 + partial struct Vector3F : + IEquatable>, + IReadOnlyList + where T : IFloatingPointIeee754 { /// The X component of the vector. public T X; @@ -14,9 +17,15 @@ partial struct Vector3F : IEquatable> where T : IFloatingPointIee /// The Z component of the vector. public T Z; + /// Initializes all components of the vector to the same value. + public Vector3F(T value) => (X, Y, Z) = (value, value, value); + /// Initializes the vector with individual component values. public Vector3F(T x, T y, T z) => (X, Y, Z) = (x, y, z); + /// + T IReadOnlyList.this[int index] => this[index]; + ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z. [UnscopedRef] public ref T this[int index] diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index 58c4bc0169..77c5e07e18 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -13,8 +13,6 @@ namespace Silk.NET.Maths { /// A structure representing a 3D integer vector. internal partial struct Vector3I : - IEquatable>, - IReadOnlyList, ISpanFormattable, ISpanParsable>, IUtf8SpanFormattable, @@ -23,9 +21,6 @@ internal partial struct Vector3I : IFormattable where T : IBinaryInteger { - /// Initializes all components to the same value. - public Vector3I(T value) => (X, Y, Z) = (value, value, value); - /// Initializes the vector from a span of three values. public Vector3I(ReadOnlySpan values) { diff --git a/sources/Maths/Maths/Vector3I.gen.cs b/sources/Maths/Maths/Vector3I.gen.cs index 6eccdb4014..e159c50087 100644 --- a/sources/Maths/Maths/Vector3I.gen.cs +++ b/sources/Maths/Maths/Vector3I.gen.cs @@ -3,7 +3,10 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Vector3I : IEquatable> where T : IBinaryInteger + partial struct Vector3I : + IEquatable>, + IReadOnlyList + where T : IBinaryInteger { /// The X component of the vector. public T X; @@ -14,6 +17,9 @@ partial struct Vector3I : IEquatable> where T : IBinaryInteger /// The Z component of the vector. public T Z; + /// Initializes all components of the vector to the same value. + public Vector3I(T value) => (X, Y, Z) = (value, value, value); + /// Initializes the vector with individual component values. public Vector3I(T x, T y, T z) => (X, Y, Z) = (x, y, z); diff --git a/sources/Maths/Maths/Vector4F.gen.cs b/sources/Maths/Maths/Vector4F.gen.cs index ca9b99b9f5..d1004c6a31 100644 --- a/sources/Maths/Maths/Vector4F.gen.cs +++ b/sources/Maths/Maths/Vector4F.gen.cs @@ -3,7 +3,10 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Vector4F : IEquatable> where T : IFloatingPointIeee754 + partial struct Vector4F : + IEquatable>, + IReadOnlyList + where T : IFloatingPointIeee754 { /// The X component of the vector. public T X; @@ -17,9 +20,15 @@ partial struct Vector4F : IEquatable> where T : IFloatingPointIee /// The W component of the vector. public T W; + /// Initializes all components of the vector to the same value. + public Vector4F(T value) => (X, Y, Z, W) = (value, value, value, value); + /// Initializes the vector with individual component values. public Vector4F(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); + /// + T IReadOnlyList.this[int index] => this[index]; + ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z, 3 = W. [UnscopedRef] public ref T this[int index] diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs index 78ba2afc49..9abf6fb972 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4I.cs @@ -12,8 +12,6 @@ namespace Silk.NET.Maths { /// A structure representing a 4D integer vector. internal partial struct Vector4I : - IEquatable>, - IReadOnlyList, ISpanFormattable, ISpanParsable>, IUtf8SpanFormattable, @@ -22,9 +20,6 @@ internal partial struct Vector4I : IFormattable where T : IBinaryInteger { - /// Initializes all components to the same value. - public Vector4I(T value) => (X, Y, Z, W) = (value, value, value, value); - /// Initializes the vector from a span of four values. public Vector4I(ReadOnlySpan values) { diff --git a/sources/Maths/Maths/Vector4I.gen.cs b/sources/Maths/Maths/Vector4I.gen.cs index e433fd0f7b..88e6dce282 100644 --- a/sources/Maths/Maths/Vector4I.gen.cs +++ b/sources/Maths/Maths/Vector4I.gen.cs @@ -3,7 +3,10 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Vector4I : IEquatable> where T : IBinaryInteger + partial struct Vector4I : + IEquatable>, + IReadOnlyList + where T : IBinaryInteger { /// The X component of the vector. public T X; @@ -17,6 +20,9 @@ partial struct Vector4I : IEquatable> where T : IBinaryInteger /// The W component of the vector. public T W; + /// Initializes all components of the vector to the same value. + public Vector4I(T value) => (X, Y, Z, W) = (value, value, value, value); + /// Initializes the vector with individual component values. public Vector4I(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); From 5a82141a4663aa2f66e760bb5ffc0a9fcd0b688d Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 31 May 2025 01:25:48 -0700 Subject: [PATCH 27/67] IReadOnlyList code gen. --- sources/Maths/Maths/Vector2F.cs | 13 ------------- sources/Maths/Maths/Vector2F.gen.cs | 14 ++++++++++++++ sources/Maths/Maths/Vector2I.cs | 13 ------------- sources/Maths/Maths/Vector2I.gen.cs | 14 ++++++++++++++ sources/Maths/Maths/Vector3F.gen.cs | 15 +++++++++++++++ sources/Maths/Maths/Vector3I.cs | 14 -------------- sources/Maths/Maths/Vector3I.gen.cs | 15 +++++++++++++++ sources/Maths/Maths/Vector4F.gen.cs | 16 ++++++++++++++++ sources/Maths/Maths/Vector4I.cs | 15 --------------- sources/Maths/Maths/Vector4I.gen.cs | 16 ++++++++++++++++ 10 files changed, 90 insertions(+), 55 deletions(-) diff --git a/sources/Maths/Maths/Vector2F.cs b/sources/Maths/Maths/Vector2F.cs index 21506767f7..10c855434b 100644 --- a/sources/Maths/Maths/Vector2F.cs +++ b/sources/Maths/Maths/Vector2F.cs @@ -54,16 +54,6 @@ public Vector2F(ReadOnlySpan values) /// Gets the length of the vector. public T Length => T.Sqrt(LengthSquared); - /// The number of elements in the vector. - public int Count => 2; - - /// Returns an enumerator that iterates through the vector components. - public IEnumerator GetEnumerator() - { - yield return X; - yield return Y; - } - /// Computes the dot product of this vector with another vector. public T Dot(Vector2F other) => (X * other.X) + (Y * other.Y); @@ -335,9 +325,6 @@ static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatPro static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => TryParse(s, provider, out result); - /// Returns an enumerator that iterates through the vector components. - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - /// Formats the vector as a UTF-8 string using the specified format and format provider. public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) { diff --git a/sources/Maths/Maths/Vector2F.gen.cs b/sources/Maths/Maths/Vector2F.gen.cs index fa98f7d834..34d27f31f1 100644 --- a/sources/Maths/Maths/Vector2F.gen.cs +++ b/sources/Maths/Maths/Vector2F.gen.cs @@ -1,5 +1,6 @@ namespace Silk.NET.Maths { + using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; @@ -41,6 +42,19 @@ public ref T this[int index] } } + /// The number of elements in the vector. + public int Count => 2; + + /// + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// Returns an enumerator that iterates through the vector components. + public IEnumerator GetEnumerator() + { + yield return X; + yield return Y; + } + /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index b8865ad065..2a49a846b5 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -49,16 +49,6 @@ public Vector2I(ReadOnlySpan values) /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => (X * X) + (Y * Y); - /// The number of elements in the vector. - public int Count => 2; - - /// Returns an enumerator that iterates through the vector components. - public IEnumerator GetEnumerator() - { - yield return X; - yield return Y; - } - /// Computes the dot product of this vector with another vector. public T Dot(Vector2I other) => (X * other.X) + (Y * other.Y); @@ -288,9 +278,6 @@ static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatPro static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => TryParse(s, provider, out result); - /// Returns an enumerator that iterates through the vector components. - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - /// Formats the vector as a UTF-8 string using the specified format and format provider. public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) { diff --git a/sources/Maths/Maths/Vector2I.gen.cs b/sources/Maths/Maths/Vector2I.gen.cs index 92bb8715a1..c8631934e7 100644 --- a/sources/Maths/Maths/Vector2I.gen.cs +++ b/sources/Maths/Maths/Vector2I.gen.cs @@ -1,5 +1,6 @@ namespace Silk.NET.Maths { + using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; @@ -41,6 +42,19 @@ public ref T this[int index] } } + /// The number of elements in the vector. + public int Count => 2; + + /// + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// Returns an enumerator that iterates through the vector components. + public IEnumerator GetEnumerator() + { + yield return X; + yield return Y; + } + /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. diff --git a/sources/Maths/Maths/Vector3F.gen.cs b/sources/Maths/Maths/Vector3F.gen.cs index 00b3a4cc63..93b997b6e1 100644 --- a/sources/Maths/Maths/Vector3F.gen.cs +++ b/sources/Maths/Maths/Vector3F.gen.cs @@ -1,5 +1,6 @@ namespace Silk.NET.Maths { + using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; @@ -46,6 +47,20 @@ public ref T this[int index] } } + /// The number of elements in the vector. + public int Count => 3; + + /// + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// Returns an enumerator that iterates through the vector components. + public IEnumerator GetEnumerator() + { + yield return X; + yield return Y; + yield return Z; + } + /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index 77c5e07e18..ac7a810b7d 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -57,17 +57,6 @@ public Vector3I(ReadOnlySpan values) /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => (X * X) + (Y * Y) + (Z * Z); - /// The number of elements in the vector. - public int Count => 3; - - /// Returns an enumerator that iterates through the vector components. - public IEnumerator GetEnumerator() - { - yield return X; - yield return Y; - yield return Z; - } - /// Computes the dot product of this vector with another vector. public T Dot(Vector3I other) => (X * other.X) + (Y * other.Y) + (Z * other.Z); @@ -345,9 +334,6 @@ static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatPro static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => TryParse(s, provider, out result); - /// Returns an enumerator that iterates through the vector components. - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - /// Formats the vector as a UTF-8 string using the specified format and format provider. public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) { diff --git a/sources/Maths/Maths/Vector3I.gen.cs b/sources/Maths/Maths/Vector3I.gen.cs index e159c50087..45ee97e364 100644 --- a/sources/Maths/Maths/Vector3I.gen.cs +++ b/sources/Maths/Maths/Vector3I.gen.cs @@ -1,5 +1,6 @@ namespace Silk.NET.Maths { + using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; @@ -46,6 +47,20 @@ public ref T this[int index] } } + /// The number of elements in the vector. + public int Count => 3; + + /// + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// Returns an enumerator that iterates through the vector components. + public IEnumerator GetEnumerator() + { + yield return X; + yield return Y; + yield return Z; + } + /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. diff --git a/sources/Maths/Maths/Vector4F.gen.cs b/sources/Maths/Maths/Vector4F.gen.cs index d1004c6a31..871162afc5 100644 --- a/sources/Maths/Maths/Vector4F.gen.cs +++ b/sources/Maths/Maths/Vector4F.gen.cs @@ -1,5 +1,6 @@ namespace Silk.NET.Maths { + using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; @@ -51,6 +52,21 @@ public ref T this[int index] } } + /// The number of elements in the vector. + public int Count => 4; + + /// + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// Returns an enumerator that iterates through the vector components. + public IEnumerator GetEnumerator() + { + yield return X; + yield return Y; + yield return Z; + yield return W; + } + /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs index 9abf6fb972..2386d7c797 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4I.cs @@ -63,18 +63,6 @@ public Vector4I(ReadOnlySpan values) /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => (X * X) + (Y * Y) + (Z * Z) + (W * W); - /// The number of elements in the vector. - public int Count => 4; - - /// Returns an enumerator that iterates through the vector components. - public IEnumerator GetEnumerator() - { - yield return X; - yield return Y; - yield return Z; - yield return W; - } - /// Computes the dot product of this vector with another vector. public T Dot(Vector4I other) => (X * other.X) + (Y * other.Y) + (Z * other.Z) + (W * other.W); @@ -353,9 +341,6 @@ static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatPro static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => TryParse(s, provider, out result); - /// Returns an enumerator that iterates through the vector components. - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - /// Formats the vector as a UTF-8 string using the specified format and format provider. public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) { diff --git a/sources/Maths/Maths/Vector4I.gen.cs b/sources/Maths/Maths/Vector4I.gen.cs index 88e6dce282..ef2d344376 100644 --- a/sources/Maths/Maths/Vector4I.gen.cs +++ b/sources/Maths/Maths/Vector4I.gen.cs @@ -1,5 +1,6 @@ namespace Silk.NET.Maths { + using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; @@ -51,6 +52,21 @@ public ref T this[int index] } } + /// The number of elements in the vector. + public int Count => 4; + + /// + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + /// Returns an enumerator that iterates through the vector components. + public IEnumerator GetEnumerator() + { + yield return X; + yield return Y; + yield return Z; + yield return W; + } + /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. From 16e68e2b432d3f118ee8720b7bf32071bf1f1ec0 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 31 May 2025 01:31:24 -0700 Subject: [PATCH 28/67] Fix errors with Quaternion accessibility. --- sources/Maths/Maths/Quaternion.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/Maths/Maths/Quaternion.cs b/sources/Maths/Maths/Quaternion.cs index 4df87b736a..cbc9253039 100644 --- a/sources/Maths/Maths/Quaternion.cs +++ b/sources/Maths/Maths/Quaternion.cs @@ -13,9 +13,9 @@ namespace Silk.NET.Maths /// /// Represents a four-dimensional vector used to encode 3D rotations. /// - internal struct Quaternion : + public struct Quaternion : IEquatable> - where T : IBinaryFloatingPointIeee754 + where T : IFloatingPointIeee754 { /// Specifies the X-value of the vector component of the Quaternion. public T X; From 0cb1569788dadca8dc3cabbc2b93036f3c152e69 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 31 May 2025 11:41:17 -0700 Subject: [PATCH 29/67] Move common operators and interfaces into templates. --- sources/Maths/Maths/Vector2F.cs | 257 +------------------- sources/Maths/Maths/Vector2F.gen.cs | 263 ++++++++++++++++++++- sources/Maths/Maths/Vector2I.cs | 300 +----------------------- sources/Maths/Maths/Vector2I.gen.cs | 295 ++++++++++++++++++++++- sources/Maths/Maths/Vector3F.gen.cs | 290 ++++++++++++++++++++++- sources/Maths/Maths/Vector3I.cs | 329 +------------------------- sources/Maths/Maths/Vector3I.gen.cs | 322 ++++++++++++++++++++++++- sources/Maths/Maths/Vector4F.gen.cs | 317 ++++++++++++++++++++++++- sources/Maths/Maths/Vector4I.cs | 351 +--------------------------- sources/Maths/Maths/Vector4I.gen.cs | 349 ++++++++++++++++++++++++++- 10 files changed, 1834 insertions(+), 1239 deletions(-) diff --git a/sources/Maths/Maths/Vector2F.cs b/sources/Maths/Maths/Vector2F.cs index 10c855434b..651c2abbef 100644 --- a/sources/Maths/Maths/Vector2F.cs +++ b/sources/Maths/Maths/Vector2F.cs @@ -14,37 +14,8 @@ namespace Silk.NET.Maths { /// A structure representing a 2D floating-point vector. - internal partial struct Vector2F : - ISpanFormattable, - ISpanParsable>, - IUtf8SpanFormattable, - IUtf8SpanParsable>, - IParsable>, - IFormattable - where T : IFloatingPointIeee754 + internal partial struct Vector2F { - /// Initializes the vector from a span of two values. - public Vector2F(ReadOnlySpan values) - { - if (values.Length != 2) - throw new ArgumentException("Input span must contain exactly 2 elements.", nameof(values)); - - X = values[0]; - Y = values[1]; - } - - /// Gets a vector whose 2 elements are equal to one. - public static Vector2F One => new(Scalar.One); - - /// Returns a vector whose 2 elements are equal to zero. - public static Vector2F Zero => default; - - /// Gets the vector (1, 0). - public static Vector2F UnitX => new(Scalar.One, Scalar.Zero); - - /// Gets the vector (0, 1). - public static Vector2F UnitY => new(Scalar.Zero, Scalar.One); - /// Gets a vector with all bits set for each component. public static Vector2F AllBitsSet => new(T.AllBitsSet, T.AllBitsSet); @@ -66,9 +37,6 @@ public Vector2F(ReadOnlySpan values) /// Computes the cross product of two vectors. public static T Cross(Vector2F left, Vector2F right) => (left.X * right.Y) - (left.Y * right.X); - /// Returns a span over the vector components. - public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 2); - /// Normalizes this vector. public Vector2F Normalize() { @@ -171,86 +139,6 @@ public static Vector2F Reflect(Vector2F vector, Vector2F normal) return vector - (normal * (dot + dot)); } - /// Formats the vector as a string using the specified format and format provider. - public string ToString(string? format, IFormatProvider? formatProvider) => $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}>"; - - /// Formats the vector as a string. - public override string ToString() => $"<{X}, {Y}>"; - - /// Formats the vector as a string using the specified format and format provider. - public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider) || - !Y.TryFormat(yBuffer, out int yChars, format, provider)) - { - charsWritten = 0; - return false; - } - - int requiredLength = 1 + xChars + 2 + yChars + 1; - - if (destination.Length < requiredLength) - { - charsWritten = 0; - return false; - } - - int pos = 0; - destination[pos++] = '<'; - - xBuffer[..xChars].CopyTo(destination[pos..]); - pos += xChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - yBuffer[..yChars].CopyTo(destination[pos..]); - pos += yChars; - - destination[pos++] = '>'; - - charsWritten = pos; - return true; - } - - /// Parses a span to a instance. - public static Vector2F Parse(ReadOnlySpan s, IFormatProvider? provider) - { - if (!TryParse(s, provider, out var result)) - throw new FormatException("Invalid format for Vector2F."); - - return result; - } - - /// Copies the components of the vector to the specified array starting at index 0. - public void CopyTo(T[] array) => CopyTo(array, 0); - - /// Copies the components of the vector to the specified array starting at the given index. - public void CopyTo(T[] array, int startIndex) - { - if (array == null) - throw new ArgumentNullException(nameof(array)); - if (startIndex < 0 || startIndex + 2 > array.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - array[startIndex] = X; - array[startIndex + 1] = Y; - } - - /// Copies the components of the vector to the specified span starting at index 0. - public void CopyTo(Span span) => CopyTo(span, 0); - - /// Copies the components of the vector to the specified span starting at the given index. - public void CopyTo(Span span, int startIndex) - { - if (startIndex < 0 || startIndex + 2 > span.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - span[startIndex] = X; - span[startIndex + 1] = Y; - } - /// Returns a vector where each component is the sign of the original vector's component. public Vector2F Sign() => new(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y))); @@ -274,110 +162,6 @@ public Vector2F CopySign(T signScalar) => public static Vector2F CopySign(Vector2F value, T signScalar) => new(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar)); - /// Parses a string to a instance. - public static Vector2F Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); - - /// Tries to parse a span to a instance. - public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) - { - result = default; - - s = s.Trim(); - if (s.Length < 5 || s[0] != '<' || s[^1] != '>') - return false; - - s = s[1..^1]; // Remove < and > - - int commaIndex = s.IndexOf(','); - if (commaIndex < 0) - return false; - - ReadOnlySpan xSpan = s[..commaIndex].Trim(); - ReadOnlySpan ySpan = s[(commaIndex + 1)..].Trim(); - - if (T.TryParse(xSpan, provider, out var x) && - T.TryParse(ySpan, provider, out var y)) - { - result = new Vector2F(x, y); - return true; - } - - return false; - } - - /// Tries to parse a string to a instance. - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => - TryParse(s.AsSpan(), provider, out result); - - /// Parses a span to a instance. - static Vector2F ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => - Parse(s, provider); - - /// Parses a string to a instance. - static Vector2F IParsable>.Parse(string s, IFormatProvider? provider) => - Parse(s, provider); - - /// Tries to parse a span to a instance. - static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => - TryParse(s, provider, out result); - - /// Tries to parse a string to a instance. - static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => - TryParse(s, provider, out result); - - /// Formats the vector as a UTF-8 string using the specified format and format provider. - public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) - { - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider) || - !Y.TryFormat(yBuffer, out int yChars, format, provider)) - { - bytesWritten = 0; - return false; - } - - int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + - Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + - Encoding.UTF8.GetByteCount("<, >"); - - if (utf8Destination.Length < estimatedSize) - { - bytesWritten = 0; - return false; - } - - int totalBytes = 0; - - totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); - - bytesWritten = totalBytes; - return true; - } - - /// Parses a UTF-8 span to a instance. - public static Vector2F Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return Parse(charBuffer, provider); - } - - /// Tries to parse a UTF-8 span to a instance. - public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return TryParse(charBuffer, provider, out result); - } - // Casts /// Explicitly casts a to a . @@ -388,45 +172,6 @@ public static explicit operator Vector2F(System.Numerics.Vector2 v) => public static explicit operator System.Numerics.Vector2(Vector2F v) => new(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); - // Component Operators - public static Vector2F operator +(Vector2F left, Vector2F right) => - new(left.X + right.X, left.Y + right.Y); - - public static Vector2F operator -(Vector2F left, Vector2F right) => - new(left.X - right.X, left.Y - right.Y); - - public static Vector2F operator *(Vector2F left, Vector2F right) => - new(left.X * right.X, left.Y * right.Y); - - public static Vector2F operator /(Vector2F left, Vector2F right) => - new(left.X / right.X, left.Y / right.Y); - - public static Vector2F operator %(Vector2F left, Vector2F right) => - new(left.X % right.X, left.Y % right.Y); - - // Scalar Operators - public static Vector2F operator +(Vector2F vector, T scalar) => - new(vector.X + scalar, vector.Y + scalar); - - public static Vector2F operator -(Vector2F vector, T scalar) => - new(vector.X - scalar, vector.Y - scalar); - - public static Vector2F operator *(Vector2F vector, T scalar) => - new(vector.X * scalar, vector.Y * scalar); - - public static Vector2F operator /(Vector2F vector, T scalar) => - new(vector.X / scalar, vector.Y / scalar); - - public static Vector2F operator %(Vector2F vector, T scalar) => - new(vector.X % scalar, vector.Y % scalar); - - // + operator: returns the vector - public static Vector2F operator +(Vector2F vector) => vector; - - // - operator: returns the negated vector - public static Vector2F operator -(Vector2F vector) => - new(-vector.X, -vector.Y); - // IFloatingPointIeee754 public static Vector2F Sqrt(Vector2F x) => new(T.Sqrt(x.X), T.Sqrt(x.Y)); diff --git a/sources/Maths/Maths/Vector2F.gen.cs b/sources/Maths/Maths/Vector2F.gen.cs index 34d27f31f1..c78c0ae7a7 100644 --- a/sources/Maths/Maths/Vector2F.gen.cs +++ b/sources/Maths/Maths/Vector2F.gen.cs @@ -3,10 +3,18 @@ namespace Silk.NET.Maths using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.InteropServices; + using System.Text; partial struct Vector2F : IEquatable>, - IReadOnlyList + IReadOnlyList, + IFormattable, + IParsable>, + ISpanFormattable, + ISpanParsable>, + IUtf8SpanFormattable, + IUtf8SpanParsable> where T : IFloatingPointIeee754 { /// The X component of the vector. @@ -21,6 +29,28 @@ partial struct Vector2F : /// Initializes the vector with individual component values. public Vector2F(T x, T y) => (X, Y) = (x, y); + /// Initializes the vector from a span of 2 values. + public Vector2F(ReadOnlySpan values) + { + if (values.Length != 2) + throw new ArgumentException("Input span must contain exactly 2 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + } + + /// Gets a vector whose 2 elements are equal to one. + public static Vector2F One => new(Scalar.One); + + /// Returns a vector whose 2 elements are equal to zero. + public static Vector2F Zero => default; + + /// Gets the vector (1, 0). + public static Vector2F UnitX => new(Scalar.One, Scalar.Zero); + + /// Gets the vector (0, 1). + public static Vector2F UnitY => new(Scalar.Zero, Scalar.One); + /// T IReadOnlyList.this[int index] => this[index]; @@ -55,6 +85,197 @@ public IEnumerator GetEnumerator() yield return Y; } + /// Copies the components of the vector to the specified array starting at index 0. + public void CopyTo(T[] array) => CopyTo(array, 0); + + /// Copies the components of the vector to the specified array starting at the given index. + public void CopyTo(T[] array, int startIndex) + { + if (array == null) + throw new ArgumentNullException(nameof(array)); + if (startIndex < 0 || startIndex + 2 > array.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + array[startIndex] = X; + array[startIndex + 1] = Y; + } + + /// Copies the components of the vector to the specified span starting at index 0. + public void CopyTo(Span span) => CopyTo(span, 0); + + /// Copies the components of the vector to the specified span starting at the given index. + public void CopyTo(Span span, int startIndex) + { + if (startIndex < 0 || startIndex + 2 > span.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + span[startIndex] = X; + span[startIndex + 1] = Y; + } + + /// Returns a span over the vector components. + public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 2); + + /// Formats the vector as a string. + public override string ToString() => + $"<{X}, {Y}>"; + + /// Formats the vector as a string using the specified format and format provider. + public string ToString(string? format, IFormatProvider? formatProvider) => + $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}>"; + + /// Parses a string to a instance. + public static Vector2F Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + + /// Parses a span to a instance. + public static Vector2F Parse(ReadOnlySpan s, IFormatProvider? provider) + { + if (!TryParse(s, provider, out var result)) + throw new FormatException("Invalid format for Vector2F."); + + return result; + } + + /// Formats the vector as a UTF-8 string using the specified format and format provider. + public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider)|| + !Y.TryFormat(yBuffer, out int yChars, format, provider)) + { + bytesWritten = 0; + return false; + } + + int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + + Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + + Encoding.UTF8.GetByteCount("<, >"); + + if (utf8Destination.Length < estimatedSize) + { + bytesWritten = 0; + return false; + } + + int totalBytes = 0; + + totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); + + bytesWritten = totalBytes; + return true; + } + + /// Formats the vector as a string using the specified format and format provider. + public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider)) + { + charsWritten = 0; + return false; + } + + int requiredLength = 1 + xChars + 2 + yChars + 1; + + if (destination.Length < requiredLength) + { + charsWritten = 0; + return false; + } + + int pos = 0; + destination[pos++] = '<'; + + xBuffer[..xChars].CopyTo(destination[pos..]); + pos += xChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + yBuffer[..yChars].CopyTo(destination[pos..]); + pos += yChars; + + destination[pos++] = '>'; + + charsWritten = pos; + return true; + } + + /// Tries to parse a span to a instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) + { + result = default; + + s = s.Trim(); + if (s.Length < 4 || s[0] != '<' || s[^1] != '>') + return false; + + s = s[1..^1]; // Remove < and > + + int commaX = s.IndexOf(','); + if (commaX < 0) + return false; + + ReadOnlySpan xSpan = s[..commaX].Trim(); + ReadOnlySpan ySpan = s[(commaX + 1)..].Trim(); + + if (T.TryParse(xSpan, provider, out var x) && + T.TryParse(ySpan, provider, out var y)) + { + result = new Vector2F(x, y); + return true; + } + + return false; + } + + /// Parses a UTF-8 span to a instance. + public static Vector2F Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return Parse(charBuffer, provider); + } + + /// Tries to parse a UTF-8 span to a instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return TryParse(charBuffer, provider, out result); + } + + /// Tries to parse a string to a instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => + TryParse(s.AsSpan(), provider, out result); + + /// Parses a span to a instance. + static Vector2F ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + Parse(s, provider); + + /// Parses a string to a instance. + static Vector2F IParsable>.Parse(string s, IFormatProvider? provider) => + Parse(s, provider); + + /// Tries to parse a span to a instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => + TryParse(s, provider, out result); + + /// Tries to parse a string to a instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => + TryParse(s, provider, out result); + /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. @@ -77,6 +298,46 @@ public IEnumerator GetEnumerator() /// public override int GetHashCode() => HashCode.Combine(X, Y); + + public static Vector2F operator +(Vector2F vector) => + vector; + + public static Vector2F operator -(Vector2F vector) => + new Vector2F(-vector.X, -vector.Y); + + public static Vector2F operator +(Vector2F left, Vector2F right) => + new Vector2F(left.X + right.X, left.Y + right.Y); + + public static Vector2F operator -(Vector2F left, Vector2F right) => + new Vector2F(left.X - right.X, left.Y - right.Y); + + public static Vector2F operator *(Vector2F left, Vector2F right) => + new Vector2F(left.X * right.X, left.Y * right.Y); + + public static Vector2F operator /(Vector2F left, Vector2F right) => + new Vector2F(left.X / right.X, left.Y / right.Y); + + public static Vector2F operator %(Vector2F left, Vector2F right) => + new Vector2F(left.X % right.X, left.Y % right.Y); + + public static Vector2F operator +(Vector2F vector, T scalar) => + new Vector2F(vector.X + scalar, vector.Y + scalar); + + public static Vector2F operator -(Vector2F vector, T scalar) => + new Vector2F(vector.X - scalar, vector.Y - scalar); + + public static Vector2F operator *(Vector2F vector, T scalar) => + new Vector2F(vector.X * scalar, vector.Y * scalar); + + public static Vector2F operator *(T scalar, Vector2F vector) => + new Vector2F(scalar * vector.X, scalar * vector.Y); + + public static Vector2F operator /(Vector2F vector, T scalar) => + new Vector2F(vector.X / scalar, vector.Y / scalar); + + public static Vector2F operator %(Vector2F vector, T scalar) => + new Vector2F(vector.X % scalar, vector.Y % scalar); + } static partial class Vector2F diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index 2a49a846b5..d4e06c943e 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -12,40 +12,8 @@ namespace Silk.NET.Maths { /// A structure representing a 2D integer vector. - internal partial struct Vector2I : - ISpanFormattable, - ISpanParsable>, - IUtf8SpanFormattable, - IUtf8SpanParsable>, - IParsable>, - IFormattable - where T : IBinaryInteger + internal partial struct Vector2I { - /// Initializes the vector from a span of two values. - public Vector2I(ReadOnlySpan values) - { - if (values.Length != 2) - throw new ArgumentException("Input span must contain exactly 2 elements.", nameof(values)); - - X = values[0]; - Y = values[1]; - } - - /// Gets a vector whose 2 elements are equal to one. - public static Vector2I One => new(Scalar.One); - - /// Returns a vector whose 2 elements are equal to zero. - public static Vector2I Zero => default; - - /// Gets the vector (1, 0). - public static Vector2I UnitX => new(Scalar.One, Scalar.Zero); - - /// Gets the vector (0, 1). - public static Vector2I UnitY => new(Scalar.Zero, Scalar.One); - - /// Gets a vector with all bits set for each component. - public static Vector2I AllBitsSet => new Vector2I(T.AllBitsSet, T.AllBitsSet); - /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => (X * X) + (Y * Y); @@ -61,9 +29,6 @@ public Vector2I(ReadOnlySpan values) /// Computes the cross product of two vectors. public static T Cross(Vector2I left, Vector2I right) => (left.X * right.Y) - (left.Y * right.X); - /// Returns a span over the vector components. - public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 2); - /// Returns a vector with the component-wise maximum of this and another vector. public Vector2I Max(Vector2I other) => new Vector2I(T.Max(X, other.X), T.Max(Y, other.Y)); @@ -119,90 +84,6 @@ public static Vector2I Clamp(Vector2I vector, T min, T max) => public static Vector2I Abs(Vector2I vector) => new Vector2I(T.Abs(vector.X), T.Abs(vector.Y)); - /// Formats the vector as a string using the specified format and format provider. - public string ToString(string? format, IFormatProvider? formatProvider) => $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}>"; - - /// Formats the vector as a string. - public override string ToString() => $"<{X}, {Y}>"; - - /// Formats the vector as a string using the specified format and format provider. - public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - // Format components individually into temporary buffers - // Not too sure about this implementation - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider) || - !Y.TryFormat(yBuffer, out int yChars, format, provider)) - { - charsWritten = 0; - return false; - } - - // Calculate total required length: < + x + ", " + y + > - int requiredLength = 1 + xChars + 2 + yChars + 1; - - if (destination.Length < requiredLength) - { - charsWritten = 0; - return false; - } - - int pos = 0; - destination[pos++] = '<'; - - xBuffer[..xChars].CopyTo(destination[pos..]); - pos += xChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - yBuffer[..yChars].CopyTo(destination[pos..]); - pos += yChars; - - destination[pos++] = '>'; - - charsWritten = pos; - return true; - } - - /// Parses a span to a instance. - public static Vector2I Parse(ReadOnlySpan s, IFormatProvider? provider) - { - if (!TryParse(s, provider, out var result)) - throw new FormatException("Invalid format for Vector2I."); - - return result; - } - - /// Copies the components of the vector to the specified array starting at index 0. - public void CopyTo(T[] array) => CopyTo(array, 0); - - /// Copies the components of the vector to the specified array starting at the given index. - public void CopyTo(T[] array, int startIndex) - { - if (array == null) - throw new ArgumentNullException(nameof(array)); - if (startIndex < 0 || startIndex + 2 > array.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - array[startIndex] = X; - array[startIndex + 1] = Y; - } - - /// Copies the components of the vector to the specified span starting at index 0. - public void CopyTo(Span span) => CopyTo(span, 0); - - /// Copies the components of the vector to the specified span starting at the given index. - public void CopyTo(Span span, int startIndex) - { - if (startIndex < 0 || startIndex + 2 > span.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - - span[startIndex] = X; - span[startIndex + 1] = Y; - } - /// Returns a vector where each component is the sign of the original vector's component. public Vector2I Sign() => new Vector2I(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y))); @@ -226,114 +107,6 @@ public Vector2I CopySign(T signScalar) => public static Vector2I CopySign(Vector2I value, T signScalar) => new Vector2I(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar)); - /// Parses a string to a instance. - public static Vector2I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); - - /// Tries to parse a span to a instance. - public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) - { - result = default; - - s = s.Trim(); - if (s.Length < 5 || s[0] != '<' || s[^1] != '>') - return false; - - s = s[1..^1]; // Remove < and > - - int commaIndex = s.IndexOf(','); - if (commaIndex < 0) - return false; - - ReadOnlySpan xSpan = s[..commaIndex].Trim(); - ReadOnlySpan ySpan = s[(commaIndex + 1)..].Trim(); - - if (T.TryParse(xSpan, provider, out var x) && - T.TryParse(ySpan, provider, out var y)) - { - result = new Vector2I(x, y); - return true; - } - - return false; - } - - - /// Tries to parse a string to a instance. - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => - TryParse(s.AsSpan(), provider, out result); - - /// Parses a span to a instance. - static Vector2I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => - Parse(s, provider); - - /// Parses a string to a instance. - static Vector2I IParsable>.Parse(string s, IFormatProvider? provider) => - Parse(s, provider); - - /// Tries to parse a span to a instance. - static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => - TryParse(s, provider, out result); - - /// Tries to parse a string to a instance. - static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => - TryParse(s, provider, out result); - - /// Formats the vector as a UTF-8 string using the specified format and format provider. - public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) - { - // Format components individually into temporary buffers - // Not too sure about this implementation - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider) || - !Y.TryFormat(yBuffer, out int yChars, format, provider)) - { - bytesWritten = 0; - return false; - } - - // Estimate total required UTF-8 bytes - int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + - Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + - Encoding.UTF8.GetByteCount("<, >"); - - if (utf8Destination.Length < estimatedSize) - { - bytesWritten = 0; - return false; - } - - int totalBytes = 0; - - totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); - - bytesWritten = totalBytes; - return true; - } - - /// Parses a UTF-8 span to a instance. - public static Vector2I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return Parse(charBuffer, provider); - } - - /// Tries to parse a UTF-8 span to a instance. - public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return TryParse(charBuffer, provider, out result); - } - // Casts /// Explicitly casts a to a . @@ -344,77 +117,6 @@ public static explicit operator Vector2I(System.Numerics.Vector2 v) => public static explicit operator System.Numerics.Vector2(Vector2I v) => new System.Numerics.Vector2(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); - // Component Operators - public static Vector2I operator +(Vector2I left, Vector2I right) => - new Vector2I(left.X + right.X, left.Y + right.Y); - - public static Vector2I operator -(Vector2I left, Vector2I right) => - new Vector2I(left.X - right.X, left.Y - right.Y); - - public static Vector2I operator *(Vector2I left, Vector2I right) => - new Vector2I(left.X * right.X, left.Y * right.Y); - - public static Vector2I operator /(Vector2I left, Vector2I right) => - new Vector2I(left.X / right.X, left.Y / right.Y); - - public static Vector2I operator %(Vector2I left, Vector2I right) => - new Vector2I(left.X % right.X, left.Y % right.Y); - - // Scalar Operators - public static Vector2I operator +(Vector2I vector, T scalar) => - new Vector2I(vector.X + scalar, vector.Y + scalar); - - public static Vector2I operator -(Vector2I vector, T scalar) => - new Vector2I(vector.X - scalar, vector.Y - scalar); - - public static Vector2I operator *(Vector2I vector, T scalar) => - new Vector2I(vector.X * scalar, vector.Y * scalar); - - public static Vector2I operator /(Vector2I vector, T scalar) => - new Vector2I(vector.X / scalar, vector.Y / scalar); - - public static Vector2I operator %(Vector2I vector, T scalar) => - new Vector2I(vector.X % scalar, vector.Y % scalar); - - // + operator: returns the vector (?) - public static Vector2I operator +(Vector2I vector) => vector; - - // - operator: returns the negated vector - public static Vector2I operator -(Vector2I vector) => - new Vector2I(-vector.X, -vector.Y); - - // Bitwise Operators - public static Vector2I operator &(Vector2I left, Vector2I right) => - new Vector2I(left.X & right.X, left.Y & right.Y); - - public static Vector2I operator |(Vector2I left, Vector2I right) => - new Vector2I(left.X | right.X, left.Y | right.Y); - - public static Vector2I operator ^(Vector2I left, Vector2I right) => - new Vector2I(left.X ^ right.X, left.Y ^ right.Y); - - public static Vector2I operator &(Vector2I vector, T scalar) => - new Vector2I(vector.X & scalar, vector.Y & scalar); - - public static Vector2I operator &(T scalar, Vector2I vector) => - new Vector2I(scalar & vector.X, scalar & vector.Y); - - public static Vector2I operator |(Vector2I vector, T scalar) => - new Vector2I(vector.X | scalar, vector.Y | scalar); - - public static Vector2I operator |(T scalar, Vector2I vector) => - new Vector2I(scalar | vector.X, scalar | vector.Y); - - public static Vector2I operator ^(Vector2I vector, T scalar) => - new Vector2I(vector.X ^ scalar, vector.Y ^ scalar); - - public static Vector2I operator ^(T scalar, Vector2I vector) => - new Vector2I(scalar ^ vector.X, scalar ^ vector.Y); - - // NOT operator - public static Vector2I operator ~(Vector2I vector) => - new Vector2I(~vector.X, ~vector.Y); - // IBinaryInteger // TODO: Verify these are actually correct diff --git a/sources/Maths/Maths/Vector2I.gen.cs b/sources/Maths/Maths/Vector2I.gen.cs index c8631934e7..60df7f4e0c 100644 --- a/sources/Maths/Maths/Vector2I.gen.cs +++ b/sources/Maths/Maths/Vector2I.gen.cs @@ -3,10 +3,18 @@ namespace Silk.NET.Maths using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.InteropServices; + using System.Text; partial struct Vector2I : IEquatable>, - IReadOnlyList + IReadOnlyList, + IFormattable, + IParsable>, + ISpanFormattable, + ISpanParsable>, + IUtf8SpanFormattable, + IUtf8SpanParsable> where T : IBinaryInteger { /// The X component of the vector. @@ -21,6 +29,31 @@ partial struct Vector2I : /// Initializes the vector with individual component values. public Vector2I(T x, T y) => (X, Y) = (x, y); + /// Initializes the vector from a span of 2 values. + public Vector2I(ReadOnlySpan values) + { + if (values.Length != 2) + throw new ArgumentException("Input span must contain exactly 2 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + } + + /// Gets a vector whose 2 elements are equal to one. + public static Vector2I One => new(Scalar.One); + + /// Returns a vector whose 2 elements are equal to zero. + public static Vector2I Zero => default; + + /// Gets the vector (1, 0). + public static Vector2I UnitX => new(Scalar.One, Scalar.Zero); + + /// Gets the vector (0, 1). + public static Vector2I UnitY => new(Scalar.Zero, Scalar.One); + + /// Gets a vector with all bits set for each component. + public static Vector2I AllBitsSet => new Vector2I(T.AllBitsSet, T.AllBitsSet); + /// T IReadOnlyList.this[int index] => this[index]; @@ -55,6 +88,197 @@ public IEnumerator GetEnumerator() yield return Y; } + /// Copies the components of the vector to the specified array starting at index 0. + public void CopyTo(T[] array) => CopyTo(array, 0); + + /// Copies the components of the vector to the specified array starting at the given index. + public void CopyTo(T[] array, int startIndex) + { + if (array == null) + throw new ArgumentNullException(nameof(array)); + if (startIndex < 0 || startIndex + 2 > array.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + array[startIndex] = X; + array[startIndex + 1] = Y; + } + + /// Copies the components of the vector to the specified span starting at index 0. + public void CopyTo(Span span) => CopyTo(span, 0); + + /// Copies the components of the vector to the specified span starting at the given index. + public void CopyTo(Span span, int startIndex) + { + if (startIndex < 0 || startIndex + 2 > span.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + span[startIndex] = X; + span[startIndex + 1] = Y; + } + + /// Returns a span over the vector components. + public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 2); + + /// Formats the vector as a string. + public override string ToString() => + $"<{X}, {Y}>"; + + /// Formats the vector as a string using the specified format and format provider. + public string ToString(string? format, IFormatProvider? formatProvider) => + $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}>"; + + /// Parses a string to a instance. + public static Vector2I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + + /// Parses a span to a instance. + public static Vector2I Parse(ReadOnlySpan s, IFormatProvider? provider) + { + if (!TryParse(s, provider, out var result)) + throw new FormatException("Invalid format for Vector2I."); + + return result; + } + + /// Formats the vector as a UTF-8 string using the specified format and format provider. + public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider)|| + !Y.TryFormat(yBuffer, out int yChars, format, provider)) + { + bytesWritten = 0; + return false; + } + + int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + + Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + + Encoding.UTF8.GetByteCount("<, >"); + + if (utf8Destination.Length < estimatedSize) + { + bytesWritten = 0; + return false; + } + + int totalBytes = 0; + + totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); + + bytesWritten = totalBytes; + return true; + } + + /// Formats the vector as a string using the specified format and format provider. + public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider)) + { + charsWritten = 0; + return false; + } + + int requiredLength = 1 + xChars + 2 + yChars + 1; + + if (destination.Length < requiredLength) + { + charsWritten = 0; + return false; + } + + int pos = 0; + destination[pos++] = '<'; + + xBuffer[..xChars].CopyTo(destination[pos..]); + pos += xChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + yBuffer[..yChars].CopyTo(destination[pos..]); + pos += yChars; + + destination[pos++] = '>'; + + charsWritten = pos; + return true; + } + + /// Tries to parse a span to a instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) + { + result = default; + + s = s.Trim(); + if (s.Length < 4 || s[0] != '<' || s[^1] != '>') + return false; + + s = s[1..^1]; // Remove < and > + + int commaX = s.IndexOf(','); + if (commaX < 0) + return false; + + ReadOnlySpan xSpan = s[..commaX].Trim(); + ReadOnlySpan ySpan = s[(commaX + 1)..].Trim(); + + if (T.TryParse(xSpan, provider, out var x) && + T.TryParse(ySpan, provider, out var y)) + { + result = new Vector2I(x, y); + return true; + } + + return false; + } + + /// Parses a UTF-8 span to a instance. + public static Vector2I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return Parse(charBuffer, provider); + } + + /// Tries to parse a UTF-8 span to a instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return TryParse(charBuffer, provider, out result); + } + + /// Tries to parse a string to a instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => + TryParse(s.AsSpan(), provider, out result); + + /// Parses a span to a instance. + static Vector2I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + Parse(s, provider); + + /// Parses a string to a instance. + static Vector2I IParsable>.Parse(string s, IFormatProvider? provider) => + Parse(s, provider); + + /// Tries to parse a span to a instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => + TryParse(s, provider, out result); + + /// Tries to parse a string to a instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => + TryParse(s, provider, out result); + /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. @@ -77,6 +301,75 @@ public IEnumerator GetEnumerator() /// public override int GetHashCode() => HashCode.Combine(X, Y); + + public static Vector2I operator +(Vector2I vector) => + vector; + + public static Vector2I operator -(Vector2I vector) => + new Vector2I(-vector.X, -vector.Y); + + public static Vector2I operator +(Vector2I left, Vector2I right) => + new Vector2I(left.X + right.X, left.Y + right.Y); + + public static Vector2I operator -(Vector2I left, Vector2I right) => + new Vector2I(left.X - right.X, left.Y - right.Y); + + public static Vector2I operator *(Vector2I left, Vector2I right) => + new Vector2I(left.X * right.X, left.Y * right.Y); + + public static Vector2I operator /(Vector2I left, Vector2I right) => + new Vector2I(left.X / right.X, left.Y / right.Y); + + public static Vector2I operator %(Vector2I left, Vector2I right) => + new Vector2I(left.X % right.X, left.Y % right.Y); + + public static Vector2I operator +(Vector2I vector, T scalar) => + new Vector2I(vector.X + scalar, vector.Y + scalar); + + public static Vector2I operator -(Vector2I vector, T scalar) => + new Vector2I(vector.X - scalar, vector.Y - scalar); + + public static Vector2I operator *(Vector2I vector, T scalar) => + new Vector2I(vector.X * scalar, vector.Y * scalar); + + public static Vector2I operator *(T scalar, Vector2I vector) => + new Vector2I(scalar * vector.X, scalar * vector.Y); + + public static Vector2I operator /(Vector2I vector, T scalar) => + new Vector2I(vector.X / scalar, vector.Y / scalar); + + public static Vector2I operator %(Vector2I vector, T scalar) => + new Vector2I(vector.X % scalar, vector.Y % scalar); + + public static Vector2I operator ~(Vector2I vector) => + new Vector2I(~vector.X, ~vector.Y); + + public static Vector2I operator &(Vector2I left, Vector2I right) => + new Vector2I(left.X & right.X, left.Y & right.Y); + + public static Vector2I operator |(Vector2I left, Vector2I right) => + new Vector2I(left.X | right.X, left.Y | right.Y); + + public static Vector2I operator ^(Vector2I left, Vector2I right) => + new Vector2I(left.X ^ right.X, left.Y ^ right.Y); + + public static Vector2I operator &(Vector2I vector, T scalar) => + new Vector2I(vector.X & scalar, vector.Y & scalar); + + public static Vector2I operator &(T scalar, Vector2I vector) => + new Vector2I(scalar & vector.X, scalar & vector.Y); + + public static Vector2I operator |(Vector2I vector, T scalar) => + new Vector2I(vector.X | scalar, vector.Y | scalar); + + public static Vector2I operator |(T scalar, Vector2I vector) => + new Vector2I(scalar | vector.X, scalar | vector.Y); + + public static Vector2I operator ^(Vector2I vector, T scalar) => + new Vector2I(vector.X ^ scalar, vector.Y ^ scalar); + + public static Vector2I operator ^(T scalar, Vector2I vector) => + new Vector2I(scalar ^ vector.X, scalar ^ vector.Y); } static partial class Vector2I diff --git a/sources/Maths/Maths/Vector3F.gen.cs b/sources/Maths/Maths/Vector3F.gen.cs index 93b997b6e1..c339e7248b 100644 --- a/sources/Maths/Maths/Vector3F.gen.cs +++ b/sources/Maths/Maths/Vector3F.gen.cs @@ -3,10 +3,18 @@ namespace Silk.NET.Maths using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.InteropServices; + using System.Text; partial struct Vector3F : IEquatable>, - IReadOnlyList + IReadOnlyList, + IFormattable, + IParsable>, + ISpanFormattable, + ISpanParsable>, + IUtf8SpanFormattable, + IUtf8SpanParsable> where T : IFloatingPointIeee754 { /// The X component of the vector. @@ -24,6 +32,32 @@ partial struct Vector3F : /// Initializes the vector with individual component values. public Vector3F(T x, T y, T z) => (X, Y, Z) = (x, y, z); + /// Initializes the vector from a span of 3 values. + public Vector3F(ReadOnlySpan values) + { + if (values.Length != 3) + throw new ArgumentException("Input span must contain exactly 3 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + Z = values[2]; + } + + /// Gets a vector whose 3 elements are equal to one. + public static Vector3F One => new(Scalar.One); + + /// Returns a vector whose 3 elements are equal to zero. + public static Vector3F Zero => default; + + /// Gets the vector (1, 0, 0). + public static Vector3F UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero); + + /// Gets the vector (0, 1, 0). + public static Vector3F UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero); + + /// Gets the vector (0, 0, 1). + public static Vector3F UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One); + /// T IReadOnlyList.this[int index] => this[index]; @@ -61,6 +95,220 @@ public IEnumerator GetEnumerator() yield return Z; } + /// Copies the components of the vector to the specified array starting at index 0. + public void CopyTo(T[] array) => CopyTo(array, 0); + + /// Copies the components of the vector to the specified array starting at the given index. + public void CopyTo(T[] array, int startIndex) + { + if (array == null) + throw new ArgumentNullException(nameof(array)); + if (startIndex < 0 || startIndex + 3 > array.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + array[startIndex] = X; + array[startIndex + 1] = Y; + array[startIndex + 2] = Z; + } + + /// Copies the components of the vector to the specified span starting at index 0. + public void CopyTo(Span span) => CopyTo(span, 0); + + /// Copies the components of the vector to the specified span starting at the given index. + public void CopyTo(Span span, int startIndex) + { + if (startIndex < 0 || startIndex + 3 > span.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + span[startIndex] = X; + span[startIndex + 1] = Y; + span[startIndex + 2] = Z; + } + + /// Returns a span over the vector components. + public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 3); + + /// Formats the vector as a string. + public override string ToString() => + $"<{X}, {Y}, {Z}>"; + + /// Formats the vector as a string using the specified format and format provider. + public string ToString(string? format, IFormatProvider? formatProvider) => + $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}, {Z.ToString(format, formatProvider)}>"; + + /// Parses a string to a instance. + public static Vector3F Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + + /// Parses a span to a instance. + public static Vector3F Parse(ReadOnlySpan s, IFormatProvider? provider) + { + if (!TryParse(s, provider, out var result)) + throw new FormatException("Invalid format for Vector3F."); + + return result; + } + + /// Formats the vector as a UTF-8 string using the specified format and format provider. + public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + Span zBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider)|| + !Y.TryFormat(yBuffer, out int yChars, format, provider)|| + !Z.TryFormat(zBuffer, out int zChars, format, provider)) + { + bytesWritten = 0; + return false; + } + + int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + + Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + + Encoding.UTF8.GetByteCount(zBuffer[..zChars]) + + Encoding.UTF8.GetByteCount("<, >"); + + if (utf8Destination.Length < estimatedSize) + { + bytesWritten = 0; + return false; + } + + int totalBytes = 0; + + totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(zBuffer[..zChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); + + bytesWritten = totalBytes; + return true; + } + + /// Formats the vector as a string using the specified format and format provider. + public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + Span zBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider) || + !Z.TryFormat(zBuffer, out int zChars, format, provider)) + { + charsWritten = 0; + return false; + } + + int requiredLength = 1 + xChars + 2 + yChars + 2 + zChars + 1; + + if (destination.Length < requiredLength) + { + charsWritten = 0; + return false; + } + + int pos = 0; + destination[pos++] = '<'; + + xBuffer[..xChars].CopyTo(destination[pos..]); + pos += xChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + yBuffer[..yChars].CopyTo(destination[pos..]); + pos += yChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + zBuffer[..zChars].CopyTo(destination[pos..]); + pos += zChars; + + destination[pos++] = '>'; + + charsWritten = pos; + return true; + } + + /// Tries to parse a span to a instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3F result) + { + result = default; + + s = s.Trim(); + if (s.Length < 6 || s[0] != '<' || s[^1] != '>') + return false; + + s = s[1..^1]; // Remove < and > + + int commaX = s.IndexOf(','); + if (commaX < 0) + return false; + + ReadOnlySpan remainder1 = s.Slice(commaX + 1); + int commaYRelative = remainder1.IndexOf(','); + if (commaYRelative < 0) + return false; + int commaY = commaX + 1 + commaYRelative; + + ReadOnlySpan xSpan = s[..commaX].Trim(); + ReadOnlySpan ySpan = s[(commaX + 1)..commaY].Trim(); + ReadOnlySpan zSpan = s[(commaY + 1)..].Trim(); + + if (T.TryParse(xSpan, provider, out var x) && + T.TryParse(ySpan, provider, out var y) && + T.TryParse(zSpan, provider, out var z)) + { + result = new Vector3F(x, y, z); + return true; + } + + return false; + } + + /// Parses a UTF-8 span to a instance. + public static Vector3F Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return Parse(charBuffer, provider); + } + + /// Tries to parse a UTF-8 span to a instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3F result) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return TryParse(charBuffer, provider, out result); + } + + /// Tries to parse a string to a instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3F result) => + TryParse(s.AsSpan(), provider, out result); + + /// Parses a span to a instance. + static Vector3F ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + Parse(s, provider); + + /// Parses a string to a instance. + static Vector3F IParsable>.Parse(string s, IFormatProvider? provider) => + Parse(s, provider); + + /// Tries to parse a span to a instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3F result) => + TryParse(s, provider, out result); + + /// Tries to parse a string to a instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3F result) => + TryParse(s, provider, out result); + /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. @@ -84,6 +332,46 @@ public IEnumerator GetEnumerator() /// public override int GetHashCode() => HashCode.Combine(X, Y, Z); + + public static Vector3F operator +(Vector3F vector) => + vector; + + public static Vector3F operator -(Vector3F vector) => + new Vector3F(-vector.X, -vector.Y, -vector.Z); + + public static Vector3F operator +(Vector3F left, Vector3F right) => + new Vector3F(left.X + right.X, left.Y + right.Y, left.Z + right.Z); + + public static Vector3F operator -(Vector3F left, Vector3F right) => + new Vector3F(left.X - right.X, left.Y - right.Y, left.Z - right.Z); + + public static Vector3F operator *(Vector3F left, Vector3F right) => + new Vector3F(left.X * right.X, left.Y * right.Y, left.Z * right.Z); + + public static Vector3F operator /(Vector3F left, Vector3F right) => + new Vector3F(left.X / right.X, left.Y / right.Y, left.Z / right.Z); + + public static Vector3F operator %(Vector3F left, Vector3F right) => + new Vector3F(left.X % right.X, left.Y % right.Y, left.Z % right.Z); + + public static Vector3F operator +(Vector3F vector, T scalar) => + new Vector3F(vector.X + scalar, vector.Y + scalar, vector.Z + scalar); + + public static Vector3F operator -(Vector3F vector, T scalar) => + new Vector3F(vector.X - scalar, vector.Y - scalar, vector.Z - scalar); + + public static Vector3F operator *(Vector3F vector, T scalar) => + new Vector3F(vector.X * scalar, vector.Y * scalar, vector.Z * scalar); + + public static Vector3F operator *(T scalar, Vector3F vector) => + new Vector3F(scalar * vector.X, scalar * vector.Y, scalar * vector.Z); + + public static Vector3F operator /(Vector3F vector, T scalar) => + new Vector3F(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); + + public static Vector3F operator %(Vector3F vector, T scalar) => + new Vector3F(vector.X % scalar, vector.Y % scalar, vector.Z % scalar); + } static partial class Vector3F diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index ac7a810b7d..8df9e4e06a 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -12,48 +12,12 @@ namespace Silk.NET.Maths { /// A structure representing a 3D integer vector. - internal partial struct Vector3I : - ISpanFormattable, - ISpanParsable>, - IUtf8SpanFormattable, - IUtf8SpanParsable>, - IParsable>, - IFormattable - where T : IBinaryInteger + internal partial struct Vector3I { - /// Initializes the vector from a span of three values. - public Vector3I(ReadOnlySpan values) - { - if (values.Length != 3) - throw new ArgumentException("Input span must contain exactly 3 elements.", nameof(values)); - - X = values[0]; - Y = values[1]; - Z = values[2]; - } - /// Initializes the vector using a Vector2I for X and Y, and a separate value for Z. // TODO: Make sure lower dimensional constructors arent meant to zero-out the higher dimensions public Vector3I(Vector2I xy, T z) => (X, Y, Z) = (xy.X, xy.Y, z); - /// Gets a vector whose 3 elements are equal to one. - public static Vector3I One => new(Scalar.One); - - /// Returns a vector whose 3 elements are equal to zero. - public static Vector3I Zero => default; - - /// Gets the vector (1, 0, 0). - public static Vector3I UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero); - - /// Gets the vector (0, 1, 0). - public static Vector3I UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero); - - /// Gets the vector (0, 0, 1). - public static Vector3I UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One); - - /// Gets a vector with all bits set for each component. - public static Vector3I AllBitsSet => new Vector3I(T.AllBitsSet, T.AllBitsSet, T.AllBitsSet); - /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => (X * X) + (Y * Y) + (Z * Z); @@ -79,9 +43,6 @@ public static Vector3I Cross(Vector3I left, Vector3I right) => (left.X * right.Y) - (left.Y * right.X) ); - /// Returns a span over the vector components. - public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 3); - /// Returns a vector with the component-wise maximum of this and another vector. public Vector3I Max(Vector3I other) => new Vector3I(T.Max(X, other.X), T.Max(Y, other.Y), T.Max(Z, other.Z)); @@ -153,99 +114,6 @@ public static Vector3I Clamp(Vector3I vector, T min, T max) => public static Vector3I Abs(Vector3I vector) => new Vector3I(T.Abs(vector.X), T.Abs(vector.Y), T.Abs(vector.Z)); - /// Formats the vector as a string using the specified format and format provider. - public string ToString(string? format, IFormatProvider? formatProvider) => - $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}, {Z.ToString(format, formatProvider)}>"; - - /// Formats the vector as a string. - public override string ToString() => $"<{X}, {Y}, {Z}>"; - - /// Formats the vector as a string using the specified format and format provider. - public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - // Format components individually into temporary buffers - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - Span zBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider) || - !Y.TryFormat(yBuffer, out int yChars, format, provider) || - !Z.TryFormat(zBuffer, out int zChars, format, provider)) - { - charsWritten = 0; - return false; - } - - // Calculate total required length: < + x + ", " + y + ", " + z + > - int requiredLength = 1 + xChars + 2 + yChars + 2 + zChars + 1; - - if (destination.Length < requiredLength) - { - charsWritten = 0; - return false; - } - - int pos = 0; - destination[pos++] = '<'; - - xBuffer[..xChars].CopyTo(destination[pos..]); - pos += xChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - yBuffer[..yChars].CopyTo(destination[pos..]); - pos += yChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - zBuffer[..zChars].CopyTo(destination[pos..]); - pos += zChars; - - destination[pos++] = '>'; - - charsWritten = pos; - return true; - } - - /// Parses a span to a instance. - public static Vector3I Parse(ReadOnlySpan s, IFormatProvider? provider) - { - if (!TryParse(s, provider, out var result)) - throw new FormatException("Invalid format for Vector3I."); - - return result; - } - - /// Copies the components of the vector to the specified array starting at index 0. - public void CopyTo(T[] array) => CopyTo(array, 0); - - /// Copies the components of the vector to the specified array starting at the given index. - public void CopyTo(T[] array, int startIndex) - { - if (array == null) - throw new ArgumentNullException(nameof(array)); - if (startIndex < 0 || startIndex + 3 > array.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - array[startIndex] = X; - array[startIndex + 1] = Y; - array[startIndex + 2] = Z; - } - - /// Copies the components of the vector to the specified span starting at index 0. - public void CopyTo(Span span) => CopyTo(span, 0); - - /// Copies the components of the vector to the specified span starting at the given index. - public void CopyTo(Span span, int startIndex) - { - if (startIndex < 0 || startIndex + 3 > span.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - span[startIndex] = X; - span[startIndex + 1] = Y; - span[startIndex + 2] = Z; - } - /// Returns a vector where each component is the sign of the original vector's component. public Vector3I Sign() => new Vector3I(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y)), T.CreateChecked(T.Sign(Z))); @@ -270,130 +138,6 @@ public Vector3I CopySign(T signScalar) => public static Vector3I CopySign(Vector3I value, T signScalar) => new Vector3I(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar), T.CopySign(value.Z, signScalar)); - /// Parses a string to a instance. - public static Vector3I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); - - /// Tries to parse a span to a instance. - public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) - { - result = default; - - s = s.Trim(); - if (s.Length < 7 || s[0] != '<' || s[^1] != '>') - return false; - - s = s[1..^1]; // Remove < and > - - int firstComma = s.IndexOf(','); - if (firstComma < 0) - return false; - - // Kind of hacky, but it works - // TODO: See if there's a better way - ReadOnlySpan remainder = s.Slice(firstComma + 1); - int secondCommaRelative = remainder.IndexOf(','); - if (secondCommaRelative < 0) - return false; - - int secondComma = firstComma + 1 + secondCommaRelative; - if (secondComma < 0) - return false; - - ReadOnlySpan xSpan = s[..firstComma].Trim(); - ReadOnlySpan ySpan = s[(firstComma + 1)..secondComma].Trim(); - ReadOnlySpan zSpan = s[(secondComma + 1)..].Trim(); - - if (T.TryParse(xSpan, provider, out var x) && - T.TryParse(ySpan, provider, out var y) && - T.TryParse(zSpan, provider, out var z)) - { - result = new Vector3I(x, y, z); - return true; - } - - return false; - } - - /// Tries to parse a string to a instance. - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => - TryParse(s.AsSpan(), provider, out result); - - /// Parses a span to a instance. - static Vector3I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => - Parse(s, provider); - - /// Parses a string to a instance. - static Vector3I IParsable>.Parse(string s, IFormatProvider? provider) => - Parse(s, provider); - - /// Tries to parse a span to a instance. - static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => - TryParse(s, provider, out result); - - /// Tries to parse a string to a instance. - static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => - TryParse(s, provider, out result); - - /// Formats the vector as a UTF-8 string using the specified format and format provider. - public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) - { - // Format components individually into temporary buffers - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - Span zBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider) || - !Y.TryFormat(yBuffer, out int yChars, format, provider) || - !Z.TryFormat(zBuffer, out int zChars, format, provider)) - { - bytesWritten = 0; - return false; - } - - // Estimate total required UTF-8 bytes - int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + - Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + - Encoding.UTF8.GetByteCount(zBuffer[..zChars]) + - Encoding.UTF8.GetByteCount("<, , >"); - - if (utf8Destination.Length < estimatedSize) - { - bytesWritten = 0; - return false; - } - - int totalBytes = 0; - - totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(zBuffer[..zChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); - - bytesWritten = totalBytes; - return true; - } - - /// Parses a UTF-8 span to a instance. - public static Vector3I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return Parse(charBuffer, provider); - } - - /// Tries to parse a UTF-8 span to a instance. - public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return TryParse(charBuffer, provider, out result); - } - // Casts /// Explicitly casts a to a . @@ -404,77 +148,6 @@ public static explicit operator Vector3I(System.Numerics.Vector3 v) => public static explicit operator System.Numerics.Vector3(Vector3I v) => new System.Numerics.Vector3(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z)); - // Component Operators - public static Vector3I operator +(Vector3I left, Vector3I right) => - new Vector3I(left.X + right.X, left.Y + right.Y, left.Z + right.Z); - - public static Vector3I operator -(Vector3I left, Vector3I right) => - new Vector3I(left.X - right.X, left.Y - right.Y, left.Z - right.Z); - - public static Vector3I operator *(Vector3I left, Vector3I right) => - new Vector3I(left.X * right.X, left.Y * right.Y, left.Z * right.Z); - - public static Vector3I operator /(Vector3I left, Vector3I right) => - new Vector3I(left.X / right.X, left.Y / right.Y, left.Z / right.Z); - - public static Vector3I operator %(Vector3I left, Vector3I right) => - new Vector3I(left.X % right.X, left.Y % right.Y, left.Z % right.Z); - - // Scalar Operators - public static Vector3I operator +(Vector3I vector, T scalar) => - new Vector3I(vector.X + scalar, vector.Y + scalar, vector.Z + scalar); - - public static Vector3I operator -(Vector3I vector, T scalar) => - new Vector3I(vector.X - scalar, vector.Y - scalar, vector.Z - scalar); - - public static Vector3I operator *(Vector3I vector, T scalar) => - new Vector3I(vector.X * scalar, vector.Y * scalar, vector.Z * scalar); - - public static Vector3I operator /(Vector3I vector, T scalar) => - new Vector3I(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); - - public static Vector3I operator %(Vector3I vector, T scalar) => - new Vector3I(vector.X % scalar, vector.Y % scalar, vector.Z % scalar); - - // + operator: returns the vector (?) - public static Vector3I operator +(Vector3I vector) => vector; - - // - operator: returns the negated vector - public static Vector3I operator -(Vector3I vector) => - new Vector3I(-vector.X, -vector.Y, -vector.Z); - - // Bitwise Operators - public static Vector3I operator &(Vector3I left, Vector3I right) => - new Vector3I(left.X & right.X, left.Y & right.Y, left.Z & right.Z); - - public static Vector3I operator |(Vector3I left, Vector3I right) => - new Vector3I(left.X | right.X, left.Y | right.Y, left.Z | right.Z); - - public static Vector3I operator ^(Vector3I left, Vector3I right) => - new Vector3I(left.X ^ right.X, left.Y ^ right.Y, left.Z ^ right.Z); - - public static Vector3I operator &(Vector3I vector, T scalar) => - new Vector3I(vector.X & scalar, vector.Y & scalar, vector.Z & scalar); - - public static Vector3I operator &(T scalar, Vector3I vector) => - new Vector3I(scalar & vector.X, scalar & vector.Y, scalar & vector.Z); - - public static Vector3I operator |(Vector3I vector, T scalar) => - new Vector3I(vector.X | scalar, vector.Y | scalar, vector.Z | scalar); - - public static Vector3I operator |(T scalar, Vector3I vector) => - new Vector3I(scalar | vector.X, scalar | vector.Y, scalar | vector.Z); - - public static Vector3I operator ^(Vector3I vector, T scalar) => - new Vector3I(vector.X ^ scalar, vector.Y ^ scalar, vector.Z ^ scalar); - - public static Vector3I operator ^(T scalar, Vector3I vector) => - new Vector3I(scalar ^ vector.X, scalar ^ vector.Y, scalar ^ vector.Z); - - // NOT operator - public static Vector3I operator ~(Vector3I vector) => - new Vector3I(~vector.X, ~vector.Y, ~vector.Z); - // IBinaryInteger public static Vector3I Log2(Vector3I x) => new Vector3I(T.Log2(x.X), T.Log2(x.Y), T.Log2(x.Z)); diff --git a/sources/Maths/Maths/Vector3I.gen.cs b/sources/Maths/Maths/Vector3I.gen.cs index 45ee97e364..181ba38d8c 100644 --- a/sources/Maths/Maths/Vector3I.gen.cs +++ b/sources/Maths/Maths/Vector3I.gen.cs @@ -3,10 +3,18 @@ namespace Silk.NET.Maths using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.InteropServices; + using System.Text; partial struct Vector3I : IEquatable>, - IReadOnlyList + IReadOnlyList, + IFormattable, + IParsable>, + ISpanFormattable, + ISpanParsable>, + IUtf8SpanFormattable, + IUtf8SpanParsable> where T : IBinaryInteger { /// The X component of the vector. @@ -24,6 +32,35 @@ partial struct Vector3I : /// Initializes the vector with individual component values. public Vector3I(T x, T y, T z) => (X, Y, Z) = (x, y, z); + /// Initializes the vector from a span of 3 values. + public Vector3I(ReadOnlySpan values) + { + if (values.Length != 3) + throw new ArgumentException("Input span must contain exactly 3 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + Z = values[2]; + } + + /// Gets a vector whose 3 elements are equal to one. + public static Vector3I One => new(Scalar.One); + + /// Returns a vector whose 3 elements are equal to zero. + public static Vector3I Zero => default; + + /// Gets the vector (1, 0, 0). + public static Vector3I UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero); + + /// Gets the vector (0, 1, 0). + public static Vector3I UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero); + + /// Gets the vector (0, 0, 1). + public static Vector3I UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One); + + /// Gets a vector with all bits set for each component. + public static Vector3I AllBitsSet => new Vector3I(T.AllBitsSet, T.AllBitsSet, T.AllBitsSet); + /// T IReadOnlyList.this[int index] => this[index]; @@ -61,6 +98,220 @@ public IEnumerator GetEnumerator() yield return Z; } + /// Copies the components of the vector to the specified array starting at index 0. + public void CopyTo(T[] array) => CopyTo(array, 0); + + /// Copies the components of the vector to the specified array starting at the given index. + public void CopyTo(T[] array, int startIndex) + { + if (array == null) + throw new ArgumentNullException(nameof(array)); + if (startIndex < 0 || startIndex + 3 > array.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + array[startIndex] = X; + array[startIndex + 1] = Y; + array[startIndex + 2] = Z; + } + + /// Copies the components of the vector to the specified span starting at index 0. + public void CopyTo(Span span) => CopyTo(span, 0); + + /// Copies the components of the vector to the specified span starting at the given index. + public void CopyTo(Span span, int startIndex) + { + if (startIndex < 0 || startIndex + 3 > span.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + span[startIndex] = X; + span[startIndex + 1] = Y; + span[startIndex + 2] = Z; + } + + /// Returns a span over the vector components. + public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 3); + + /// Formats the vector as a string. + public override string ToString() => + $"<{X}, {Y}, {Z}>"; + + /// Formats the vector as a string using the specified format and format provider. + public string ToString(string? format, IFormatProvider? formatProvider) => + $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}, {Z.ToString(format, formatProvider)}>"; + + /// Parses a string to a instance. + public static Vector3I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + + /// Parses a span to a instance. + public static Vector3I Parse(ReadOnlySpan s, IFormatProvider? provider) + { + if (!TryParse(s, provider, out var result)) + throw new FormatException("Invalid format for Vector3I."); + + return result; + } + + /// Formats the vector as a UTF-8 string using the specified format and format provider. + public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + Span zBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider)|| + !Y.TryFormat(yBuffer, out int yChars, format, provider)|| + !Z.TryFormat(zBuffer, out int zChars, format, provider)) + { + bytesWritten = 0; + return false; + } + + int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + + Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + + Encoding.UTF8.GetByteCount(zBuffer[..zChars]) + + Encoding.UTF8.GetByteCount("<, >"); + + if (utf8Destination.Length < estimatedSize) + { + bytesWritten = 0; + return false; + } + + int totalBytes = 0; + + totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(zBuffer[..zChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); + + bytesWritten = totalBytes; + return true; + } + + /// Formats the vector as a string using the specified format and format provider. + public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + Span zBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider) || + !Z.TryFormat(zBuffer, out int zChars, format, provider)) + { + charsWritten = 0; + return false; + } + + int requiredLength = 1 + xChars + 2 + yChars + 2 + zChars + 1; + + if (destination.Length < requiredLength) + { + charsWritten = 0; + return false; + } + + int pos = 0; + destination[pos++] = '<'; + + xBuffer[..xChars].CopyTo(destination[pos..]); + pos += xChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + yBuffer[..yChars].CopyTo(destination[pos..]); + pos += yChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + zBuffer[..zChars].CopyTo(destination[pos..]); + pos += zChars; + + destination[pos++] = '>'; + + charsWritten = pos; + return true; + } + + /// Tries to parse a span to a instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) + { + result = default; + + s = s.Trim(); + if (s.Length < 6 || s[0] != '<' || s[^1] != '>') + return false; + + s = s[1..^1]; // Remove < and > + + int commaX = s.IndexOf(','); + if (commaX < 0) + return false; + + ReadOnlySpan remainder1 = s.Slice(commaX + 1); + int commaYRelative = remainder1.IndexOf(','); + if (commaYRelative < 0) + return false; + int commaY = commaX + 1 + commaYRelative; + + ReadOnlySpan xSpan = s[..commaX].Trim(); + ReadOnlySpan ySpan = s[(commaX + 1)..commaY].Trim(); + ReadOnlySpan zSpan = s[(commaY + 1)..].Trim(); + + if (T.TryParse(xSpan, provider, out var x) && + T.TryParse(ySpan, provider, out var y) && + T.TryParse(zSpan, provider, out var z)) + { + result = new Vector3I(x, y, z); + return true; + } + + return false; + } + + /// Parses a UTF-8 span to a instance. + public static Vector3I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return Parse(charBuffer, provider); + } + + /// Tries to parse a UTF-8 span to a instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return TryParse(charBuffer, provider, out result); + } + + /// Tries to parse a string to a instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => + TryParse(s.AsSpan(), provider, out result); + + /// Parses a span to a instance. + static Vector3I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + Parse(s, provider); + + /// Parses a string to a instance. + static Vector3I IParsable>.Parse(string s, IFormatProvider? provider) => + Parse(s, provider); + + /// Tries to parse a span to a instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => + TryParse(s, provider, out result); + + /// Tries to parse a string to a instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => + TryParse(s, provider, out result); + /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. @@ -84,6 +335,75 @@ public IEnumerator GetEnumerator() /// public override int GetHashCode() => HashCode.Combine(X, Y, Z); + + public static Vector3I operator +(Vector3I vector) => + vector; + + public static Vector3I operator -(Vector3I vector) => + new Vector3I(-vector.X, -vector.Y, -vector.Z); + + public static Vector3I operator +(Vector3I left, Vector3I right) => + new Vector3I(left.X + right.X, left.Y + right.Y, left.Z + right.Z); + + public static Vector3I operator -(Vector3I left, Vector3I right) => + new Vector3I(left.X - right.X, left.Y - right.Y, left.Z - right.Z); + + public static Vector3I operator *(Vector3I left, Vector3I right) => + new Vector3I(left.X * right.X, left.Y * right.Y, left.Z * right.Z); + + public static Vector3I operator /(Vector3I left, Vector3I right) => + new Vector3I(left.X / right.X, left.Y / right.Y, left.Z / right.Z); + + public static Vector3I operator %(Vector3I left, Vector3I right) => + new Vector3I(left.X % right.X, left.Y % right.Y, left.Z % right.Z); + + public static Vector3I operator +(Vector3I vector, T scalar) => + new Vector3I(vector.X + scalar, vector.Y + scalar, vector.Z + scalar); + + public static Vector3I operator -(Vector3I vector, T scalar) => + new Vector3I(vector.X - scalar, vector.Y - scalar, vector.Z - scalar); + + public static Vector3I operator *(Vector3I vector, T scalar) => + new Vector3I(vector.X * scalar, vector.Y * scalar, vector.Z * scalar); + + public static Vector3I operator *(T scalar, Vector3I vector) => + new Vector3I(scalar * vector.X, scalar * vector.Y, scalar * vector.Z); + + public static Vector3I operator /(Vector3I vector, T scalar) => + new Vector3I(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); + + public static Vector3I operator %(Vector3I vector, T scalar) => + new Vector3I(vector.X % scalar, vector.Y % scalar, vector.Z % scalar); + + public static Vector3I operator ~(Vector3I vector) => + new Vector3I(~vector.X, ~vector.Y, ~vector.Z); + + public static Vector3I operator &(Vector3I left, Vector3I right) => + new Vector3I(left.X & right.X, left.Y & right.Y, left.Z & right.Z); + + public static Vector3I operator |(Vector3I left, Vector3I right) => + new Vector3I(left.X | right.X, left.Y | right.Y, left.Z | right.Z); + + public static Vector3I operator ^(Vector3I left, Vector3I right) => + new Vector3I(left.X ^ right.X, left.Y ^ right.Y, left.Z ^ right.Z); + + public static Vector3I operator &(Vector3I vector, T scalar) => + new Vector3I(vector.X & scalar, vector.Y & scalar, vector.Z & scalar); + + public static Vector3I operator &(T scalar, Vector3I vector) => + new Vector3I(scalar & vector.X, scalar & vector.Y, scalar & vector.Z); + + public static Vector3I operator |(Vector3I vector, T scalar) => + new Vector3I(vector.X | scalar, vector.Y | scalar, vector.Z | scalar); + + public static Vector3I operator |(T scalar, Vector3I vector) => + new Vector3I(scalar | vector.X, scalar | vector.Y, scalar | vector.Z); + + public static Vector3I operator ^(Vector3I vector, T scalar) => + new Vector3I(vector.X ^ scalar, vector.Y ^ scalar, vector.Z ^ scalar); + + public static Vector3I operator ^(T scalar, Vector3I vector) => + new Vector3I(scalar ^ vector.X, scalar ^ vector.Y, scalar ^ vector.Z); } static partial class Vector3I diff --git a/sources/Maths/Maths/Vector4F.gen.cs b/sources/Maths/Maths/Vector4F.gen.cs index 871162afc5..b97dbf436f 100644 --- a/sources/Maths/Maths/Vector4F.gen.cs +++ b/sources/Maths/Maths/Vector4F.gen.cs @@ -3,10 +3,18 @@ namespace Silk.NET.Maths using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.InteropServices; + using System.Text; partial struct Vector4F : IEquatable>, - IReadOnlyList + IReadOnlyList, + IFormattable, + IParsable>, + ISpanFormattable, + ISpanParsable>, + IUtf8SpanFormattable, + IUtf8SpanParsable> where T : IFloatingPointIeee754 { /// The X component of the vector. @@ -27,6 +35,36 @@ partial struct Vector4F : /// Initializes the vector with individual component values. public Vector4F(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); + /// Initializes the vector from a span of 4 values. + public Vector4F(ReadOnlySpan values) + { + if (values.Length != 4) + throw new ArgumentException("Input span must contain exactly 4 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + Z = values[2]; + W = values[3]; + } + + /// Gets a vector whose 4 elements are equal to one. + public static Vector4F One => new(Scalar.One); + + /// Returns a vector whose 4 elements are equal to zero. + public static Vector4F Zero => default; + + /// Gets the vector (1, 0, 0, 0). + public static Vector4F UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero, Scalar.Zero); + + /// Gets the vector (0, 1, 0, 0). + public static Vector4F UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero, Scalar.Zero); + + /// Gets the vector (0, 0, 1, 0). + public static Vector4F UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One, Scalar.Zero); + + /// Gets the vector (0, 0, 0, 1). + public static Vector4F UnitW => new(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); + /// T IReadOnlyList.this[int index] => this[index]; @@ -67,6 +105,243 @@ public IEnumerator GetEnumerator() yield return W; } + /// Copies the components of the vector to the specified array starting at index 0. + public void CopyTo(T[] array) => CopyTo(array, 0); + + /// Copies the components of the vector to the specified array starting at the given index. + public void CopyTo(T[] array, int startIndex) + { + if (array == null) + throw new ArgumentNullException(nameof(array)); + if (startIndex < 0 || startIndex + 4 > array.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + array[startIndex] = X; + array[startIndex + 1] = Y; + array[startIndex + 2] = Z; + array[startIndex + 3] = W; + } + + /// Copies the components of the vector to the specified span starting at index 0. + public void CopyTo(Span span) => CopyTo(span, 0); + + /// Copies the components of the vector to the specified span starting at the given index. + public void CopyTo(Span span, int startIndex) + { + if (startIndex < 0 || startIndex + 4 > span.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + span[startIndex] = X; + span[startIndex + 1] = Y; + span[startIndex + 2] = Z; + span[startIndex + 3] = W; + } + + /// Returns a span over the vector components. + public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 4); + + /// Formats the vector as a string. + public override string ToString() => + $"<{X}, {Y}, {Z}, {W}>"; + + /// Formats the vector as a string using the specified format and format provider. + public string ToString(string? format, IFormatProvider? formatProvider) => + $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}, {Z.ToString(format, formatProvider)}, {W.ToString(format, formatProvider)}>"; + + /// Parses a string to a instance. + public static Vector4F Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + + /// Parses a span to a instance. + public static Vector4F Parse(ReadOnlySpan s, IFormatProvider? provider) + { + if (!TryParse(s, provider, out var result)) + throw new FormatException("Invalid format for Vector4F."); + + return result; + } + + /// Formats the vector as a UTF-8 string using the specified format and format provider. + public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + Span zBuffer = stackalloc char[64]; + Span wBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider)|| + !Y.TryFormat(yBuffer, out int yChars, format, provider)|| + !Z.TryFormat(zBuffer, out int zChars, format, provider)|| + !W.TryFormat(wBuffer, out int wChars, format, provider)) + { + bytesWritten = 0; + return false; + } + + int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + + Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + + Encoding.UTF8.GetByteCount(zBuffer[..zChars]) + + Encoding.UTF8.GetByteCount(wBuffer[..wChars]) + + Encoding.UTF8.GetByteCount("<, >"); + + if (utf8Destination.Length < estimatedSize) + { + bytesWritten = 0; + return false; + } + + int totalBytes = 0; + + totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(zBuffer[..zChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(wBuffer[..wChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); + + bytesWritten = totalBytes; + return true; + } + + /// Formats the vector as a string using the specified format and format provider. + public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + Span zBuffer = stackalloc char[64]; + Span wBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider) || + !Z.TryFormat(zBuffer, out int zChars, format, provider) || + !W.TryFormat(wBuffer, out int wChars, format, provider)) + { + charsWritten = 0; + return false; + } + + int requiredLength = 1 + xChars + 2 + yChars + 2 + zChars + 2 + wChars + 1; + + if (destination.Length < requiredLength) + { + charsWritten = 0; + return false; + } + + int pos = 0; + destination[pos++] = '<'; + + xBuffer[..xChars].CopyTo(destination[pos..]); + pos += xChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + yBuffer[..yChars].CopyTo(destination[pos..]); + pos += yChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + zBuffer[..zChars].CopyTo(destination[pos..]); + pos += zChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + wBuffer[..wChars].CopyTo(destination[pos..]); + pos += wChars; + + destination[pos++] = '>'; + + charsWritten = pos; + return true; + } + + /// Tries to parse a span to a instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4F result) + { + result = default; + + s = s.Trim(); + if (s.Length < 8 || s[0] != '<' || s[^1] != '>') + return false; + + s = s[1..^1]; // Remove < and > + + int commaX = s.IndexOf(','); + if (commaX < 0) + return false; + + ReadOnlySpan remainder1 = s.Slice(commaX + 1); + int commaYRelative = remainder1.IndexOf(','); + if (commaYRelative < 0) + return false; + int commaY = commaX + 1 + commaYRelative; + + ReadOnlySpan remainder2 = s.Slice(commaY + 1); + int commaZRelative = remainder2.IndexOf(','); + if (commaZRelative < 0) + return false; + int commaZ = commaY + 1 + commaZRelative; + + ReadOnlySpan xSpan = s[..commaX].Trim(); + ReadOnlySpan ySpan = s[(commaX + 1)..commaY].Trim(); + ReadOnlySpan zSpan = s[(commaY + 1)..commaZ].Trim(); + ReadOnlySpan wSpan = s[(commaZ + 1)..].Trim(); + + if (T.TryParse(xSpan, provider, out var x) && + T.TryParse(ySpan, provider, out var y) && + T.TryParse(zSpan, provider, out var z) && + T.TryParse(wSpan, provider, out var w)) + { + result = new Vector4F(x, y, z, w); + return true; + } + + return false; + } + + /// Parses a UTF-8 span to a instance. + public static Vector4F Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return Parse(charBuffer, provider); + } + + /// Tries to parse a UTF-8 span to a instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4F result) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return TryParse(charBuffer, provider, out result); + } + + /// Tries to parse a string to a instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4F result) => + TryParse(s.AsSpan(), provider, out result); + + /// Parses a span to a instance. + static Vector4F ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + Parse(s, provider); + + /// Parses a string to a instance. + static Vector4F IParsable>.Parse(string s, IFormatProvider? provider) => + Parse(s, provider); + + /// Tries to parse a span to a instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4F result) => + TryParse(s, provider, out result); + + /// Tries to parse a string to a instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4F result) => + TryParse(s, provider, out result); + /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. @@ -91,6 +366,46 @@ public IEnumerator GetEnumerator() /// public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); + + public static Vector4F operator +(Vector4F vector) => + vector; + + public static Vector4F operator -(Vector4F vector) => + new Vector4F(-vector.X, -vector.Y, -vector.Z, -vector.W); + + public static Vector4F operator +(Vector4F left, Vector4F right) => + new Vector4F(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); + + public static Vector4F operator -(Vector4F left, Vector4F right) => + new Vector4F(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); + + public static Vector4F operator *(Vector4F left, Vector4F right) => + new Vector4F(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W); + + public static Vector4F operator /(Vector4F left, Vector4F right) => + new Vector4F(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W); + + public static Vector4F operator %(Vector4F left, Vector4F right) => + new Vector4F(left.X % right.X, left.Y % right.Y, left.Z % right.Z, left.W % right.W); + + public static Vector4F operator +(Vector4F vector, T scalar) => + new Vector4F(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar); + + public static Vector4F operator -(Vector4F vector, T scalar) => + new Vector4F(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar); + + public static Vector4F operator *(Vector4F vector, T scalar) => + new Vector4F(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar); + + public static Vector4F operator *(T scalar, Vector4F vector) => + new Vector4F(scalar * vector.X, scalar * vector.Y, scalar * vector.Z, scalar * vector.W); + + public static Vector4F operator /(Vector4F vector, T scalar) => + new Vector4F(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); + + public static Vector4F operator %(Vector4F vector, T scalar) => + new Vector4F(vector.X % scalar, vector.Y % scalar, vector.Z % scalar, vector.W % scalar); + } static partial class Vector4F diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs index 2386d7c797..9952e08574 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4I.cs @@ -11,27 +11,8 @@ namespace Silk.NET.Maths { /// A structure representing a 4D integer vector. - internal partial struct Vector4I : - ISpanFormattable, - ISpanParsable>, - IUtf8SpanFormattable, - IUtf8SpanParsable>, - IParsable>, - IFormattable - where T : IBinaryInteger + internal partial struct Vector4I { - /// Initializes the vector from a span of four values. - public Vector4I(ReadOnlySpan values) - { - if (values.Length != 4) - throw new ArgumentException("Input span must contain exactly 4 elements.", nameof(values)); - - X = values[0]; - Y = values[1]; - Z = values[2]; - W = values[3]; - } - /// Initializes the vector using a Vector2I for X and Y, and a separate value for Z and W. // TODO: Make sure lower dimensional constructors arent meant to zero-out the higher dimensions public Vector4I(Vector2I xy, T z, T w) => (X, Y, Z, W) = (xy.X, xy.Y, z, w); @@ -39,27 +20,6 @@ public Vector4I(ReadOnlySpan values) /// Initializes the vector using a Vector3I for X, Y and Z, and a separate value for W. public Vector4I(Vector3I xyz, T w) => (X, Y, Z, W) = (xyz.X, xyz.Y, xyz.Z, w); - /// Gets a vector whose 4 elements are equal to one. - public static Vector4I One => new(Scalar.One); - - /// Returns a vector whose 4 elements are equal to zero. - public static Vector4I Zero => default; - - /// Gets the vector (1, 0, 0, 0). - public static Vector4I UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero, Scalar.Zero); - - /// Gets the vector (0, 1, 0, 0). - public static Vector4I UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero, Scalar.Zero); - - /// Gets the vector (0, 0, 1, 0). - public static Vector4I UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One, Scalar.Zero); - - /// Gets the vector (0, 0, 0, 1). - public static Vector4I UnitW => new(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); - - /// Gets a vector with all bits set for each component. - public static Vector4I AllBitsSet => new Vector4I(T.AllBitsSet, T.AllBitsSet, T.AllBitsSet, T.AllBitsSet); - /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => (X * X) + (Y * Y) + (Z * Z) + (W * W); @@ -69,9 +29,6 @@ public Vector4I(ReadOnlySpan values) /// Computes the dot product of two vectors. public static T Dot(Vector4I left, Vector4I right) => (left.X * right.X) + (left.Y * right.Y) + (left.Z * right.Z) + (left.W * right.W); - /// Returns a span over the vector components. - public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 4); - /// Returns a vector with the component-wise maximum of this and another vector. public Vector4I Max(Vector4I other) => new Vector4I(T.Max(X, other.X), T.Max(Y, other.Y), T.Max(Z, other.Z), T.Max(W, other.W)); @@ -147,109 +104,6 @@ public static Vector4I Clamp(Vector4I vector, T min, T max) => public static Vector4I Abs(Vector4I vector) => new Vector4I(T.Abs(vector.X), T.Abs(vector.Y), T.Abs(vector.Z), T.Abs(vector.W)); - /// Formats the vector as a string using the specified format and format provider. - public string ToString(string? format, IFormatProvider? formatProvider) => - $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}, {Z.ToString(format, formatProvider)}, {W.ToString(format, formatProvider)}>"; - - /// Formats the vector as a string. - public override string ToString() => $"<{X}, {Y}, {Z}, {W}>"; - - /// Formats the vector as a string using the specified format and format provider. - public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - // Format components individually into temporary buffers - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - Span zBuffer = stackalloc char[64]; - Span wBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider) || - !Y.TryFormat(yBuffer, out int yChars, format, provider) || - !Z.TryFormat(zBuffer, out int zChars, format, provider) || - !W.TryFormat(wBuffer, out int wChars, format, provider)) - { - charsWritten = 0; - return false; - } - - // Calculate total required length: < + x + ", " + y + ", " + z + ", " + w + > - int requiredLength = 1 + xChars + 2 + yChars + 2 + zChars + 2 + wChars + 1; - - if (destination.Length < requiredLength) - { - charsWritten = 0; - return false; - } - - int pos = 0; - destination[pos++] = '<'; - - xBuffer[..xChars].CopyTo(destination[pos..]); - pos += xChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - yBuffer[..yChars].CopyTo(destination[pos..]); - pos += yChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - zBuffer[..zChars].CopyTo(destination[pos..]); - pos += zChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - wBuffer[..wChars].CopyTo(destination[pos..]); - pos += wChars; - - destination[pos++] = '>'; - - charsWritten = pos; - return true; - } - - /// Parses a span to a Vector4I instance. - public static Vector4I Parse(ReadOnlySpan s, IFormatProvider? provider) - { - if (!TryParse(s, provider, out var result)) - throw new FormatException("Invalid format for Vector4I."); - - return result; - } - - /// Copies the components of the vector to the specified array starting at index 0. - public void CopyTo(T[] array) => CopyTo(array, 0); - - /// Copies the components of the vector to the specified array starting at the given index. - public void CopyTo(T[] array, int startIndex) - { - if (array == null) - throw new ArgumentNullException(nameof(array)); - if (startIndex < 0 || startIndex + 4 > array.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - array[startIndex] = X; - array[startIndex + 1] = Y; - array[startIndex + 2] = Z; - array[startIndex + 3] = W; - } - - /// Copies the components of the vector to the specified span starting at index 0. - public void CopyTo(Span span) => CopyTo(span, 0); - - /// Copies the components of the vector to the specified span starting at the given index. - public void CopyTo(Span span, int startIndex) - { - if (startIndex < 0 || startIndex + 4 > span.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - span[startIndex] = X; - span[startIndex + 1] = Y; - span[startIndex + 2] = Z; - span[startIndex + 3] = W; - } - /// Returns a vector where each component is the sign of the original vector's component. public Vector4I Sign() => new Vector4I(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y)), T.CreateChecked(T.Sign(Z)), T.CreateChecked(T.Sign(W))); @@ -274,138 +128,6 @@ public Vector4I CopySign(T signScalar) => public static Vector4I CopySign(Vector4I value, T signScalar) => new Vector4I(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar), T.CopySign(value.Z, signScalar), T.CopySign(value.W, signScalar)); - /// Parses a string to a Vector4I instance. - public static Vector4I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); - - /// Tries to parse a span to a Vector4I instance. - public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) - { - result = default; - - s = s.Trim(); - if (s.Length < 9 || s[0] != '<' || s[^1] != '>') - return false; - - s = s[1..^1]; // Remove < and > - - int firstComma = s.IndexOf(','); - if (firstComma < 0) - return false; - - ReadOnlySpan remainder1 = s.Slice(firstComma + 1); - int secondCommaRelative = remainder1.IndexOf(','); - if (secondCommaRelative < 0) - return false; - int secondComma = firstComma + 1 + secondCommaRelative; - - ReadOnlySpan remainder2 = s.Slice(secondComma + 1); - int thirdCommaRelative = remainder2.IndexOf(','); - if (thirdCommaRelative < 0) - return false; - int thirdComma = secondComma + 1 + thirdCommaRelative; - - ReadOnlySpan xSpan = s[..firstComma].Trim(); - ReadOnlySpan ySpan = s[(firstComma + 1)..secondComma].Trim(); - ReadOnlySpan zSpan = s[(secondComma + 1)..thirdComma].Trim(); - ReadOnlySpan wSpan = s[(thirdComma + 1)..].Trim(); - - if (T.TryParse(xSpan, provider, out var x) && - T.TryParse(ySpan, provider, out var y) && - T.TryParse(zSpan, provider, out var z) && - T.TryParse(wSpan, provider, out var w)) - { - result = new Vector4I(x, y, z, w); - return true; - } - - return false; - } - - /// Tries to parse a string to a Vector4I instance. - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => - TryParse(s.AsSpan(), provider, out result); - - /// Parses a span to a Vector4I instance. - static Vector4I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => - Parse(s, provider); - - /// Parses a string to a Vector4I instance. - static Vector4I IParsable>.Parse(string s, IFormatProvider? provider) => - Parse(s, provider); - - /// Tries to parse a span to a Vector4I instance. - static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => - TryParse(s, provider, out result); - - /// Tries to parse a string to a Vector4I instance. - static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => - TryParse(s, provider, out result); - - /// Formats the vector as a UTF-8 string using the specified format and format provider. - public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) - { - // Format components individually into temporary buffers - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - Span zBuffer = stackalloc char[64]; - Span wBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider) || - !Y.TryFormat(yBuffer, out int yChars, format, provider) || - !Z.TryFormat(zBuffer, out int zChars, format, provider) || - !W.TryFormat(wBuffer, out int wChars, format, provider)) - { - bytesWritten = 0; - return false; - } - - // Estimate total required UTF-8 bytes - int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + - Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + - Encoding.UTF8.GetByteCount(zBuffer[..zChars]) + - Encoding.UTF8.GetByteCount(wBuffer[..wChars]) + - Encoding.UTF8.GetByteCount("<, , , >"); - - if (utf8Destination.Length < estimatedSize) - { - bytesWritten = 0; - return false; - } - - int totalBytes = 0; - - totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(zBuffer[..zChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(wBuffer[..wChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); - - bytesWritten = totalBytes; - return true; - } - - /// Parses a UTF-8 span to a Vector4I instance. - public static Vector4I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return Parse(charBuffer, provider); - } - - /// Tries to parse a UTF-8 span to a Vector4I instance. - public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return TryParse(charBuffer, provider, out result); - } - // Casts /// Explicitly casts a System.Numerics.Vector4 to a Vector4I. @@ -416,77 +138,6 @@ public static explicit operator Vector4I(System.Numerics.Vector4 v) => public static explicit operator System.Numerics.Vector4(Vector4I v) => new System.Numerics.Vector4(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z), Convert.ToSingle(v.W)); - // Component Operators - public static Vector4I operator +(Vector4I left, Vector4I right) => - new Vector4I(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); - - public static Vector4I operator -(Vector4I left, Vector4I right) => - new Vector4I(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); - - public static Vector4I operator *(Vector4I left, Vector4I right) => - new Vector4I(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W); - - public static Vector4I operator /(Vector4I left, Vector4I right) => - new Vector4I(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W); - - public static Vector4I operator %(Vector4I left, Vector4I right) => - new Vector4I(left.X % right.X, left.Y % right.Y, left.Z % right.Z, left.W % right.W); - - // Scalar Operators - public static Vector4I operator +(Vector4I vector, T scalar) => - new Vector4I(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar); - - public static Vector4I operator -(Vector4I vector, T scalar) => - new Vector4I(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar); - - public static Vector4I operator *(Vector4I vector, T scalar) => - new Vector4I(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar); - - public static Vector4I operator /(Vector4I vector, T scalar) => - new Vector4I(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); - - public static Vector4I operator %(Vector4I vector, T scalar) => - new Vector4I(vector.X % scalar, vector.Y % scalar, vector.Z % scalar, vector.W % scalar); - - // + operator: returns the vector (?) - public static Vector4I operator +(Vector4I vector) => vector; - - // - operator: returns the negated vector - public static Vector4I operator -(Vector4I vector) => - new Vector4I(-vector.X, -vector.Y, -vector.Z, -vector.W); - - // Bitwise Operators - public static Vector4I operator &(Vector4I left, Vector4I right) => - new Vector4I(left.X & right.X, left.Y & right.Y, left.Z & right.Z, left.W & right.W); - - public static Vector4I operator |(Vector4I left, Vector4I right) => - new Vector4I(left.X | right.X, left.Y | right.Y, left.Z | right.Z, left.W | right.W); - - public static Vector4I operator ^(Vector4I left, Vector4I right) => - new Vector4I(left.X ^ right.X, left.Y ^ right.Y, left.Z ^ right.Z, left.W ^ right.W); - - public static Vector4I operator &(Vector4I vector, T scalar) => - new Vector4I(vector.X & scalar, vector.Y & scalar, vector.Z & scalar, vector.W & scalar); - - public static Vector4I operator &(T scalar, Vector4I vector) => - new Vector4I(scalar & vector.X, scalar & vector.Y, scalar & vector.Z, scalar & vector.W); - - public static Vector4I operator |(Vector4I vector, T scalar) => - new Vector4I(vector.X | scalar, vector.Y | scalar, vector.Z | scalar, vector.W | scalar); - - public static Vector4I operator |(T scalar, Vector4I vector) => - new Vector4I(scalar | vector.X, scalar | vector.Y, scalar | vector.Z, scalar | vector.W); - - public static Vector4I operator ^(Vector4I vector, T scalar) => - new Vector4I(vector.X ^ scalar, vector.Y ^ scalar, vector.Z ^ scalar, vector.W ^ scalar); - - public static Vector4I operator ^(T scalar, Vector4I vector) => - new Vector4I(scalar ^ vector.X, scalar ^ vector.Y, scalar ^ vector.Z, scalar ^ vector.W); - - // NOT operator - public static Vector4I operator ~(Vector4I vector) => - new Vector4I(~vector.X, ~vector.Y, ~vector.Z, ~vector.W); - // IBinaryInteger public static Vector4I Log2(Vector4I x) => new Vector4I(T.Log2(x.X), T.Log2(x.Y), T.Log2(x.Z), T.Log2(x.W)); diff --git a/sources/Maths/Maths/Vector4I.gen.cs b/sources/Maths/Maths/Vector4I.gen.cs index ef2d344376..37bab5858b 100644 --- a/sources/Maths/Maths/Vector4I.gen.cs +++ b/sources/Maths/Maths/Vector4I.gen.cs @@ -3,10 +3,18 @@ namespace Silk.NET.Maths using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.InteropServices; + using System.Text; partial struct Vector4I : IEquatable>, - IReadOnlyList + IReadOnlyList, + IFormattable, + IParsable>, + ISpanFormattable, + ISpanParsable>, + IUtf8SpanFormattable, + IUtf8SpanParsable> where T : IBinaryInteger { /// The X component of the vector. @@ -27,6 +35,39 @@ partial struct Vector4I : /// Initializes the vector with individual component values. public Vector4I(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); + /// Initializes the vector from a span of 4 values. + public Vector4I(ReadOnlySpan values) + { + if (values.Length != 4) + throw new ArgumentException("Input span must contain exactly 4 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + Z = values[2]; + W = values[3]; + } + + /// Gets a vector whose 4 elements are equal to one. + public static Vector4I One => new(Scalar.One); + + /// Returns a vector whose 4 elements are equal to zero. + public static Vector4I Zero => default; + + /// Gets the vector (1, 0, 0, 0). + public static Vector4I UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero, Scalar.Zero); + + /// Gets the vector (0, 1, 0, 0). + public static Vector4I UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero, Scalar.Zero); + + /// Gets the vector (0, 0, 1, 0). + public static Vector4I UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One, Scalar.Zero); + + /// Gets the vector (0, 0, 0, 1). + public static Vector4I UnitW => new(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); + + /// Gets a vector with all bits set for each component. + public static Vector4I AllBitsSet => new Vector4I(T.AllBitsSet, T.AllBitsSet, T.AllBitsSet, T.AllBitsSet); + /// T IReadOnlyList.this[int index] => this[index]; @@ -67,6 +108,243 @@ public IEnumerator GetEnumerator() yield return W; } + /// Copies the components of the vector to the specified array starting at index 0. + public void CopyTo(T[] array) => CopyTo(array, 0); + + /// Copies the components of the vector to the specified array starting at the given index. + public void CopyTo(T[] array, int startIndex) + { + if (array == null) + throw new ArgumentNullException(nameof(array)); + if (startIndex < 0 || startIndex + 4 > array.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + array[startIndex] = X; + array[startIndex + 1] = Y; + array[startIndex + 2] = Z; + array[startIndex + 3] = W; + } + + /// Copies the components of the vector to the specified span starting at index 0. + public void CopyTo(Span span) => CopyTo(span, 0); + + /// Copies the components of the vector to the specified span starting at the given index. + public void CopyTo(Span span, int startIndex) + { + if (startIndex < 0 || startIndex + 4 > span.Length) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + span[startIndex] = X; + span[startIndex + 1] = Y; + span[startIndex + 2] = Z; + span[startIndex + 3] = W; + } + + /// Returns a span over the vector components. + public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 4); + + /// Formats the vector as a string. + public override string ToString() => + $"<{X}, {Y}, {Z}, {W}>"; + + /// Formats the vector as a string using the specified format and format provider. + public string ToString(string? format, IFormatProvider? formatProvider) => + $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}, {Z.ToString(format, formatProvider)}, {W.ToString(format, formatProvider)}>"; + + /// Parses a string to a instance. + public static Vector4I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + + /// Parses a span to a instance. + public static Vector4I Parse(ReadOnlySpan s, IFormatProvider? provider) + { + if (!TryParse(s, provider, out var result)) + throw new FormatException("Invalid format for Vector4I."); + + return result; + } + + /// Formats the vector as a UTF-8 string using the specified format and format provider. + public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + Span zBuffer = stackalloc char[64]; + Span wBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider)|| + !Y.TryFormat(yBuffer, out int yChars, format, provider)|| + !Z.TryFormat(zBuffer, out int zChars, format, provider)|| + !W.TryFormat(wBuffer, out int wChars, format, provider)) + { + bytesWritten = 0; + return false; + } + + int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + + Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + + Encoding.UTF8.GetByteCount(zBuffer[..zChars]) + + Encoding.UTF8.GetByteCount(wBuffer[..wChars]) + + Encoding.UTF8.GetByteCount("<, >"); + + if (utf8Destination.Length < estimatedSize) + { + bytesWritten = 0; + return false; + } + + int totalBytes = 0; + + totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(zBuffer[..zChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(wBuffer[..wChars], utf8Destination[totalBytes..]); + totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); + + bytesWritten = totalBytes; + return true; + } + + /// Formats the vector as a string using the specified format and format provider. + public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) + { + Span xBuffer = stackalloc char[64]; + Span yBuffer = stackalloc char[64]; + Span zBuffer = stackalloc char[64]; + Span wBuffer = stackalloc char[64]; + + if (!X.TryFormat(xBuffer, out int xChars, format, provider) || + !Y.TryFormat(yBuffer, out int yChars, format, provider) || + !Z.TryFormat(zBuffer, out int zChars, format, provider) || + !W.TryFormat(wBuffer, out int wChars, format, provider)) + { + charsWritten = 0; + return false; + } + + int requiredLength = 1 + xChars + 2 + yChars + 2 + zChars + 2 + wChars + 1; + + if (destination.Length < requiredLength) + { + charsWritten = 0; + return false; + } + + int pos = 0; + destination[pos++] = '<'; + + xBuffer[..xChars].CopyTo(destination[pos..]); + pos += xChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + yBuffer[..yChars].CopyTo(destination[pos..]); + pos += yChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + zBuffer[..zChars].CopyTo(destination[pos..]); + pos += zChars; + + destination[pos++] = ','; + destination[pos++] = ' '; + + wBuffer[..wChars].CopyTo(destination[pos..]); + pos += wChars; + + destination[pos++] = '>'; + + charsWritten = pos; + return true; + } + + /// Tries to parse a span to a instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) + { + result = default; + + s = s.Trim(); + if (s.Length < 8 || s[0] != '<' || s[^1] != '>') + return false; + + s = s[1..^1]; // Remove < and > + + int commaX = s.IndexOf(','); + if (commaX < 0) + return false; + + ReadOnlySpan remainder1 = s.Slice(commaX + 1); + int commaYRelative = remainder1.IndexOf(','); + if (commaYRelative < 0) + return false; + int commaY = commaX + 1 + commaYRelative; + + ReadOnlySpan remainder2 = s.Slice(commaY + 1); + int commaZRelative = remainder2.IndexOf(','); + if (commaZRelative < 0) + return false; + int commaZ = commaY + 1 + commaZRelative; + + ReadOnlySpan xSpan = s[..commaX].Trim(); + ReadOnlySpan ySpan = s[(commaX + 1)..commaY].Trim(); + ReadOnlySpan zSpan = s[(commaY + 1)..commaZ].Trim(); + ReadOnlySpan wSpan = s[(commaZ + 1)..].Trim(); + + if (T.TryParse(xSpan, provider, out var x) && + T.TryParse(ySpan, provider, out var y) && + T.TryParse(zSpan, provider, out var z) && + T.TryParse(wSpan, provider, out var w)) + { + result = new Vector4I(x, y, z, w); + return true; + } + + return false; + } + + /// Parses a UTF-8 span to a instance. + public static Vector4I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return Parse(charBuffer, provider); + } + + /// Tries to parse a UTF-8 span to a instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) + { + int charCount = Encoding.UTF8.GetCharCount(utf8Text); + Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; + Encoding.UTF8.GetChars(utf8Text, charBuffer); + return TryParse(charBuffer, provider, out result); + } + + /// Tries to parse a string to a instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => + TryParse(s.AsSpan(), provider, out result); + + /// Parses a span to a instance. + static Vector4I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + Parse(s, provider); + + /// Parses a string to a instance. + static Vector4I IParsable>.Parse(string s, IFormatProvider? provider) => + Parse(s, provider); + + /// Tries to parse a span to a instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => + TryParse(s, provider, out result); + + /// Tries to parse a string to a instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => + TryParse(s, provider, out result); + /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. @@ -91,6 +369,75 @@ public IEnumerator GetEnumerator() /// public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); + + public static Vector4I operator +(Vector4I vector) => + vector; + + public static Vector4I operator -(Vector4I vector) => + new Vector4I(-vector.X, -vector.Y, -vector.Z, -vector.W); + + public static Vector4I operator +(Vector4I left, Vector4I right) => + new Vector4I(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); + + public static Vector4I operator -(Vector4I left, Vector4I right) => + new Vector4I(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); + + public static Vector4I operator *(Vector4I left, Vector4I right) => + new Vector4I(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W); + + public static Vector4I operator /(Vector4I left, Vector4I right) => + new Vector4I(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W); + + public static Vector4I operator %(Vector4I left, Vector4I right) => + new Vector4I(left.X % right.X, left.Y % right.Y, left.Z % right.Z, left.W % right.W); + + public static Vector4I operator +(Vector4I vector, T scalar) => + new Vector4I(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar); + + public static Vector4I operator -(Vector4I vector, T scalar) => + new Vector4I(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar); + + public static Vector4I operator *(Vector4I vector, T scalar) => + new Vector4I(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar); + + public static Vector4I operator *(T scalar, Vector4I vector) => + new Vector4I(scalar * vector.X, scalar * vector.Y, scalar * vector.Z, scalar * vector.W); + + public static Vector4I operator /(Vector4I vector, T scalar) => + new Vector4I(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); + + public static Vector4I operator %(Vector4I vector, T scalar) => + new Vector4I(vector.X % scalar, vector.Y % scalar, vector.Z % scalar, vector.W % scalar); + + public static Vector4I operator ~(Vector4I vector) => + new Vector4I(~vector.X, ~vector.Y, ~vector.Z, ~vector.W); + + public static Vector4I operator &(Vector4I left, Vector4I right) => + new Vector4I(left.X & right.X, left.Y & right.Y, left.Z & right.Z, left.W & right.W); + + public static Vector4I operator |(Vector4I left, Vector4I right) => + new Vector4I(left.X | right.X, left.Y | right.Y, left.Z | right.Z, left.W | right.W); + + public static Vector4I operator ^(Vector4I left, Vector4I right) => + new Vector4I(left.X ^ right.X, left.Y ^ right.Y, left.Z ^ right.Z, left.W ^ right.W); + + public static Vector4I operator &(Vector4I vector, T scalar) => + new Vector4I(vector.X & scalar, vector.Y & scalar, vector.Z & scalar, vector.W & scalar); + + public static Vector4I operator &(T scalar, Vector4I vector) => + new Vector4I(scalar & vector.X, scalar & vector.Y, scalar & vector.Z, scalar & vector.W); + + public static Vector4I operator |(Vector4I vector, T scalar) => + new Vector4I(vector.X | scalar, vector.Y | scalar, vector.Z | scalar, vector.W | scalar); + + public static Vector4I operator |(T scalar, Vector4I vector) => + new Vector4I(scalar | vector.X, scalar | vector.Y, scalar | vector.Z, scalar | vector.W); + + public static Vector4I operator ^(Vector4I vector, T scalar) => + new Vector4I(vector.X ^ scalar, vector.Y ^ scalar, vector.Z ^ scalar, vector.W ^ scalar); + + public static Vector4I operator ^(T scalar, Vector4I vector) => + new Vector4I(scalar ^ vector.X, scalar ^ vector.Y, scalar ^ vector.Z, scalar ^ vector.W); } static partial class Vector4I From c9ce628a5b5ba6cb98fa451417f895de107c2d8f Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 31 May 2025 12:03:19 -0700 Subject: [PATCH 30/67] Use Legacy namespace qualifications for lecacy Quaternion. --- sources/Maths/Maths/Legacy/Vector2D.Ops.cs | 4 ++-- sources/Maths/Maths/Legacy/Vector3D.Ops.cs | 4 ++-- sources/Maths/Maths/Legacy/Vector4D.Ops.cs | 8 ++++---- sources/Maths/Maths/Matrix2X3.Ops.cs | 8 ++++---- sources/Maths/Maths/Matrix3X3.Ops.cs | 14 +++++++------- sources/Maths/Maths/Matrix4X4.Ops.cs | 14 +++++++------- sources/Maths/Maths/Plane.Ops.cs | 4 ++-- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/sources/Maths/Maths/Legacy/Vector2D.Ops.cs b/sources/Maths/Maths/Legacy/Vector2D.Ops.cs index 3c556c26d3..df68ebed3b 100644 --- a/sources/Maths/Maths/Legacy/Vector2D.Ops.cs +++ b/sources/Maths/Maths/Legacy/Vector2D.Ops.cs @@ -213,7 +213,7 @@ public static Vector2D TransformNormal(Vector2D normal, Matrix4X4 ma /// The source vector to be rotated. /// The rotation to apply. /// The transformed vector. - public static Vector2D Transform(Vector2D value, Quaternion rotation) + public static Vector2D Transform(Vector2D value, Legacy.Quaternion rotation) where T : unmanaged, IFormattable, IEquatable, IComparable { T x2 = Scalar.Add(rotation.X, rotation.X); @@ -285,4 +285,4 @@ public static Vector2D Multiply(Vector2D value1, Matrix2X2 value2) where T : unmanaged, IFormattable, IEquatable, IComparable => value1 * value2; } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Legacy/Vector3D.Ops.cs b/sources/Maths/Maths/Legacy/Vector3D.Ops.cs index ec06f40112..618c53b805 100644 --- a/sources/Maths/Maths/Legacy/Vector3D.Ops.cs +++ b/sources/Maths/Maths/Legacy/Vector3D.Ops.cs @@ -254,7 +254,7 @@ public static Vector3D Transform(Vector3D position, Matrix4X4 matrix /// The rotation to apply. /// The transformed vector. [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Transform(Vector3D value, Quaternion rotation) + public static Vector3D Transform(Vector3D value, Legacy.Quaternion rotation) where T : unmanaged, IFormattable, IEquatable, IComparable { T x2 = Scalar.Add(rotation.X, rotation.X); @@ -296,4 +296,4 @@ public static Vector3D TransformNormal(Vector3D normal, Matrix4X4 ma ); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Legacy/Vector4D.Ops.cs b/sources/Maths/Maths/Legacy/Vector4D.Ops.cs index 16caebd93b..b86726fc19 100644 --- a/sources/Maths/Maths/Legacy/Vector4D.Ops.cs +++ b/sources/Maths/Maths/Legacy/Vector4D.Ops.cs @@ -237,7 +237,7 @@ public static Vector4D Transform(Vector2D position, Matrix4X4 matrix /// The rotation to apply. /// The transformed vector. [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Transform(Vector2D value, Quaternion rotation) + public static Vector4D Transform(Vector2D value, Silk.NET.Maths.Legacy.Quaternion rotation) where T : unmanaged, IFormattable, IEquatable, IComparable { T x2 = Scalar.Add(rotation.X, rotation.X); @@ -283,7 +283,7 @@ public static Vector4D Transform(Vector3D position, Matrix4X4 matrix /// The rotation to apply. /// The transformed vector. [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Transform(Vector3D value, Quaternion rotation) + public static Vector4D Transform(Vector3D value, Legacy.Quaternion rotation) where T : unmanaged, IFormattable, IEquatable, IComparable { T x2 = Scalar.Add(rotation.X, rotation.X); @@ -329,7 +329,7 @@ public static Vector4D Transform(Vector4D vector, Matrix4X4 matrix) /// The rotation to apply. /// The transformed vector. [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Transform(Vector4D value, Quaternion rotation) + public static Vector4D Transform(Vector4D value, Legacy.Quaternion rotation) where T : unmanaged, IFormattable, IEquatable, IComparable { T x2 = Scalar.Add(rotation.X, rotation.X); @@ -354,4 +354,4 @@ public static Vector4D Transform(Vector4D value, Quaternion rotation ); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix2X3.Ops.cs b/sources/Maths/Maths/Matrix2X3.Ops.cs index 242912de0b..6ebb6124ca 100644 --- a/sources/Maths/Maths/Matrix2X3.Ops.cs +++ b/sources/Maths/Maths/Matrix2X3.Ops.cs @@ -104,7 +104,7 @@ public static Matrix2X3 CreateFromAxisAngle(Vector3D axis, T angle) /// Creates a rotation matrix from the given Quaternion rotation value. /// The source Quaternion. /// The rotation matrix. - public static Matrix2X3 CreateFromQuaternion(Quaternion quaternion) + public static Matrix2X3 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quaternion quaternion) where T : unmanaged, IFormattable, IEquatable, IComparable { Matrix2X3 result = Matrix2X3.Identity; @@ -140,7 +140,7 @@ public static Matrix2X3 CreateFromQuaternion(Quaternion quaternion) public static Matrix2X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) where T : unmanaged, IFormattable, IEquatable, IComparable { - Quaternion q = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); + Legacy.Quaternion q = Legacy.Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(q); } @@ -223,7 +223,7 @@ public static unsafe Matrix2X3 Lerp(Matrix2X3 matrix1, Matrix2X3 mat /// The source matrix to transform. /// The rotation to apply. /// The transformed matrix. - public static Matrix2X3 Transform(Matrix2X3 value, Quaternion rotation) + public static Matrix2X3 Transform(Matrix2X3 value, Legacy.Quaternion rotation) where T : unmanaged, IFormattable, IEquatable, IComparable { // Compute rotation matrix. @@ -260,4 +260,4 @@ public static Matrix2X3 Transform(Matrix2X3 value, Quaternion rotati return new(value.M11 * q1 + value.M12 * q2 + value.M13 * q3, value.M21 * q1 + value.M22 * q2 + value.M23 * q3); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix3X3.Ops.cs b/sources/Maths/Maths/Matrix3X3.Ops.cs index 2b11c28756..aa3905c23a 100644 --- a/sources/Maths/Maths/Matrix3X3.Ops.cs +++ b/sources/Maths/Maths/Matrix3X3.Ops.cs @@ -127,7 +127,7 @@ public static Matrix3X3 CreateFromAxisAngle(Vector3D axis, T angle) /// Creates a rotation matrix from the given Quaternion rotation value. /// The source Quaternion. /// The rotation matrix. - public static Matrix3X3 CreateFromQuaternion(Quaternion quaternion) + public static Matrix3X3 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quaternion quaternion) where T : unmanaged, IFormattable, IEquatable, IComparable { Matrix3X3 result = Matrix3X3.Identity; @@ -167,7 +167,7 @@ public static Matrix3X3 CreateFromQuaternion(Quaternion quaternion) public static Matrix3X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) where T : unmanaged, IFormattable, IEquatable, IComparable { - Quaternion q = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); + Legacy.Quaternion q = Legacy.Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(q); } @@ -373,7 +373,7 @@ public static Matrix3X3 Subtract(Matrix3X3 value1, Matrix3X3 value2) /// The scaling component of the transformation matrix. /// The rotation component of the transformation matrix. /// True if the source matrix was successfully decomposed; False otherwise. - public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out Quaternion rotation) + public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out Silk.NET.Maths.Legacy.Quaternion rotation) where T : unmanaged, IFormattable, IEquatable, IComparable { bool result = true; @@ -546,13 +546,13 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out if (!Scalar.GreaterThanOrEqual(Scalar.As(DecomposeEpsilon), det)) { // Non-SRT matrix encountered - rotation = Quaternion.Identity; + rotation = Legacy.Quaternion.Identity; result = false; } else { // generate the quaternion from the matrix - rotation = Quaternion.CreateFromRotationMatrix(matTemp); + rotation = Legacy.Quaternion.CreateFromRotationMatrix(matTemp); } } } @@ -579,7 +579,7 @@ public static unsafe Matrix3X3 Lerp(Matrix3X3 matrix1, Matrix3X3 mat /// The source matrix to transform. /// The rotation to apply. /// The transformed matrix. - public static Matrix3X3 Transform(Matrix3X3 value, Quaternion rotation) + public static Matrix3X3 Transform(Matrix3X3 value, Legacy.Quaternion rotation) where T : unmanaged, IFormattable, IEquatable, IComparable { // Compute rotation matrix. @@ -625,4 +625,4 @@ public static unsafe Matrix3X3 Transpose(Matrix3X3 matrix) return new(matrix.Column1, matrix.Column2, matrix.Column3); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix4X4.Ops.cs b/sources/Maths/Maths/Matrix4X4.Ops.cs index d27a6128ae..fb74c4345a 100644 --- a/sources/Maths/Maths/Matrix4X4.Ops.cs +++ b/sources/Maths/Maths/Matrix4X4.Ops.cs @@ -197,7 +197,7 @@ public static Matrix4X4 CreateFromAxisAngle(Vector3D axis, T angle) /// Creates a rotation matrix from the given Quaternion rotation value. /// The source Quaternion. /// The rotation matrix. - public static Matrix4X4 CreateFromQuaternion(Quaternion quaternion) + public static Matrix4X4 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quaternion quaternion) where T : unmanaged, IFormattable, IEquatable, IComparable { Matrix4X4 result = Matrix4X4.Identity; @@ -237,7 +237,7 @@ public static Matrix4X4 CreateFromQuaternion(Quaternion quaternion) public static Matrix4X4 CreateFromYawPitchRoll(T yaw, T pitch, T roll) where T : unmanaged, IFormattable, IEquatable, IComparable { - Quaternion q = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); + Legacy.Quaternion q = Legacy.Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(q); } @@ -1276,7 +1276,7 @@ private static Vector128 Permute(Vector128 value, byte control) /// The rotation component of the transformation matrix. /// The translation component of the transformation matrix /// True if the source matrix was successfully decomposed; False otherwise. - public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out Quaternion rotation, out Vector3D translation) + public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out Silk.NET.Maths.Legacy.Quaternion rotation, out Vector3D translation) where T : unmanaged, IFormattable, IEquatable, IComparable { bool result = true; @@ -1454,13 +1454,13 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out if (!Scalar.GreaterThanOrEqual(Scalar.As(DecomposeEpsilon), det)) { // Non-SRT matrix encountered - rotation = Quaternion.Identity; + rotation = Legacy.Quaternion.Identity; result = false; } else { // generate the quaternion from the matrix - rotation = Quaternion.CreateFromRotationMatrix(matTemp); + rotation = Legacy.Quaternion.CreateFromRotationMatrix(matTemp); } } } @@ -1488,7 +1488,7 @@ public static unsafe Matrix4X4 Lerp(Matrix4X4 matrix1, Matrix4X4 mat /// The source matrix to transform. /// The rotation to apply. /// The transformed matrix. - public static Matrix4X4 Transform(Matrix4X4 value, Quaternion rotation) + public static Matrix4X4 Transform(Matrix4X4 value, Legacy.Quaternion rotation) where T : unmanaged, IFormattable, IEquatable, IComparable { // Compute rotation matrix. @@ -1539,4 +1539,4 @@ public static unsafe Matrix4X4 Transpose(Matrix4X4 matrix) return new(matrix.Column1, matrix.Column2, matrix.Column3, matrix.Column4); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Plane.Ops.cs b/sources/Maths/Maths/Plane.Ops.cs index ec15e8de18..24879072fb 100644 --- a/sources/Maths/Maths/Plane.Ops.cs +++ b/sources/Maths/Maths/Plane.Ops.cs @@ -181,7 +181,7 @@ public static Plane Transform(Plane plane, Matrix4X4 matrix) /// The Quaternion rotation to apply to the Plane. /// A new Plane that results from applying the rotation. [MethodImpl((MethodImplOptions) 768)] - public static Plane Transform(Plane plane, Quaternion rotation) + public static Plane Transform(Plane plane, Legacy.Quaternion rotation) where T : unmanaged, IFormattable, IEquatable, IComparable { // Compute rotation matrix. @@ -220,4 +220,4 @@ public static Plane Transform(Plane plane, Quaternion rotation) plane.Distance); } } -} \ No newline at end of file +} From aac298a454bf7e3439839767d86a86781340edbf Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 31 May 2025 12:39:24 -0700 Subject: [PATCH 31/67] Generate constructors to extend smaller vectors. --- sources/Maths/Maths/Vector3F.gen.cs | 3 +++ sources/Maths/Maths/Vector3I.cs | 4 ---- sources/Maths/Maths/Vector3I.gen.cs | 3 +++ sources/Maths/Maths/Vector4F.gen.cs | 6 ++++++ sources/Maths/Maths/Vector4I.cs | 7 ------- sources/Maths/Maths/Vector4I.gen.cs | 6 ++++++ 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/sources/Maths/Maths/Vector3F.gen.cs b/sources/Maths/Maths/Vector3F.gen.cs index c339e7248b..ce3072ea61 100644 --- a/sources/Maths/Maths/Vector3F.gen.cs +++ b/sources/Maths/Maths/Vector3F.gen.cs @@ -32,6 +32,9 @@ partial struct Vector3F : /// Initializes the vector with individual component values. public Vector3F(T x, T y, T z) => (X, Y, Z) = (x, y, z); + /// Initializes the vector using a for the initial elements, and the specified component for the remainder. + public Vector3F(Vector2F other, T z) => (X, Y, Z) = (other.X, other.Y, z); + /// Initializes the vector from a span of 3 values. public Vector3F(ReadOnlySpan values) { diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index 8df9e4e06a..69ebab924f 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -14,10 +14,6 @@ namespace Silk.NET.Maths /// A structure representing a 3D integer vector. internal partial struct Vector3I { - /// Initializes the vector using a Vector2I for X and Y, and a separate value for Z. - // TODO: Make sure lower dimensional constructors arent meant to zero-out the higher dimensions - public Vector3I(Vector2I xy, T z) => (X, Y, Z) = (xy.X, xy.Y, z); - /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => (X * X) + (Y * Y) + (Z * Z); diff --git a/sources/Maths/Maths/Vector3I.gen.cs b/sources/Maths/Maths/Vector3I.gen.cs index 181ba38d8c..ac9bef4904 100644 --- a/sources/Maths/Maths/Vector3I.gen.cs +++ b/sources/Maths/Maths/Vector3I.gen.cs @@ -32,6 +32,9 @@ partial struct Vector3I : /// Initializes the vector with individual component values. public Vector3I(T x, T y, T z) => (X, Y, Z) = (x, y, z); + /// Initializes the vector using a for the initial elements, and the specified component for the remainder. + public Vector3I(Vector2I other, T z) => (X, Y, Z) = (other.X, other.Y, z); + /// Initializes the vector from a span of 3 values. public Vector3I(ReadOnlySpan values) { diff --git a/sources/Maths/Maths/Vector4F.gen.cs b/sources/Maths/Maths/Vector4F.gen.cs index b97dbf436f..a617c6fc42 100644 --- a/sources/Maths/Maths/Vector4F.gen.cs +++ b/sources/Maths/Maths/Vector4F.gen.cs @@ -35,6 +35,12 @@ partial struct Vector4F : /// Initializes the vector with individual component values. public Vector4F(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); + /// Initializes the vector using a for the initial elements, and the specified components for the remainder. + public Vector4F(Vector2F other, T z, T w) => (X, Y, Z, W) = (other.X, other.Y, z, w); + + /// Initializes the vector using a for the initial elements, and the specified component for the remainder. + public Vector4F(Vector3F other, T w) => (X, Y, Z, W) = (other.X, other.Y, other.Z, w); + /// Initializes the vector from a span of 4 values. public Vector4F(ReadOnlySpan values) { diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs index 9952e08574..07d4b25c17 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4I.cs @@ -13,13 +13,6 @@ namespace Silk.NET.Maths /// A structure representing a 4D integer vector. internal partial struct Vector4I { - /// Initializes the vector using a Vector2I for X and Y, and a separate value for Z and W. - // TODO: Make sure lower dimensional constructors arent meant to zero-out the higher dimensions - public Vector4I(Vector2I xy, T z, T w) => (X, Y, Z, W) = (xy.X, xy.Y, z, w); - - /// Initializes the vector using a Vector3I for X, Y and Z, and a separate value for W. - public Vector4I(Vector3I xyz, T w) => (X, Y, Z, W) = (xyz.X, xyz.Y, xyz.Z, w); - /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => (X * X) + (Y * Y) + (Z * Z) + (W * W); diff --git a/sources/Maths/Maths/Vector4I.gen.cs b/sources/Maths/Maths/Vector4I.gen.cs index 37bab5858b..44059dcff8 100644 --- a/sources/Maths/Maths/Vector4I.gen.cs +++ b/sources/Maths/Maths/Vector4I.gen.cs @@ -35,6 +35,12 @@ partial struct Vector4I : /// Initializes the vector with individual component values. public Vector4I(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); + /// Initializes the vector using a for the initial elements, and the specified components for the remainder. + public Vector4I(Vector2I other, T z, T w) => (X, Y, Z, W) = (other.X, other.Y, z, w); + + /// Initializes the vector using a for the initial elements, and the specified component for the remainder. + public Vector4I(Vector3I other, T w) => (X, Y, Z, W) = (other.X, other.Y, other.Z, w); + /// Initializes the vector from a span of 4 values. public Vector4I(ReadOnlySpan values) { From 25f69945b8cb9330d1675431521604867c165948 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 31 May 2025 12:40:00 -0700 Subject: [PATCH 32/67] Removed AllBitsSet from Vector2F. --- sources/Maths/Maths/Vector2F.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/sources/Maths/Maths/Vector2F.cs b/sources/Maths/Maths/Vector2F.cs index 651c2abbef..7cc5666095 100644 --- a/sources/Maths/Maths/Vector2F.cs +++ b/sources/Maths/Maths/Vector2F.cs @@ -16,9 +16,6 @@ namespace Silk.NET.Maths /// A structure representing a 2D floating-point vector. internal partial struct Vector2F { - /// Gets a vector with all bits set for each component. - public static Vector2F AllBitsSet => new(T.AllBitsSet, T.AllBitsSet); - /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => (X * X) + (Y * Y); From 41aa58d5f0ffc6d411f5f023584715db99d38355 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 31 May 2025 16:33:34 -0700 Subject: [PATCH 33/67] Generate vector specific methods in templates. --- sources/Maths/Maths/Vector2F.cs | 53 ++++------------------------- sources/Maths/Maths/Vector2F.gen.cs | 29 ++++++++++++++++ sources/Maths/Maths/Vector2I.cs | 9 ----- sources/Maths/Maths/Vector2I.gen.cs | 16 +++++++++ sources/Maths/Maths/Vector3F.gen.cs | 29 ++++++++++++++++ sources/Maths/Maths/Vector3I.cs | 9 ----- sources/Maths/Maths/Vector3I.gen.cs | 16 +++++++++ sources/Maths/Maths/Vector4F.gen.cs | 29 ++++++++++++++++ sources/Maths/Maths/Vector4I.cs | 9 ----- sources/Maths/Maths/Vector4I.gen.cs | 16 +++++++++ 10 files changed, 142 insertions(+), 73 deletions(-) diff --git a/sources/Maths/Maths/Vector2F.cs b/sources/Maths/Maths/Vector2F.cs index 7cc5666095..843f180af2 100644 --- a/sources/Maths/Maths/Vector2F.cs +++ b/sources/Maths/Maths/Vector2F.cs @@ -16,38 +16,6 @@ namespace Silk.NET.Maths /// A structure representing a 2D floating-point vector. internal partial struct Vector2F { - /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => (X * X) + (Y * Y); - - /// Gets the length of the vector. - public T Length => T.Sqrt(LengthSquared); - - /// Computes the dot product of this vector with another vector. - public T Dot(Vector2F other) => (X * other.X) + (Y * other.Y); - - /// Computes the dot product of two vectors. - public static T Dot(Vector2F left, Vector2F right) => (left.X * right.X) + (left.Y * right.Y); - - /// Computes the cross product of this vector with another vector. - public T Cross(Vector2F other) => (X * other.Y) - (Y * other.X); - - /// Computes the cross product of two vectors. - public static T Cross(Vector2F left, Vector2F right) => (left.X * right.Y) - (left.Y * right.X); - - /// Normalizes this vector. - public Vector2F Normalize() - { - T length = Length; - return length != T.Zero ? this / length : Zero; - } - - /// Normalizes a vector. - public static Vector2F Normalize(Vector2F vector) - { - T length = vector.Length; - return length != T.Zero ? vector / length : Zero; - } - /// Returns a vector with the component-wise maximum of this and another vector. public Vector2F Max(Vector2F other) => new(T.Max(X, other.X), T.Max(Y, other.Y)); @@ -122,20 +90,6 @@ public static Vector2F LerpClamped(Vector2F a, Vector2F b, Vector2F a.Y + (b.Y - a.Y) * T.Clamp(t.Y, T.Zero, T.One) ); - /// Reflects a vector over a normal vector. - public Vector2F Reflect(Vector2F normal) - { - T dot = Dot(normal); - return this - (normal * (dot + dot)); - } - - /// Reflects a vector over a normal vector. - public static Vector2F Reflect(Vector2F vector, Vector2F normal) - { - T dot = Dot(vector, normal); - return vector - (normal * (dot + dot)); - } - /// Returns a vector where each component is the sign of the original vector's component. public Vector2F Sign() => new(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y))); @@ -358,4 +312,11 @@ public static Vector2F ScaleB(Vector2F x, Vector2I n) => public static Vector2F ScaleB(Vector2F x, int n) => new(T.ScaleB(x.X, n), T.ScaleB(x.Y, n)); } + + static partial class Vector2F + { + /// Computes the cross product of two vectors. + public static T Cross(this Vector2F left, Vector2F right) + where T : IFloatingPointIeee754 => (left.X * right.Y) - (left.Y * right.X); + } } diff --git a/sources/Maths/Maths/Vector2F.gen.cs b/sources/Maths/Maths/Vector2F.gen.cs index c78c0ae7a7..b7c5cfc47f 100644 --- a/sources/Maths/Maths/Vector2F.gen.cs +++ b/sources/Maths/Maths/Vector2F.gen.cs @@ -51,6 +51,9 @@ public Vector2F(ReadOnlySpan values) /// Gets the vector (0, 1). public static Vector2F UnitY => new(Scalar.Zero, Scalar.One); + /// Gets the squared length of the vector (dot product with itself). + public T LengthSquared => Vector2F.Dot(this, this); + /// T IReadOnlyList.this[int index] => this[index]; @@ -342,6 +345,32 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm static partial class Vector2F { + /// Computes the dot product of two vectors. + public static T Dot(this Vector2F left, Vector2F right) + where T : IFloatingPointIeee754 => + left.X * right.X + left.Y * right.Y; + + /// Reflects a vector over a normal vector. + public static Vector2F Reflect(Vector2F vector, Vector2F normal) + where T : IFloatingPointIeee754 + { + T dot = vector.Dot(normal); + return vector - (normal * (dot + dot)); + } + + /// Computes the length of the vector. + public static T GetLength(this Vector2F vector) + where T : IFloatingPointIeee754 => + T.Sqrt(vector.LengthSquared); + + /// Normalizes a vector. + public static Vector2F Normalize(this Vector2F vector) + where T : IFloatingPointIeee754 + { + T length = vector.GetLength(); + return length != T.Zero ? vector / length : Vector2F.Zero; + } + public static Vector2F Log(this Vector2F x) where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y)); diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index d4e06c943e..fceb7b5b44 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -14,15 +14,6 @@ namespace Silk.NET.Maths /// A structure representing a 2D integer vector. internal partial struct Vector2I { - /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => (X * X) + (Y * Y); - - /// Computes the dot product of this vector with another vector. - public T Dot(Vector2I other) => (X * other.X) + (Y * other.Y); - - /// Computes the dot product of two vectors. - public static T Dot(Vector2I left, Vector2I right) => (left.X * right.X) + (left.Y * right.Y); - /// Computes the cross product of this vector with another vector. public T Cross(Vector2I other) => (X * other.Y) - (Y * other.X); diff --git a/sources/Maths/Maths/Vector2I.gen.cs b/sources/Maths/Maths/Vector2I.gen.cs index 60df7f4e0c..afe221d779 100644 --- a/sources/Maths/Maths/Vector2I.gen.cs +++ b/sources/Maths/Maths/Vector2I.gen.cs @@ -54,6 +54,9 @@ public Vector2I(ReadOnlySpan values) /// Gets a vector with all bits set for each component. public static Vector2I AllBitsSet => new Vector2I(T.AllBitsSet, T.AllBitsSet); + /// Gets the squared length of the vector (dot product with itself). + public T LengthSquared => Vector2I.Dot(this, this); + /// T IReadOnlyList.this[int index] => this[index]; @@ -374,6 +377,19 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm static partial class Vector2I { + /// Computes the dot product of two vectors. + public static T Dot(this Vector2I left, Vector2I right) + where T : IBinaryInteger => + left.X * right.X + left.Y * right.Y; + + /// Reflects a vector over a normal vector. + public static Vector2I Reflect(Vector2I vector, Vector2I normal) + where T : IBinaryInteger + { + T dot = vector.Dot(normal); + return vector - (normal * (dot + dot)); + } + public static Vector2I Log(this Vector2I x) where TSelf : IBinaryInteger, ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y)); diff --git a/sources/Maths/Maths/Vector3F.gen.cs b/sources/Maths/Maths/Vector3F.gen.cs index ce3072ea61..6c9a8a9f67 100644 --- a/sources/Maths/Maths/Vector3F.gen.cs +++ b/sources/Maths/Maths/Vector3F.gen.cs @@ -61,6 +61,9 @@ public Vector3F(ReadOnlySpan values) /// Gets the vector (0, 0, 1). public static Vector3F UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One); + /// Gets the squared length of the vector (dot product with itself). + public T LengthSquared => Vector3F.Dot(this, this); + /// T IReadOnlyList.this[int index] => this[index]; @@ -379,6 +382,32 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm static partial class Vector3F { + /// Computes the dot product of two vectors. + public static T Dot(this Vector3F left, Vector3F right) + where T : IFloatingPointIeee754 => + left.X * right.X + left.Y * right.Y + left.Z * right.Z; + + /// Reflects a vector over a normal vector. + public static Vector3F Reflect(Vector3F vector, Vector3F normal) + where T : IFloatingPointIeee754 + { + T dot = vector.Dot(normal); + return vector - (normal * (dot + dot)); + } + + /// Computes the length of the vector. + public static T GetLength(this Vector3F vector) + where T : IFloatingPointIeee754 => + T.Sqrt(vector.LengthSquared); + + /// Normalizes a vector. + public static Vector3F Normalize(this Vector3F vector) + where T : IFloatingPointIeee754 + { + T length = vector.GetLength(); + return length != T.Zero ? vector / length : Vector3F.Zero; + } + public static Vector3F Log(this Vector3F x) where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z)); diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index 69ebab924f..167273b467 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -14,15 +14,6 @@ namespace Silk.NET.Maths /// A structure representing a 3D integer vector. internal partial struct Vector3I { - /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => (X * X) + (Y * Y) + (Z * Z); - - /// Computes the dot product of this vector with another vector. - public T Dot(Vector3I other) => (X * other.X) + (Y * other.Y) + (Z * other.Z); - - /// Computes the dot product of two vectors. - public static T Dot(Vector3I left, Vector3I right) => (left.X * right.X) + (left.Y * right.Y) + (left.Z * right.Z); - /// Computes the cross product of this vector with another vector. public Vector3I Cross(Vector3I other) => new Vector3I( diff --git a/sources/Maths/Maths/Vector3I.gen.cs b/sources/Maths/Maths/Vector3I.gen.cs index ac9bef4904..05bb368e10 100644 --- a/sources/Maths/Maths/Vector3I.gen.cs +++ b/sources/Maths/Maths/Vector3I.gen.cs @@ -64,6 +64,9 @@ public Vector3I(ReadOnlySpan values) /// Gets a vector with all bits set for each component. public static Vector3I AllBitsSet => new Vector3I(T.AllBitsSet, T.AllBitsSet, T.AllBitsSet); + /// Gets the squared length of the vector (dot product with itself). + public T LengthSquared => Vector3I.Dot(this, this); + /// T IReadOnlyList.this[int index] => this[index]; @@ -411,6 +414,19 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm static partial class Vector3I { + /// Computes the dot product of two vectors. + public static T Dot(this Vector3I left, Vector3I right) + where T : IBinaryInteger => + left.X * right.X + left.Y * right.Y + left.Z * right.Z; + + /// Reflects a vector over a normal vector. + public static Vector3I Reflect(Vector3I vector, Vector3I normal) + where T : IBinaryInteger + { + T dot = vector.Dot(normal); + return vector - (normal * (dot + dot)); + } + public static Vector3I Log(this Vector3I x) where TSelf : IBinaryInteger, ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z)); diff --git a/sources/Maths/Maths/Vector4F.gen.cs b/sources/Maths/Maths/Vector4F.gen.cs index a617c6fc42..be1a8e23ed 100644 --- a/sources/Maths/Maths/Vector4F.gen.cs +++ b/sources/Maths/Maths/Vector4F.gen.cs @@ -71,6 +71,9 @@ public Vector4F(ReadOnlySpan values) /// Gets the vector (0, 0, 0, 1). public static Vector4F UnitW => new(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); + /// Gets the squared length of the vector (dot product with itself). + public T LengthSquared => Vector4F.Dot(this, this); + /// T IReadOnlyList.this[int index] => this[index]; @@ -416,6 +419,32 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm static partial class Vector4F { + /// Computes the dot product of two vectors. + public static T Dot(this Vector4F left, Vector4F right) + where T : IFloatingPointIeee754 => + left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W; + + /// Reflects a vector over a normal vector. + public static Vector4F Reflect(Vector4F vector, Vector4F normal) + where T : IFloatingPointIeee754 + { + T dot = vector.Dot(normal); + return vector - (normal * (dot + dot)); + } + + /// Computes the length of the vector. + public static T GetLength(this Vector4F vector) + where T : IFloatingPointIeee754 => + T.Sqrt(vector.LengthSquared); + + /// Normalizes a vector. + public static Vector4F Normalize(this Vector4F vector) + where T : IFloatingPointIeee754 + { + T length = vector.GetLength(); + return length != T.Zero ? vector / length : Vector4F.Zero; + } + public static Vector4F Log(this Vector4F x) where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z), TSelf.Log(x.W)); diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs index 07d4b25c17..16c3e21720 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4I.cs @@ -13,15 +13,6 @@ namespace Silk.NET.Maths /// A structure representing a 4D integer vector. internal partial struct Vector4I { - /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => (X * X) + (Y * Y) + (Z * Z) + (W * W); - - /// Computes the dot product of this vector with another vector. - public T Dot(Vector4I other) => (X * other.X) + (Y * other.Y) + (Z * other.Z) + (W * other.W); - - /// Computes the dot product of two vectors. - public static T Dot(Vector4I left, Vector4I right) => (left.X * right.X) + (left.Y * right.Y) + (left.Z * right.Z) + (left.W * right.W); - /// Returns a vector with the component-wise maximum of this and another vector. public Vector4I Max(Vector4I other) => new Vector4I(T.Max(X, other.X), T.Max(Y, other.Y), T.Max(Z, other.Z), T.Max(W, other.W)); diff --git a/sources/Maths/Maths/Vector4I.gen.cs b/sources/Maths/Maths/Vector4I.gen.cs index 44059dcff8..04eb7ca61c 100644 --- a/sources/Maths/Maths/Vector4I.gen.cs +++ b/sources/Maths/Maths/Vector4I.gen.cs @@ -74,6 +74,9 @@ public Vector4I(ReadOnlySpan values) /// Gets a vector with all bits set for each component. public static Vector4I AllBitsSet => new Vector4I(T.AllBitsSet, T.AllBitsSet, T.AllBitsSet, T.AllBitsSet); + /// Gets the squared length of the vector (dot product with itself). + public T LengthSquared => Vector4I.Dot(this, this); + /// T IReadOnlyList.this[int index] => this[index]; @@ -448,6 +451,19 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm static partial class Vector4I { + /// Computes the dot product of two vectors. + public static T Dot(this Vector4I left, Vector4I right) + where T : IBinaryInteger => + left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W; + + /// Reflects a vector over a normal vector. + public static Vector4I Reflect(Vector4I vector, Vector4I normal) + where T : IBinaryInteger + { + T dot = vector.Dot(normal); + return vector - (normal * (dot + dot)); + } + public static Vector4I Log(this Vector4I x) where TSelf : IBinaryInteger, ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z), TSelf.Log(x.W)); From 09e674c61db686760b8ac4fd661fcd0b53d6f2c2 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Mon, 30 Jun 2025 16:19:44 -0700 Subject: [PATCH 34/67] Snapshot. --- sources/Maths/Maths/Vector2F.cs | 257 +------------- sources/Maths/Maths/Vector2F.gen.cs | 525 +++++++++++++++++++++++++-- sources/Maths/Maths/Vector2I.cs | 87 ----- sources/Maths/Maths/Vector2I.gen.cs | 229 ++++++++---- sources/Maths/Maths/Vector3F.gen.cs | 529 +++++++++++++++++++++++++-- sources/Maths/Maths/Vector3I.cs | 102 ------ sources/Maths/Maths/Vector3I.gen.cs | 233 ++++++++---- sources/Maths/Maths/Vector4F.gen.cs | 533 ++++++++++++++++++++++++++-- sources/Maths/Maths/Vector4I.cs | 106 ------ sources/Maths/Maths/Vector4I.gen.cs | 237 +++++++++---- 10 files changed, 1993 insertions(+), 845 deletions(-) diff --git a/sources/Maths/Maths/Vector2F.cs b/sources/Maths/Maths/Vector2F.cs index 843f180af2..70db4099f6 100644 --- a/sources/Maths/Maths/Vector2F.cs +++ b/sources/Maths/Maths/Vector2F.cs @@ -16,72 +16,9 @@ namespace Silk.NET.Maths /// A structure representing a 2D floating-point vector. internal partial struct Vector2F { - /// Returns a vector with the component-wise maximum of this and another vector. - public Vector2F Max(Vector2F other) => - new(T.Max(X, other.X), T.Max(Y, other.Y)); - - /// Returns a vector with the component-wise maximum of two vectors. - public static Vector2F Max(Vector2F left, Vector2F right) => - new(T.Max(left.X, right.X), T.Max(left.Y, right.Y)); - - /// Returns a vector with the component-wise maximum of this vector and a scalar. - public Vector2F Max(T scalar) => - new(T.Max(X, scalar), T.Max(Y, scalar)); - - /// Returns a vector with the component-wise maximum of a vector and a scalar. - public static Vector2F Max(Vector2F vector, T scalar) => - new(T.Max(vector.X, scalar), T.Max(vector.Y, scalar)); - - /// Returns a vector with the component-wise minimum of this and another vector. - public Vector2F Min(Vector2F other) => - new(T.Min(X, other.X), T.Min(Y, other.Y)); - - /// Returns a vector with the component-wise minimum of two vectors. - public static Vector2F Min(Vector2F left, Vector2F right) => - new(T.Min(left.X, right.X), T.Min(left.Y, right.Y)); - - /// Returns a vector with the component-wise minimum of this vector and a scalar. - public Vector2F Min(T scalar) => - new(T.Min(X, scalar), T.Min(Y, scalar)); - - /// Returns a vector with the component-wise minimum of a vector and a scalar. - public static Vector2F Min(Vector2F vector, T scalar) => - new(T.Min(vector.X, scalar), T.Min(vector.Y, scalar)); - - /// Clamps this vector's components between the corresponding Min and Max vectors. - public Vector2F Clamp(Vector2F min, Vector2F max) => - new(T.Clamp(X, min.X, max.X), T.Clamp(Y, min.Y, max.Y)); - - /// Clamps the components of a vector between the corresponding Min and Max vectors. - public static Vector2F Clamp(Vector2F vector, Vector2F min, Vector2F max) => - new(T.Clamp(vector.X, min.X, max.X), T.Clamp(vector.Y, min.Y, max.Y)); - - /// Clamps this vector's components between the Min and Max scalar values. - public Vector2F Clamp(T min, T max) => - new(T.Clamp(X, min, max), T.Clamp(Y, min, max)); - - /// Clamps the components of a vector between the Min and Max scalar values. - public static Vector2F Clamp(Vector2F vector, T min, T max) => - new(T.Clamp(vector.X, min, max), T.Clamp(vector.Y, min, max)); - - /// Returns a vector with the absolute value of each component of this vector. - public Vector2F Abs() => new(T.Abs(X), T.Abs(Y)); - - /// Returns a vector with the absolute value of each component of the specified vector. - public static Vector2F Abs(Vector2F vector) => - new(T.Abs(vector.X), T.Abs(vector.Y)); - - /// Linearly interpolates between two vectors using a scalar t-value. - public static Vector2F Lerp(Vector2F a, Vector2F b, T t) => - new(a.X + (b.X - a.X) * t, a.Y + (b.Y - a.Y) * t); - - /// Linearly interpolates between two vectors using a vector t-value. - public static Vector2F Lerp(Vector2F a, Vector2F b, Vector2F t) => - new(a.X + (b.X - a.X) * t.X, a.Y + (b.Y - a.Y) * t.Y); - /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). public static Vector2F LerpClamped(Vector2F a, Vector2F b, T t) => - Lerp(a, b, T.Clamp(t, T.Zero, T.One)); + Vector2F.Lerp(a, b, T.Clamp(t, T.Zero, T.One)); /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). public static Vector2F LerpClamped(Vector2F a, Vector2F b, Vector2F t) => @@ -90,29 +27,6 @@ public static Vector2F LerpClamped(Vector2F a, Vector2F b, Vector2F a.Y + (b.Y - a.Y) * T.Clamp(t.Y, T.Zero, T.One) ); - /// Returns a vector where each component is the sign of the original vector's component. - public Vector2F Sign() => new(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y))); - - /// Returns a vector where each component is the sign of the input vector's component. - public static Vector2F Sign(Vector2F vector) => - new(T.CreateChecked(T.Sign(vector.X)), T.CreateChecked(T.Sign(vector.Y))); - - /// Copies the sign of each component from another vector to this vector's components. - public Vector2F CopySign(Vector2F signSource) => - new(T.CopySign(X, signSource.X), T.CopySign(Y, signSource.Y)); - - /// Copies the sign of each component from another vector to a new vector. - public static Vector2F CopySign(Vector2F value, Vector2F signSource) => - new(T.CopySign(value.X, signSource.X), T.CopySign(value.Y, signSource.Y)); - - /// Copies the sign of a scalar onto each component of this vector. - public Vector2F CopySign(T signScalar) => - new(T.CopySign(X, signScalar), T.CopySign(Y, signScalar)); - - /// Copies the sign of a scalar onto each component of a new vector. - public static Vector2F CopySign(Vector2F value, T signScalar) => - new(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar)); - // Casts /// Explicitly casts a to a . @@ -124,68 +38,6 @@ public static explicit operator System.Numerics.Vector2(Vector2F v) => new(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); // IFloatingPointIeee754 - public static Vector2F Sqrt(Vector2F x) => - new(T.Sqrt(x.X), T.Sqrt(x.Y)); - - public static Vector2F Acosh(Vector2F x) => - new(T.Acosh(x.X), T.Acosh(x.Y)); - - public static Vector2F Asinh(Vector2F x) => - new(T.Asinh(x.X), T.Asinh(x.Y)); - - public static Vector2F Atanh(Vector2F x) => - new(T.Atanh(x.X), T.Atanh(x.Y)); - - public static Vector2F Cosh(Vector2F x) => - new(T.Cosh(x.X), T.Cosh(x.Y)); - - public static Vector2F Sinh(Vector2F x) => - new(T.Sinh(x.X), T.Sinh(x.Y)); - - public static Vector2F Tanh(Vector2F x) => - new(T.Tanh(x.X), T.Tanh(x.Y)); - - public static Vector2F Acos(Vector2F x) => - new(T.Acos(x.X), T.Acos(x.Y)); - - public static Vector2F AcosPi(Vector2F x) => - new(T.AcosPi(x.X), T.AcosPi(x.Y)); - - public static Vector2F Asin(Vector2F x) => - new(T.Asin(x.X), T.Asin(x.Y)); - - public static Vector2F AsinPi(Vector2F x) => - new(T.AsinPi(x.X), T.AsinPi(x.Y)); - - public static Vector2F Atan(Vector2F x) => - new(T.Atan(x.X), T.Atan(x.Y)); - - public static Vector2F AtanPi(Vector2F x) => - new(T.AtanPi(x.X), T.AtanPi(x.Y)); - - public static Vector2F Cos(Vector2F x) => - new(T.Cos(x.X), T.Cos(x.Y)); - - public static Vector2F CosPi(Vector2F x) => - new(T.CosPi(x.X), T.CosPi(x.Y)); - - public static Vector2F Sin(Vector2F x) => - new(T.Sin(x.X), T.Sin(x.Y)); - - public static Vector2F SinPi(Vector2F x) => - new(T.SinPi(x.X), T.SinPi(x.Y)); - - public static Vector2F Tan(Vector2F x) => - new(T.Tan(x.X), T.Tan(x.Y)); - - public static Vector2F TanPi(Vector2F x) => - new(T.TanPi(x.X), T.TanPi(x.Y)); - - public static Vector2F DegreesToRadians(Vector2F degrees) => - new(T.DegreesToRadians(degrees.X), T.DegreesToRadians(degrees.Y)); - - public static Vector2F RadiansToDegrees(Vector2F radians) => - new(T.RadiansToDegrees(radians.X), T.RadiansToDegrees(radians.Y)); public static (Vector2F Sin, Vector2F Cos) SinCos(Vector2F x) => (new(T.Sin(x.X), T.Sin(x.Y)), new(T.Cos(x.X), T.Cos(x.Y))); @@ -193,98 +45,6 @@ public static (Vector2F Sin, Vector2F Cos) SinCos(Vector2F x) => public static (Vector2F SinPi, Vector2F CosPi) SinCosPi(Vector2F x) => (new(T.SinPi(x.X), T.SinPi(x.Y)), new(T.CosPi(x.X), T.CosPi(x.Y))); - public static Vector2F Log(Vector2F x) => - new(T.Log(x.X), T.Log(x.Y)); - - public static Vector2F Log(Vector2F x, Vector2F newBase) => - new(T.Log(x.X, newBase.X), T.Log(x.Y, newBase.Y)); - - public static Vector2F Log(Vector2F x, T newBase) => - new(T.Log(x.X, newBase), T.Log(x.Y, newBase)); - - public static Vector2F LogP1(Vector2F x) => - new(T.LogP1(x.X), T.LogP1(x.Y)); - - // TODO: Static Log2 - - public static Vector2F Log2P1(Vector2F x) => - new(T.Log2P1(x.X), T.Log2P1(x.Y)); - - public static Vector2F Log10(Vector2F x) => - new(T.Log10(x.X), T.Log10(x.Y)); - - public static Vector2F Log10P1(Vector2F x) => - new(T.Log10P1(x.X), T.Log10P1(x.Y)); - - public static Vector2F Exp(Vector2F x) => - new(T.Exp(x.X), T.Exp(x.Y)); - - public static Vector2F ExpM1(Vector2F x) => - new(T.ExpM1(x.X), T.ExpM1(x.Y)); - - public static Vector2F Exp2(Vector2F x) => - new(T.Exp2(x.X), T.Exp2(x.Y)); - - public static Vector2F Exp2M1(Vector2F x) => - new(T.Exp2M1(x.X), T.Exp2M1(x.Y)); - - public static Vector2F Exp10(Vector2F x) => - new(T.Exp10(x.X), T.Exp10(x.Y)); - - public static Vector2F Exp10M1(Vector2F x) => - new(T.Exp10M1(x.X), T.Exp10M1(x.Y)); - - public static Vector2F Pow(Vector2F x, Vector2F y) => - new(T.Pow(x.X, y.X), T.Pow(x.Y, y.Y)); - - public static Vector2F Pow(Vector2F x, T y) => - new(T.Pow(x.X, y), T.Pow(x.Y, y)); - - public static Vector2F Cbrt(Vector2F x) => - new(T.Cbrt(x.X), T.Cbrt(x.Y)); - - public static Vector2F Hypot(Vector2F x, Vector2F y) => - new(T.Hypot(x.X, y.X), T.Hypot(x.Y, y.Y)); - - public static Vector2F Hypot(Vector2F x, T y) => - new(T.Hypot(x.X, y), T.Hypot(x.Y, y)); - - public static Vector2F RootN(Vector2F x, int n) => - new(T.RootN(x.X, n), T.RootN(x.Y, n)); - - public static Vector2F Round(Vector2F x) => - new(T.Round(x.X), T.Round(x.Y)); - - public static Vector2F Round(Vector2F x, int digits) => - new(T.Round(x.X, digits), T.Round(x.Y, digits)); - - public static Vector2F Round(Vector2F x, MidpointRounding mode) => - new(T.Round(x.X, mode), T.Round(x.Y, mode)); - - public static Vector2F Round(Vector2F x, int digits, MidpointRounding mode) => - new(T.Round(x.X, digits, mode), T.Round(x.Y, digits, mode)); - - public static Vector2F Truncate(Vector2F x) => - new(T.Truncate(x.X), T.Truncate(x.Y)); - - public static Vector2F Atan2(Vector2F y, Vector2F x) => - new(T.Atan2(y.X, x.X), T.Atan2(y.Y, x.Y)); - - public static Vector2F Atan2Pi(Vector2F y, Vector2F x) => - new(T.Atan2Pi(y.X, x.X), T.Atan2Pi(y.Y, x.Y)); - - public static Vector2F Atan2(Vector2F y, T x) => - new(T.Atan2(y.X, x), T.Atan2(y.Y, x)); - - public static Vector2F Atan2Pi(Vector2F y, T x) => - new(T.Atan2Pi(y.X, x), T.Atan2Pi(y.Y, x)); - - public static Vector2F BitDecrement(Vector2F x) => - new(T.BitDecrement(x.X), T.BitDecrement(x.Y)); - - public static Vector2F BitIncrement(Vector2F x) => - new(T.BitIncrement(x.X), T.BitIncrement(x.Y)); - public static Vector2F FusedMultiplyAdd(Vector2F left, Vector2F right, Vector2F addend) => new(T.FusedMultiplyAdd(left.X, right.X, addend.X), T.FusedMultiplyAdd(left.Y, right.Y, addend.Y)); @@ -296,21 +56,6 @@ public static Vector2F FusedMultiplyAdd(Vector2F left, T right, Vector2F FusedMultiplyAdd(Vector2F left, T right, T addend) => new(T.FusedMultiplyAdd(left.X, right, addend), T.FusedMultiplyAdd(left.Y, right, addend)); - - public static Vector2F ReciprocalEstimate(Vector2F x) => - new(T.ReciprocalEstimate(x.X), T.ReciprocalEstimate(x.Y)); - - public static Vector2F ReciprocalSqrtEstimate(Vector2F x) => - new(T.ReciprocalSqrtEstimate(x.X), T.ReciprocalSqrtEstimate(x.Y)); - - public static Vector2I ILogB(Vector2F x) => - new(T.ILogB(x.X), T.ILogB(x.Y)); - - public static Vector2F ScaleB(Vector2F x, Vector2I n) => - new(T.ScaleB(x.X, n.X), T.ScaleB(x.Y, n.Y)); - - public static Vector2F ScaleB(Vector2F x, int n) => - new(T.ScaleB(x.X, n), T.ScaleB(x.Y, n)); } static partial class Vector2F diff --git a/sources/Maths/Maths/Vector2F.gen.cs b/sources/Maths/Maths/Vector2F.gen.cs index b7c5cfc47f..66d80f2855 100644 --- a/sources/Maths/Maths/Vector2F.gen.cs +++ b/sources/Maths/Maths/Vector2F.gen.cs @@ -40,16 +40,16 @@ public Vector2F(ReadOnlySpan values) } /// Gets a vector whose 2 elements are equal to one. - public static Vector2F One => new(Scalar.One); + public static Vector2F One => new(T.One); /// Returns a vector whose 2 elements are equal to zero. public static Vector2F Zero => default; /// Gets the vector (1, 0). - public static Vector2F UnitX => new(Scalar.One, Scalar.Zero); + public static Vector2F UnitX => new(T.One, T.Zero); /// Gets the vector (0, 1). - public static Vector2F UnitY => new(Scalar.Zero, Scalar.One); + public static Vector2F UnitY => new(T.Zero, T.One); /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => Vector2F.Dot(this, this); @@ -302,44 +302,61 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm /// public override int GetHashCode() => HashCode.Combine(X, Y); + /// Desconstructs a vector into its components. + /// The X component. + /// The Y component. + public void Deconstruct(out T x, out T y) + { + x = X; + y = Y; + } + + /// Implicitly casts a to a . + public static implicit operator Vector2F((T X, T Y) v) => + new(v.X, v.Y); + + /// Implicitly casts a to a . + public static implicit operator (T X, T Y)(Vector2F v) => + (v.X, v.Y); + public static Vector2F operator +(Vector2F vector) => vector; public static Vector2F operator -(Vector2F vector) => - new Vector2F(-vector.X, -vector.Y); + new(-vector.X, -vector.Y); public static Vector2F operator +(Vector2F left, Vector2F right) => - new Vector2F(left.X + right.X, left.Y + right.Y); + new(left.X + right.X, left.Y + right.Y); public static Vector2F operator -(Vector2F left, Vector2F right) => - new Vector2F(left.X - right.X, left.Y - right.Y); + new(left.X - right.X, left.Y - right.Y); public static Vector2F operator *(Vector2F left, Vector2F right) => - new Vector2F(left.X * right.X, left.Y * right.Y); + new(left.X * right.X, left.Y * right.Y); public static Vector2F operator /(Vector2F left, Vector2F right) => - new Vector2F(left.X / right.X, left.Y / right.Y); + new(left.X / right.X, left.Y / right.Y); public static Vector2F operator %(Vector2F left, Vector2F right) => - new Vector2F(left.X % right.X, left.Y % right.Y); + new(left.X % right.X, left.Y % right.Y); public static Vector2F operator +(Vector2F vector, T scalar) => - new Vector2F(vector.X + scalar, vector.Y + scalar); + new(vector.X + scalar, vector.Y + scalar); public static Vector2F operator -(Vector2F vector, T scalar) => - new Vector2F(vector.X - scalar, vector.Y - scalar); + new(vector.X - scalar, vector.Y - scalar); public static Vector2F operator *(Vector2F vector, T scalar) => - new Vector2F(vector.X * scalar, vector.Y * scalar); + new(vector.X * scalar, vector.Y * scalar); public static Vector2F operator *(T scalar, Vector2F vector) => - new Vector2F(scalar * vector.X, scalar * vector.Y); + new(scalar * vector.X, scalar * vector.Y); public static Vector2F operator /(Vector2F vector, T scalar) => - new Vector2F(vector.X / scalar, vector.Y / scalar); + new(vector.X / scalar, vector.Y / scalar); public static Vector2F operator %(Vector2F vector, T scalar) => - new Vector2F(vector.X % scalar, vector.Y % scalar); + new(vector.X % scalar, vector.Y % scalar); } @@ -371,56 +388,504 @@ public static Vector2F Normalize(this Vector2F vector) return length != T.Zero ? vector / length : Vector2F.Zero; } + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2I Sign(this Vector2F value) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Sign(value.X), TSelf.Sign(value.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F Max(this Vector2F x, Vector2F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2F Max(this Vector2F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F MaxNumber(this Vector2F x, Vector2F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2F MaxNumber(this Vector2F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F Min(this Vector2F x, Vector2F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2F Min(this Vector2F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F MinNumber(this Vector2F x, Vector2F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2F MinNumber(this Vector2F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F Clamp(this Vector2F value, Vector2F min, Vector2F max) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector2F Clamp(this Vector2F value, TSelf min, TSelf max) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F CopySign(this Vector2F value, Vector2F sign) + where TSelf : IFloatingPointIeee754 => + new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2F CopySign(this Vector2F value, TSelf sign) + where TSelf : IFloatingPointIeee754 => + new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Abs(this Vector2F value) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Abs(value.X), TSelf.Abs(value.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F MaxMagnitude(this Vector2F x, Vector2F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F MaxMagnitudeNumber(this Vector2F x, Vector2F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F MinMagnitude(this Vector2F x, Vector2F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F MinMagnitudeNumber(this Vector2F x, Vector2F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Ceiling(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Floor(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Floor(x.X), TSelf.Floor(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Round(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Round(x.X), TSelf.Round(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector2F Round(this Vector2F x, int digits, MidpointRounding mode) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Truncate(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F Atan2(this Vector2F y, Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F Atan2Pi(this Vector2F y, Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2F Lerp(this Vector2F value1, Vector2F value2, TSelf amount) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F BitDecrement(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F BitIncrement(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F FusedMultiplyAdd(this Vector2F left, Vector2F right, Vector2F addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector2F FusedMultiplyAdd(this Vector2F left, TSelf right, TSelf addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F Ieee754Remainder(this Vector2F left, Vector2F right) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2F Ieee754Remainder(this Vector2F left, TSelf right) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2I ILogB(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F ReciprocalEstimate(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F ReciprocalSqrtEstimate(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F ScaleB(this Vector2F x, Vector2I n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2F ScaleB(this Vector2F x, int n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F Pow(this Vector2F x, Vector2F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2F Pow(this Vector2F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Cbrt(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Sqrt(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2F RootN(this Vector2F x, int n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F RootN(this Vector2F x, Vector2I n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2F Hypot(this Vector2F x, Vector2F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector2F Log(this Vector2F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log(x.X), TSelf.Log(x.Y)); - public static Vector2F Log(this Vector2F x, Vector2F newBase) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => - new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2F Log(this Vector2F x, TSelf newBase) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector2F LogP1(this Vector2F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector2F Log2(this Vector2F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log2(x.X), TSelf.Log2(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector2F Log2P1(this Vector2F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector2F Log10(this Vector2F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log10(x.X), TSelf.Log10(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector2F Log10P1(this Vector2F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector2F Exp(this Vector2F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp(x.X), TSelf.Exp(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector2F ExpM1(this Vector2F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector2F Exp2(this Vector2F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector2F Exp2M1(this Vector2F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector2F Exp10(this Vector2F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector2F Exp10M1(this Vector2F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Acos(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Acos(x.X), TSelf.Acos(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F AcosPi(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Asin(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Asin(x.X), TSelf.Asin(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F AsinPi(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Atan(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan(x.X), TSelf.Atan(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F AtanPi(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Cos(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Cos(x.X), TSelf.Cos(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F CosPi(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Sin(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Sin(x.X), TSelf.Sin(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F SinPi(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Tan(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Tan(x.X), TSelf.Tan(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F TanPi(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F DegreesToRadians(this Vector2F degrees) + where TSelf : IFloatingPointIeee754 => + new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F RadiansToDegrees(this Vector2F radians) + where TSelf : IFloatingPointIeee754 => + new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Acosh(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Asinh(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Atanh(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Cosh(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Sinh(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2F Tanh(this Vector2F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y)); } } diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs index fceb7b5b44..88adc7cb6e 100644 --- a/sources/Maths/Maths/Vector2I.cs +++ b/sources/Maths/Maths/Vector2I.cs @@ -20,84 +20,6 @@ internal partial struct Vector2I /// Computes the cross product of two vectors. public static T Cross(Vector2I left, Vector2I right) => (left.X * right.Y) - (left.Y * right.X); - /// Returns a vector with the component-wise maximum of this and another vector. - public Vector2I Max(Vector2I other) => - new Vector2I(T.Max(X, other.X), T.Max(Y, other.Y)); - - /// Returns a vector with the component-wise maximum of two vectors. - public static Vector2I Max(Vector2I left, Vector2I right) => - new Vector2I(T.Max(left.X, right.X), T.Max(left.Y, right.Y)); - - /// Returns a vector with the component-wise maximum of this vector and a scalar. - public Vector2I Max(T scalar) => - new Vector2I(T.Max(X, scalar), T.Max(Y, scalar)); - - /// Returns a vector with the component-wise maximum of a vector and a scalar. - public static Vector2I Max(Vector2I vector, T scalar) => - new Vector2I(T.Max(vector.X, scalar), T.Max(vector.Y, scalar)); - - /// Returns a vector with the component-wise minimum of this and another vector. - public Vector2I Min(Vector2I other) => - new Vector2I(T.Min(X, other.X), T.Min(Y, other.Y)); - - /// Returns a vector with the component-wise minimum of two vectors. - public static Vector2I Min(Vector2I left, Vector2I right) => - new Vector2I(T.Min(left.X, right.X), T.Min(left.Y, right.Y)); - - /// Returns a vector with the component-wise minimum of this vector and a scalar. - public Vector2I Min(T scalar) => - new Vector2I(T.Min(X, scalar), T.Min(Y, scalar)); - - /// Returns a vector with the component-wise minimum of a vector and a scalar. - public static Vector2I Min(Vector2I vector, T scalar) => - new Vector2I(T.Min(vector.X, scalar), T.Min(vector.Y, scalar)); - - /// Clamps this vector's components between the corresponding Min and Max vectors. - public Vector2I Clamp(Vector2I min, Vector2I max) => - new Vector2I(T.Clamp(X, min.X, max.X), T.Clamp(Y, min.Y, max.Y)); - - /// Clamps the components of a vector between the corresponding Min and Max vectors. - public static Vector2I Clamp(Vector2I vector, Vector2I min, Vector2I max) => - new Vector2I(T.Clamp(vector.X, min.X, max.X), T.Clamp(vector.Y, min.Y, max.Y)); - - /// Clamps this vector's components between the Min and Max scalar values. - public Vector2I Clamp(T min, T max) => - new Vector2I(T.Clamp(X, min, max), T.Clamp(Y, min, max)); - - /// Clamps the components of a vector between the Min and Max scalar values. - public static Vector2I Clamp(Vector2I vector, T min, T max) => - new Vector2I(T.Clamp(vector.X, min, max), T.Clamp(vector.Y, min, max)); - - /// Returns a vector with the absolute value of each component of this vector. - public Vector2I Abs() => new Vector2I(T.Abs(X), T.Abs(Y)); - - /// Returns a vector with the absolute value of each component of the specified vector. - public static Vector2I Abs(Vector2I vector) => - new Vector2I(T.Abs(vector.X), T.Abs(vector.Y)); - - /// Returns a vector where each component is the sign of the original vector's component. - public Vector2I Sign() => new Vector2I(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y))); - - /// Returns a vector where each component is the sign of the input vector's component. - public static Vector2I Sign(Vector2I vector) => - new Vector2I(T.CreateChecked(T.Sign(vector.X)), T.CreateChecked(T.Sign(vector.Y))); - - /// Copies the sign of each component from another vector to this vector's components. - public Vector2I CopySign(Vector2I signSource) => - new Vector2I(T.CopySign(X, signSource.X), T.CopySign(Y, signSource.Y)); - - /// Copies the sign of each component from another vector to a new vector. - public static Vector2I CopySign(Vector2I value, Vector2I signSource) => - new Vector2I(T.CopySign(value.X, signSource.X), T.CopySign(value.Y, signSource.Y)); - - /// Copies the sign of a scalar onto each component of this vector. - public Vector2I CopySign(T signScalar) => - new Vector2I(T.CopySign(X, signScalar), T.CopySign(Y, signScalar)); - - /// Copies the sign of a scalar onto each component of a new vector. - public static Vector2I CopySign(Vector2I value, T signScalar) => - new Vector2I(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar)); - // Casts /// Explicitly casts a to a . @@ -108,20 +30,11 @@ public static explicit operator Vector2I(System.Numerics.Vector2 v) => public static explicit operator System.Numerics.Vector2(Vector2I v) => new System.Numerics.Vector2(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); - // IBinaryInteger - // TODO: Verify these are actually correct - - public static Vector2I Log2(Vector2I x) => - new Vector2I(T.Log2(x.X), T.Log2(x.Y)); - public static (Vector2I Quotient, Vector2I Remainder) DivRem(Vector2I left, Vector2I right) { var (qX, rX) = T.DivRem(left.X, right.X); var (qY, rY) = T.DivRem(left.Y, right.Y); return (new Vector2I(qX, qY), new Vector2I(rX, rY)); } - - public static Vector2I PopCount(Vector2I x) => - new Vector2I(T.PopCount(x.X), T.PopCount(x.Y)); } } diff --git a/sources/Maths/Maths/Vector2I.gen.cs b/sources/Maths/Maths/Vector2I.gen.cs index afe221d779..5295369eb4 100644 --- a/sources/Maths/Maths/Vector2I.gen.cs +++ b/sources/Maths/Maths/Vector2I.gen.cs @@ -40,16 +40,16 @@ public Vector2I(ReadOnlySpan values) } /// Gets a vector whose 2 elements are equal to one. - public static Vector2I One => new(Scalar.One); + public static Vector2I One => new(T.One); /// Returns a vector whose 2 elements are equal to zero. public static Vector2I Zero => default; /// Gets the vector (1, 0). - public static Vector2I UnitX => new(Scalar.One, Scalar.Zero); + public static Vector2I UnitX => new(T.One, T.Zero); /// Gets the vector (0, 1). - public static Vector2I UnitY => new(Scalar.Zero, Scalar.One); + public static Vector2I UnitY => new(T.Zero, T.One); /// Gets a vector with all bits set for each component. public static Vector2I AllBitsSet => new Vector2I(T.AllBitsSet, T.AllBitsSet); @@ -305,44 +305,61 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm /// public override int GetHashCode() => HashCode.Combine(X, Y); + /// Desconstructs a vector into its components. + /// The X component. + /// The Y component. + public void Deconstruct(out T x, out T y) + { + x = X; + y = Y; + } + + /// Implicitly casts a to a . + public static implicit operator Vector2I((T X, T Y) v) => + new(v.X, v.Y); + + /// Implicitly casts a to a . + public static implicit operator (T X, T Y)(Vector2I v) => + (v.X, v.Y); + public static Vector2I operator +(Vector2I vector) => vector; public static Vector2I operator -(Vector2I vector) => - new Vector2I(-vector.X, -vector.Y); + new(-vector.X, -vector.Y); public static Vector2I operator +(Vector2I left, Vector2I right) => - new Vector2I(left.X + right.X, left.Y + right.Y); + new(left.X + right.X, left.Y + right.Y); public static Vector2I operator -(Vector2I left, Vector2I right) => - new Vector2I(left.X - right.X, left.Y - right.Y); + new(left.X - right.X, left.Y - right.Y); public static Vector2I operator *(Vector2I left, Vector2I right) => - new Vector2I(left.X * right.X, left.Y * right.Y); + new(left.X * right.X, left.Y * right.Y); public static Vector2I operator /(Vector2I left, Vector2I right) => - new Vector2I(left.X / right.X, left.Y / right.Y); + new(left.X / right.X, left.Y / right.Y); public static Vector2I operator %(Vector2I left, Vector2I right) => - new Vector2I(left.X % right.X, left.Y % right.Y); + new(left.X % right.X, left.Y % right.Y); public static Vector2I operator +(Vector2I vector, T scalar) => - new Vector2I(vector.X + scalar, vector.Y + scalar); + new(vector.X + scalar, vector.Y + scalar); public static Vector2I operator -(Vector2I vector, T scalar) => - new Vector2I(vector.X - scalar, vector.Y - scalar); + new(vector.X - scalar, vector.Y - scalar); public static Vector2I operator *(Vector2I vector, T scalar) => - new Vector2I(vector.X * scalar, vector.Y * scalar); + new(vector.X * scalar, vector.Y * scalar); public static Vector2I operator *(T scalar, Vector2I vector) => - new Vector2I(scalar * vector.X, scalar * vector.Y); + new(scalar * vector.X, scalar * vector.Y); public static Vector2I operator /(Vector2I vector, T scalar) => - new Vector2I(vector.X / scalar, vector.Y / scalar); + new(vector.X / scalar, vector.Y / scalar); public static Vector2I operator %(Vector2I vector, T scalar) => - new Vector2I(vector.X % scalar, vector.Y % scalar); + new(vector.X % scalar, vector.Y % scalar); public static Vector2I operator ~(Vector2I vector) => new Vector2I(~vector.X, ~vector.Y); @@ -390,56 +407,136 @@ public static Vector2I Reflect(Vector2I vector, Vector2I normal) return vector - (normal * (dot + dot)); } - public static Vector2I Log(this Vector2I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log(x.X), TSelf.Log(x.Y)); - - public static Vector2I Log(this Vector2I x, Vector2I newBase) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y)); - - public static Vector2I LogP1(this Vector2I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y)); - - public static Vector2I Log2(this Vector2I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log2(x.X), TSelf.Log2(x.Y)); - - public static Vector2I Log2P1(this Vector2I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y)); - - public static Vector2I Log10(this Vector2I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log10(x.X), TSelf.Log10(x.Y)); - - public static Vector2I Log10P1(this Vector2I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y)); - - public static Vector2I Exp(this Vector2I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp(x.X), TSelf.Exp(x.Y)); - - public static Vector2I ExpM1(this Vector2I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y)); - - public static Vector2I Exp2(this Vector2I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y)); - - public static Vector2I Exp2M1(this Vector2I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y)); - - public static Vector2I Exp10(this Vector2I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y)); - - public static Vector2I Exp10M1(this Vector2I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2I Sign(this Vector2I value) + where TSelf : IBinaryInteger => + new(TSelf.Sign(value.X), TSelf.Sign(value.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2I Max(this Vector2I x, Vector2I y) + where TSelf : IBinaryInteger => + new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2I Max(this Vector2I x, TSelf y) + where TSelf : IBinaryInteger => + new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2I MaxNumber(this Vector2I x, Vector2I y) + where TSelf : IBinaryInteger => + new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2I MaxNumber(this Vector2I x, TSelf y) + where TSelf : IBinaryInteger => + new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2I Min(this Vector2I x, Vector2I y) + where TSelf : IBinaryInteger => + new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2I Min(this Vector2I x, TSelf y) + where TSelf : IBinaryInteger => + new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2I MinNumber(this Vector2I x, Vector2I y) + where TSelf : IBinaryInteger => + new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2I MinNumber(this Vector2I x, TSelf y) + where TSelf : IBinaryInteger => + new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2I Clamp(this Vector2I value, Vector2I min, Vector2I max) + where TSelf : IBinaryInteger => + new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector2I Clamp(this Vector2I value, TSelf min, TSelf max) + where TSelf : IBinaryInteger => + new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2I CopySign(this Vector2I value, Vector2I sign) + where TSelf : IBinaryInteger => + new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2I CopySign(this Vector2I value, TSelf sign) + where TSelf : IBinaryInteger => + new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2I Abs(this Vector2I value) + where TSelf : IBinaryInteger => + new(TSelf.Abs(value.X), TSelf.Abs(value.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2I MaxMagnitude(this Vector2I x, Vector2I y) + where TSelf : IBinaryInteger => + new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2I MaxMagnitudeNumber(this Vector2I x, Vector2I y) + where TSelf : IBinaryInteger => + new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2I MinMagnitude(this Vector2I x, Vector2I y) + where TSelf : IBinaryInteger => + new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2I MinMagnitudeNumber(this Vector2I x, Vector2I y) + where TSelf : IBinaryInteger => + new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2I Log2(this Vector2I value) + where TSelf : IBinaryInteger => + new(TSelf.Log2(value.X), TSelf.Log2(value.Y)); } } diff --git a/sources/Maths/Maths/Vector3F.gen.cs b/sources/Maths/Maths/Vector3F.gen.cs index 6c9a8a9f67..2c0d24db9c 100644 --- a/sources/Maths/Maths/Vector3F.gen.cs +++ b/sources/Maths/Maths/Vector3F.gen.cs @@ -47,19 +47,19 @@ public Vector3F(ReadOnlySpan values) } /// Gets a vector whose 3 elements are equal to one. - public static Vector3F One => new(Scalar.One); + public static Vector3F One => new(T.One); /// Returns a vector whose 3 elements are equal to zero. public static Vector3F Zero => default; /// Gets the vector (1, 0, 0). - public static Vector3F UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero); + public static Vector3F UnitX => new(T.One, T.Zero, T.Zero); /// Gets the vector (0, 1, 0). - public static Vector3F UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero); + public static Vector3F UnitY => new(T.Zero, T.One, T.Zero); /// Gets the vector (0, 0, 1). - public static Vector3F UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One); + public static Vector3F UnitZ => new(T.Zero, T.Zero, T.One); /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => Vector3F.Dot(this, this); @@ -339,44 +339,63 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm /// public override int GetHashCode() => HashCode.Combine(X, Y, Z); + /// Desconstructs a vector into its components. + /// The X component. + /// The Y component. + /// The Z component. + public void Deconstruct(out T x, out T y, out T z) + { + x = X; + y = Y; + z = Z; + } + + /// Implicitly casts a to a . + public static implicit operator Vector3F((T X, T Y, T Z) v) => + new(v.X, v.Y, v.Z); + + /// Implicitly casts a to a . + public static implicit operator (T X, T Y, T Z)(Vector3F v) => + (v.X, v.Y, v.Z); + public static Vector3F operator +(Vector3F vector) => vector; public static Vector3F operator -(Vector3F vector) => - new Vector3F(-vector.X, -vector.Y, -vector.Z); + new(-vector.X, -vector.Y, -vector.Z); public static Vector3F operator +(Vector3F left, Vector3F right) => - new Vector3F(left.X + right.X, left.Y + right.Y, left.Z + right.Z); + new(left.X + right.X, left.Y + right.Y, left.Z + right.Z); public static Vector3F operator -(Vector3F left, Vector3F right) => - new Vector3F(left.X - right.X, left.Y - right.Y, left.Z - right.Z); + new(left.X - right.X, left.Y - right.Y, left.Z - right.Z); public static Vector3F operator *(Vector3F left, Vector3F right) => - new Vector3F(left.X * right.X, left.Y * right.Y, left.Z * right.Z); + new(left.X * right.X, left.Y * right.Y, left.Z * right.Z); public static Vector3F operator /(Vector3F left, Vector3F right) => - new Vector3F(left.X / right.X, left.Y / right.Y, left.Z / right.Z); + new(left.X / right.X, left.Y / right.Y, left.Z / right.Z); public static Vector3F operator %(Vector3F left, Vector3F right) => - new Vector3F(left.X % right.X, left.Y % right.Y, left.Z % right.Z); + new(left.X % right.X, left.Y % right.Y, left.Z % right.Z); public static Vector3F operator +(Vector3F vector, T scalar) => - new Vector3F(vector.X + scalar, vector.Y + scalar, vector.Z + scalar); + new(vector.X + scalar, vector.Y + scalar, vector.Z + scalar); public static Vector3F operator -(Vector3F vector, T scalar) => - new Vector3F(vector.X - scalar, vector.Y - scalar, vector.Z - scalar); + new(vector.X - scalar, vector.Y - scalar, vector.Z - scalar); public static Vector3F operator *(Vector3F vector, T scalar) => - new Vector3F(vector.X * scalar, vector.Y * scalar, vector.Z * scalar); + new(vector.X * scalar, vector.Y * scalar, vector.Z * scalar); public static Vector3F operator *(T scalar, Vector3F vector) => - new Vector3F(scalar * vector.X, scalar * vector.Y, scalar * vector.Z); + new(scalar * vector.X, scalar * vector.Y, scalar * vector.Z); public static Vector3F operator /(Vector3F vector, T scalar) => - new Vector3F(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); + new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); public static Vector3F operator %(Vector3F vector, T scalar) => - new Vector3F(vector.X % scalar, vector.Y % scalar, vector.Z % scalar); + new(vector.X % scalar, vector.Y % scalar, vector.Z % scalar); } @@ -408,56 +427,504 @@ public static Vector3F Normalize(this Vector3F vector) return length != T.Zero ? vector / length : Vector3F.Zero; } + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3I Sign(this Vector3F value) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F Max(this Vector3F x, Vector3F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3F Max(this Vector3F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F MaxNumber(this Vector3F x, Vector3F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3F MaxNumber(this Vector3F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F Min(this Vector3F x, Vector3F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3F Min(this Vector3F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F MinNumber(this Vector3F x, Vector3F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3F MinNumber(this Vector3F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F Clamp(this Vector3F value, Vector3F min, Vector3F max) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector3F Clamp(this Vector3F value, TSelf min, TSelf max) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F CopySign(this Vector3F value, Vector3F sign) + where TSelf : IFloatingPointIeee754 => + new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3F CopySign(this Vector3F value, TSelf sign) + where TSelf : IFloatingPointIeee754 => + new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Abs(this Vector3F value) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F MaxMagnitude(this Vector3F x, Vector3F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F MaxMagnitudeNumber(this Vector3F x, Vector3F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F MinMagnitude(this Vector3F x, Vector3F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F MinMagnitudeNumber(this Vector3F x, Vector3F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Ceiling(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y), TSelf.Ceiling(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Floor(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Floor(x.X), TSelf.Floor(x.Y), TSelf.Floor(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Round(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Round(x.X), TSelf.Round(x.Y), TSelf.Round(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector3F Round(this Vector3F x, int digits, MidpointRounding mode) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode), TSelf.Round(x.Z, digits, mode)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Truncate(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y), TSelf.Truncate(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F Atan2(this Vector3F y, Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y), TSelf.Atan2(y.Z, x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F Atan2Pi(this Vector3F y, Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y), TSelf.Atan2Pi(y.Z, x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3F Lerp(this Vector3F value1, Vector3F value2, TSelf amount) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount), TSelf.Lerp(value1.Z, value2.Z, amount)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F BitDecrement(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y), TSelf.BitDecrement(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F BitIncrement(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y), TSelf.BitIncrement(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F FusedMultiplyAdd(this Vector3F left, Vector3F right, Vector3F addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector3F FusedMultiplyAdd(this Vector3F left, TSelf right, TSelf addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend), TSelf.FusedMultiplyAdd(left.Z, right, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F Ieee754Remainder(this Vector3F left, Vector3F right) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y), TSelf.Ieee754Remainder(left.Z, right.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3F Ieee754Remainder(this Vector3F left, TSelf right) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right), TSelf.Ieee754Remainder(left.Z, right)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3I ILogB(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y), TSelf.ILogB(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F ReciprocalEstimate(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y), TSelf.ReciprocalEstimate(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F ReciprocalSqrtEstimate(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y), TSelf.ReciprocalSqrtEstimate(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F ScaleB(this Vector3F x, Vector3I n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y), TSelf.ScaleB(x.Z, n.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3F ScaleB(this Vector3F x, int n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n), TSelf.ScaleB(x.Z, n)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F Pow(this Vector3F x, Vector3F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y), TSelf.Pow(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3F Pow(this Vector3F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y), TSelf.Pow(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Cbrt(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y), TSelf.Cbrt(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Sqrt(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y), TSelf.Sqrt(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3F RootN(this Vector3F x, int n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n), TSelf.RootN(x.Z, n)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F RootN(this Vector3F x, Vector3I n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y), TSelf.RootN(x.Z, n.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3F Hypot(this Vector3F x, Vector3F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y), TSelf.Hypot(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector3F Log(this Vector3F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z)); - public static Vector3F Log(this Vector3F x, Vector3F newBase) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => - new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3F Log(this Vector3F x, TSelf newBase) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase), TSelf.Log(x.Z, newBase)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector3F LogP1(this Vector3F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector3F Log2(this Vector3F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector3F Log2P1(this Vector3F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector3F Log10(this Vector3F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector3F Log10P1(this Vector3F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector3F Exp(this Vector3F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector3F ExpM1(this Vector3F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector3F Exp2(this Vector3F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector3F Exp2M1(this Vector3F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector3F Exp10(this Vector3F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector3F Exp10M1(this Vector3F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Acos(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Acos(x.X), TSelf.Acos(x.Y), TSelf.Acos(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F AcosPi(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y), TSelf.AcosPi(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Asin(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Asin(x.X), TSelf.Asin(x.Y), TSelf.Asin(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F AsinPi(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y), TSelf.AsinPi(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Atan(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan(x.X), TSelf.Atan(x.Y), TSelf.Atan(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F AtanPi(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y), TSelf.AtanPi(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Cos(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Cos(x.X), TSelf.Cos(x.Y), TSelf.Cos(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F CosPi(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y), TSelf.CosPi(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Sin(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Sin(x.X), TSelf.Sin(x.Y), TSelf.Sin(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F SinPi(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y), TSelf.SinPi(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Tan(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Tan(x.X), TSelf.Tan(x.Y), TSelf.Tan(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F TanPi(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y), TSelf.TanPi(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F DegreesToRadians(this Vector3F degrees) + where TSelf : IFloatingPointIeee754 => + new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y), TSelf.DegreesToRadians(degrees.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F RadiansToDegrees(this Vector3F radians) + where TSelf : IFloatingPointIeee754 => + new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y), TSelf.RadiansToDegrees(radians.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Acosh(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y), TSelf.Acosh(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Asinh(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y), TSelf.Asinh(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Atanh(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y), TSelf.Atanh(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Cosh(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y), TSelf.Cosh(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Sinh(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y), TSelf.Sinh(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3F Tanh(this Vector3F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y), TSelf.Tanh(x.Z)); } } diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3I.cs index 167273b467..4141292c52 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3I.cs @@ -30,101 +30,6 @@ public static Vector3I Cross(Vector3I left, Vector3I right) => (left.X * right.Y) - (left.Y * right.X) ); - /// Returns a vector with the component-wise maximum of this and another vector. - public Vector3I Max(Vector3I other) => - new Vector3I(T.Max(X, other.X), T.Max(Y, other.Y), T.Max(Z, other.Z)); - - /// Returns a vector with the component-wise maximum of two vectors. - public static Vector3I Max(Vector3I left, Vector3I right) => - new Vector3I(T.Max(left.X, right.X), T.Max(left.Y, right.Y), T.Max(left.Z, right.Z)); - - /// Returns a vector with the component-wise maximum of this vector and a scalar. - public Vector3I Max(T scalar) => - new Vector3I(T.Max(X, scalar), T.Max(Y, scalar), T.Max(Z, scalar)); - - /// Returns a vector with the component-wise maximum of a vector and a scalar. - public static Vector3I Max(Vector3I vector, T scalar) => - new Vector3I(T.Max(vector.X, scalar), T.Max(vector.Y, scalar), T.Max(vector.Z, scalar)); - - /// Returns a vector with the component-wise minimum of this and another vector. - public Vector3I Min(Vector3I other) => - new Vector3I(T.Min(X, other.X), T.Min(Y, other.Y), T.Min(Z, other.Z)); - - /// Returns a vector with the component-wise minimum of two vectors. - public static Vector3I Min(Vector3I left, Vector3I right) => - new Vector3I(T.Min(left.X, right.X), T.Min(left.Y, right.Y), T.Min(left.Z, right.Z)); - - /// Returns a vector with the component-wise minimum of this vector and a scalar. - public Vector3I Min(T scalar) => - new Vector3I(T.Min(X, scalar), T.Min(Y, scalar), T.Min(Z, scalar)); - - /// Returns a vector with the component-wise minimum of a vector and a scalar. - public static Vector3I Min(Vector3I vector, T scalar) => - new Vector3I(T.Min(vector.X, scalar), T.Min(vector.Y, scalar), T.Min(vector.Z, scalar)); - - /// Clamps this vector's components between the corresponding Min and Max vectors. - public Vector3I Clamp(Vector3I min, Vector3I max) => - new Vector3I( - T.Clamp(X, min.X, max.X), - T.Clamp(Y, min.Y, max.Y), - T.Clamp(Z, min.Z, max.Z) - ); - - /// Clamps the components of a vector between the corresponding Min and Max vectors. - public static Vector3I Clamp(Vector3I vector, Vector3I min, Vector3I max) => - new Vector3I( - T.Clamp(vector.X, min.X, max.X), - T.Clamp(vector.Y, min.Y, max.Y), - T.Clamp(vector.Z, min.Z, max.Z) - ); - - /// Clamps this vector's components between the Min and Max scalar values. - public Vector3I Clamp(T min, T max) => - new Vector3I( - T.Clamp(X, min, max), - T.Clamp(Y, min, max), - T.Clamp(Z, min, max) - ); - - /// Clamps the components of a vector between the Min and Max scalar values. - public static Vector3I Clamp(Vector3I vector, T min, T max) => - new Vector3I( - T.Clamp(vector.X, min, max), - T.Clamp(vector.Y, min, max), - T.Clamp(vector.Z, min, max) - ); - - /// Returns a vector with the absolute value of each component of this vector. - public Vector3I Abs() => new Vector3I(T.Abs(X), T.Abs(Y), T.Abs(Z)); - - /// Returns a vector with the absolute value of each component of the specified vector. - public static Vector3I Abs(Vector3I vector) => - new Vector3I(T.Abs(vector.X), T.Abs(vector.Y), T.Abs(vector.Z)); - - /// Returns a vector where each component is the sign of the original vector's component. - public Vector3I Sign() => - new Vector3I(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y)), T.CreateChecked(T.Sign(Z))); - - /// Returns a vector where each component is the sign of the input vector's component. - public static Vector3I Sign(Vector3I vector) => - new Vector3I(T.CreateChecked(T.Sign(vector.X)), T.CreateChecked(T.Sign(vector.Y)), T.CreateChecked(T.Sign(vector.Z))); - - /// Copies the sign of each component from another vector to this vector's components. - public Vector3I CopySign(Vector3I signSource) => - new Vector3I(T.CopySign(X, signSource.X), T.CopySign(Y, signSource.Y), T.CopySign(Z, signSource.Z)); - - /// Copies the sign of each component from another vector to a new vector. - public static Vector3I CopySign(Vector3I value, Vector3I signSource) => - new Vector3I(T.CopySign(value.X, signSource.X), T.CopySign(value.Y, signSource.Y), T.CopySign(value.Z, signSource.Z)); - - /// Copies the sign of a scalar onto each component of this vector. - public Vector3I CopySign(T signScalar) => - new Vector3I(T.CopySign(X, signScalar), T.CopySign(Y, signScalar), T.CopySign(Z, signScalar)); - - /// Copies the sign of a scalar onto each component of a new vector. - public static Vector3I CopySign(Vector3I value, T signScalar) => - new Vector3I(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar), T.CopySign(value.Z, signScalar)); - // Casts /// Explicitly casts a to a . @@ -135,10 +40,6 @@ public static explicit operator Vector3I(System.Numerics.Vector3 v) => public static explicit operator System.Numerics.Vector3(Vector3I v) => new System.Numerics.Vector3(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z)); - // IBinaryInteger - public static Vector3I Log2(Vector3I x) => - new Vector3I(T.Log2(x.X), T.Log2(x.Y), T.Log2(x.Z)); - public static (Vector3I Quotient, Vector3I Remainder) DivRem(Vector3I left, Vector3I right) { var (qX, rX) = T.DivRem(left.X, right.X); @@ -146,8 +47,5 @@ public static (Vector3I Quotient, Vector3I Remainder) DivRem(Vector3I l var (qZ, rZ) = T.DivRem(left.Z, right.Z); return (new Vector3I(qX, qY, qZ), new Vector3I(rX, rY, rZ)); } - - public static Vector3I PopCount(Vector3I x) => - new Vector3I(T.PopCount(x.X), T.PopCount(x.Y), T.PopCount(x.Z)); } } diff --git a/sources/Maths/Maths/Vector3I.gen.cs b/sources/Maths/Maths/Vector3I.gen.cs index 05bb368e10..197cb262d2 100644 --- a/sources/Maths/Maths/Vector3I.gen.cs +++ b/sources/Maths/Maths/Vector3I.gen.cs @@ -47,19 +47,19 @@ public Vector3I(ReadOnlySpan values) } /// Gets a vector whose 3 elements are equal to one. - public static Vector3I One => new(Scalar.One); + public static Vector3I One => new(T.One); /// Returns a vector whose 3 elements are equal to zero. public static Vector3I Zero => default; /// Gets the vector (1, 0, 0). - public static Vector3I UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero); + public static Vector3I UnitX => new(T.One, T.Zero, T.Zero); /// Gets the vector (0, 1, 0). - public static Vector3I UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero); + public static Vector3I UnitY => new(T.Zero, T.One, T.Zero); /// Gets the vector (0, 0, 1). - public static Vector3I UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One); + public static Vector3I UnitZ => new(T.Zero, T.Zero, T.One); /// Gets a vector with all bits set for each component. public static Vector3I AllBitsSet => new Vector3I(T.AllBitsSet, T.AllBitsSet, T.AllBitsSet); @@ -342,44 +342,63 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm /// public override int GetHashCode() => HashCode.Combine(X, Y, Z); + /// Desconstructs a vector into its components. + /// The X component. + /// The Y component. + /// The Z component. + public void Deconstruct(out T x, out T y, out T z) + { + x = X; + y = Y; + z = Z; + } + + /// Implicitly casts a to a . + public static implicit operator Vector3I((T X, T Y, T Z) v) => + new(v.X, v.Y, v.Z); + + /// Implicitly casts a to a . + public static implicit operator (T X, T Y, T Z)(Vector3I v) => + (v.X, v.Y, v.Z); + public static Vector3I operator +(Vector3I vector) => vector; public static Vector3I operator -(Vector3I vector) => - new Vector3I(-vector.X, -vector.Y, -vector.Z); + new(-vector.X, -vector.Y, -vector.Z); public static Vector3I operator +(Vector3I left, Vector3I right) => - new Vector3I(left.X + right.X, left.Y + right.Y, left.Z + right.Z); + new(left.X + right.X, left.Y + right.Y, left.Z + right.Z); public static Vector3I operator -(Vector3I left, Vector3I right) => - new Vector3I(left.X - right.X, left.Y - right.Y, left.Z - right.Z); + new(left.X - right.X, left.Y - right.Y, left.Z - right.Z); public static Vector3I operator *(Vector3I left, Vector3I right) => - new Vector3I(left.X * right.X, left.Y * right.Y, left.Z * right.Z); + new(left.X * right.X, left.Y * right.Y, left.Z * right.Z); public static Vector3I operator /(Vector3I left, Vector3I right) => - new Vector3I(left.X / right.X, left.Y / right.Y, left.Z / right.Z); + new(left.X / right.X, left.Y / right.Y, left.Z / right.Z); public static Vector3I operator %(Vector3I left, Vector3I right) => - new Vector3I(left.X % right.X, left.Y % right.Y, left.Z % right.Z); + new(left.X % right.X, left.Y % right.Y, left.Z % right.Z); public static Vector3I operator +(Vector3I vector, T scalar) => - new Vector3I(vector.X + scalar, vector.Y + scalar, vector.Z + scalar); + new(vector.X + scalar, vector.Y + scalar, vector.Z + scalar); public static Vector3I operator -(Vector3I vector, T scalar) => - new Vector3I(vector.X - scalar, vector.Y - scalar, vector.Z - scalar); + new(vector.X - scalar, vector.Y - scalar, vector.Z - scalar); public static Vector3I operator *(Vector3I vector, T scalar) => - new Vector3I(vector.X * scalar, vector.Y * scalar, vector.Z * scalar); + new(vector.X * scalar, vector.Y * scalar, vector.Z * scalar); public static Vector3I operator *(T scalar, Vector3I vector) => - new Vector3I(scalar * vector.X, scalar * vector.Y, scalar * vector.Z); + new(scalar * vector.X, scalar * vector.Y, scalar * vector.Z); public static Vector3I operator /(Vector3I vector, T scalar) => - new Vector3I(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); + new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); public static Vector3I operator %(Vector3I vector, T scalar) => - new Vector3I(vector.X % scalar, vector.Y % scalar, vector.Z % scalar); + new(vector.X % scalar, vector.Y % scalar, vector.Z % scalar); public static Vector3I operator ~(Vector3I vector) => new Vector3I(~vector.X, ~vector.Y, ~vector.Z); @@ -427,56 +446,136 @@ public static Vector3I Reflect(Vector3I vector, Vector3I normal) return vector - (normal * (dot + dot)); } - public static Vector3I Log(this Vector3I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z)); - - public static Vector3I Log(this Vector3I x, Vector3I newBase) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z)); - - public static Vector3I LogP1(this Vector3I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z)); - - public static Vector3I Log2(this Vector3I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z)); - - public static Vector3I Log2P1(this Vector3I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z)); - - public static Vector3I Log10(this Vector3I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z)); - - public static Vector3I Log10P1(this Vector3I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z)); - - public static Vector3I Exp(this Vector3I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z)); - - public static Vector3I ExpM1(this Vector3I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z)); - - public static Vector3I Exp2(this Vector3I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z)); - - public static Vector3I Exp2M1(this Vector3I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z)); - - public static Vector3I Exp10(this Vector3I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z)); - - public static Vector3I Exp10M1(this Vector3I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3I Sign(this Vector3I value) + where TSelf : IBinaryInteger => + new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3I Max(this Vector3I x, Vector3I y) + where TSelf : IBinaryInteger => + new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3I Max(this Vector3I x, TSelf y) + where TSelf : IBinaryInteger => + new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3I MaxNumber(this Vector3I x, Vector3I y) + where TSelf : IBinaryInteger => + new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3I MaxNumber(this Vector3I x, TSelf y) + where TSelf : IBinaryInteger => + new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3I Min(this Vector3I x, Vector3I y) + where TSelf : IBinaryInteger => + new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3I Min(this Vector3I x, TSelf y) + where TSelf : IBinaryInteger => + new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3I MinNumber(this Vector3I x, Vector3I y) + where TSelf : IBinaryInteger => + new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3I MinNumber(this Vector3I x, TSelf y) + where TSelf : IBinaryInteger => + new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3I Clamp(this Vector3I value, Vector3I min, Vector3I max) + where TSelf : IBinaryInteger => + new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector3I Clamp(this Vector3I value, TSelf min, TSelf max) + where TSelf : IBinaryInteger => + new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3I CopySign(this Vector3I value, Vector3I sign) + where TSelf : IBinaryInteger => + new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3I CopySign(this Vector3I value, TSelf sign) + where TSelf : IBinaryInteger => + new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3I Abs(this Vector3I value) + where TSelf : IBinaryInteger => + new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3I MaxMagnitude(this Vector3I x, Vector3I y) + where TSelf : IBinaryInteger => + new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3I MaxMagnitudeNumber(this Vector3I x, Vector3I y) + where TSelf : IBinaryInteger => + new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3I MinMagnitude(this Vector3I x, Vector3I y) + where TSelf : IBinaryInteger => + new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3I MinMagnitudeNumber(this Vector3I x, Vector3I y) + where TSelf : IBinaryInteger => + new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3I Log2(this Vector3I value) + where TSelf : IBinaryInteger => + new(TSelf.Log2(value.X), TSelf.Log2(value.Y), TSelf.Log2(value.Z)); } } diff --git a/sources/Maths/Maths/Vector4F.gen.cs b/sources/Maths/Maths/Vector4F.gen.cs index be1a8e23ed..cd0dd8a87d 100644 --- a/sources/Maths/Maths/Vector4F.gen.cs +++ b/sources/Maths/Maths/Vector4F.gen.cs @@ -54,22 +54,22 @@ public Vector4F(ReadOnlySpan values) } /// Gets a vector whose 4 elements are equal to one. - public static Vector4F One => new(Scalar.One); + public static Vector4F One => new(T.One); /// Returns a vector whose 4 elements are equal to zero. public static Vector4F Zero => default; /// Gets the vector (1, 0, 0, 0). - public static Vector4F UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero, Scalar.Zero); + public static Vector4F UnitX => new(T.One, T.Zero, T.Zero, T.Zero); /// Gets the vector (0, 1, 0, 0). - public static Vector4F UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero, Scalar.Zero); + public static Vector4F UnitY => new(T.Zero, T.One, T.Zero, T.Zero); /// Gets the vector (0, 0, 1, 0). - public static Vector4F UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One, Scalar.Zero); + public static Vector4F UnitZ => new(T.Zero, T.Zero, T.One, T.Zero); /// Gets the vector (0, 0, 0, 1). - public static Vector4F UnitW => new(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); + public static Vector4F UnitW => new(T.Zero, T.Zero, T.Zero, T.One); /// Gets the squared length of the vector (dot product with itself). public T LengthSquared => Vector4F.Dot(this, this); @@ -376,44 +376,65 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm /// public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); + /// Desconstructs a vector into its components. + /// The X component. + /// The Y component. + /// The Z component. + /// The W component. + public void Deconstruct(out T x, out T y, out T z, out T w) + { + x = X; + y = Y; + z = Z; + w = W; + } + + /// Implicitly casts a to a . + public static implicit operator Vector4F((T X, T Y, T Z, T W) v) => + new(v.X, v.Y, v.Z, v.W); + + /// Implicitly casts a to a . + public static implicit operator (T X, T Y, T Z, T W)(Vector4F v) => + (v.X, v.Y, v.Z, v.W); + public static Vector4F operator +(Vector4F vector) => vector; public static Vector4F operator -(Vector4F vector) => - new Vector4F(-vector.X, -vector.Y, -vector.Z, -vector.W); + new(-vector.X, -vector.Y, -vector.Z, -vector.W); public static Vector4F operator +(Vector4F left, Vector4F right) => - new Vector4F(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); + new(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); public static Vector4F operator -(Vector4F left, Vector4F right) => - new Vector4F(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); + new(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); public static Vector4F operator *(Vector4F left, Vector4F right) => - new Vector4F(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W); + new(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W); public static Vector4F operator /(Vector4F left, Vector4F right) => - new Vector4F(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W); + new(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W); public static Vector4F operator %(Vector4F left, Vector4F right) => - new Vector4F(left.X % right.X, left.Y % right.Y, left.Z % right.Z, left.W % right.W); + new(left.X % right.X, left.Y % right.Y, left.Z % right.Z, left.W % right.W); public static Vector4F operator +(Vector4F vector, T scalar) => - new Vector4F(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar); + new(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar); public static Vector4F operator -(Vector4F vector, T scalar) => - new Vector4F(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar); + new(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar); public static Vector4F operator *(Vector4F vector, T scalar) => - new Vector4F(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar); + new(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar); public static Vector4F operator *(T scalar, Vector4F vector) => - new Vector4F(scalar * vector.X, scalar * vector.Y, scalar * vector.Z, scalar * vector.W); + new(scalar * vector.X, scalar * vector.Y, scalar * vector.Z, scalar * vector.W); public static Vector4F operator /(Vector4F vector, T scalar) => - new Vector4F(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); + new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); public static Vector4F operator %(Vector4F vector, T scalar) => - new Vector4F(vector.X % scalar, vector.Y % scalar, vector.Z % scalar, vector.W % scalar); + new(vector.X % scalar, vector.Y % scalar, vector.Z % scalar, vector.W % scalar); } @@ -445,56 +466,504 @@ public static Vector4F Normalize(this Vector4F vector) return length != T.Zero ? vector / length : Vector4F.Zero; } + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4I Sign(this Vector4F value) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z), TSelf.Sign(value.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F Max(this Vector4F x, Vector4F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z), TSelf.Max(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4F Max(this Vector4F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y), TSelf.Max(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F MaxNumber(this Vector4F x, Vector4F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z), TSelf.MaxNumber(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4F MaxNumber(this Vector4F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y), TSelf.MaxNumber(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F Min(this Vector4F x, Vector4F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z), TSelf.Min(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4F Min(this Vector4F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y), TSelf.Min(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F MinNumber(this Vector4F x, Vector4F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z), TSelf.MinNumber(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4F MinNumber(this Vector4F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y), TSelf.MinNumber(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F Clamp(this Vector4F value, Vector4F min, Vector4F max) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z), TSelf.Clamp(value.W, min.W, max.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector4F Clamp(this Vector4F value, TSelf min, TSelf max) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max), TSelf.Clamp(value.W, min, max)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F CopySign(this Vector4F value, Vector4F sign) + where TSelf : IFloatingPointIeee754 => + new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z), TSelf.CopySign(value.W, sign.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4F CopySign(this Vector4F value, TSelf sign) + where TSelf : IFloatingPointIeee754 => + new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign), TSelf.CopySign(value.W, sign)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Abs(this Vector4F value) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z), TSelf.Abs(value.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F MaxMagnitude(this Vector4F x, Vector4F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z), TSelf.MaxMagnitude(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F MaxMagnitudeNumber(this Vector4F x, Vector4F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z), TSelf.MaxMagnitudeNumber(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F MinMagnitude(this Vector4F x, Vector4F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z), TSelf.MinMagnitude(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F MinMagnitudeNumber(this Vector4F x, Vector4F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z), TSelf.MinMagnitudeNumber(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Ceiling(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y), TSelf.Ceiling(x.Z), TSelf.Ceiling(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Floor(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Floor(x.X), TSelf.Floor(x.Y), TSelf.Floor(x.Z), TSelf.Floor(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Round(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Round(x.X), TSelf.Round(x.Y), TSelf.Round(x.Z), TSelf.Round(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector4F Round(this Vector4F x, int digits, MidpointRounding mode) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode), TSelf.Round(x.Z, digits, mode), TSelf.Round(x.W, digits, mode)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Truncate(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y), TSelf.Truncate(x.Z), TSelf.Truncate(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F Atan2(this Vector4F y, Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y), TSelf.Atan2(y.Z, x.Z), TSelf.Atan2(y.W, x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F Atan2Pi(this Vector4F y, Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y), TSelf.Atan2Pi(y.Z, x.Z), TSelf.Atan2Pi(y.W, x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4F Lerp(this Vector4F value1, Vector4F value2, TSelf amount) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount), TSelf.Lerp(value1.Z, value2.Z, amount), TSelf.Lerp(value1.W, value2.W, amount)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F BitDecrement(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y), TSelf.BitDecrement(x.Z), TSelf.BitDecrement(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F BitIncrement(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y), TSelf.BitIncrement(x.Z), TSelf.BitIncrement(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F FusedMultiplyAdd(this Vector4F left, Vector4F right, Vector4F addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend.Z), TSelf.FusedMultiplyAdd(left.W, right.W, addend.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector4F FusedMultiplyAdd(this Vector4F left, TSelf right, TSelf addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend), TSelf.FusedMultiplyAdd(left.Z, right, addend), TSelf.FusedMultiplyAdd(left.W, right, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F Ieee754Remainder(this Vector4F left, Vector4F right) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y), TSelf.Ieee754Remainder(left.Z, right.Z), TSelf.Ieee754Remainder(left.W, right.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4F Ieee754Remainder(this Vector4F left, TSelf right) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right), TSelf.Ieee754Remainder(left.Z, right), TSelf.Ieee754Remainder(left.W, right)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4I ILogB(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y), TSelf.ILogB(x.Z), TSelf.ILogB(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F ReciprocalEstimate(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y), TSelf.ReciprocalEstimate(x.Z), TSelf.ReciprocalEstimate(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F ReciprocalSqrtEstimate(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y), TSelf.ReciprocalSqrtEstimate(x.Z), TSelf.ReciprocalSqrtEstimate(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F ScaleB(this Vector4F x, Vector4I n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y), TSelf.ScaleB(x.Z, n.Z), TSelf.ScaleB(x.W, n.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4F ScaleB(this Vector4F x, int n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n), TSelf.ScaleB(x.Z, n), TSelf.ScaleB(x.W, n)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F Pow(this Vector4F x, Vector4F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y), TSelf.Pow(x.Z, y.Z), TSelf.Pow(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4F Pow(this Vector4F x, TSelf y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y), TSelf.Pow(x.Z, y), TSelf.Pow(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Cbrt(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y), TSelf.Cbrt(x.Z), TSelf.Cbrt(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Sqrt(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y), TSelf.Sqrt(x.Z), TSelf.Sqrt(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4F RootN(this Vector4F x, int n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n), TSelf.RootN(x.Z, n), TSelf.RootN(x.W, n)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F RootN(this Vector4F x, Vector4I n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y), TSelf.RootN(x.Z, n.Z), TSelf.RootN(x.W, n.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4F Hypot(this Vector4F x, Vector4F y) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y), TSelf.Hypot(x.Z, y.Z), TSelf.Hypot(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector4F Log(this Vector4F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z), TSelf.Log(x.W)); - public static Vector4F Log(this Vector4F x, Vector4F newBase) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => - new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z), TSelf.Log(x.W, newBase.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4F Log(this Vector4F x, TSelf newBase) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase), TSelf.Log(x.Z, newBase), TSelf.Log(x.W, newBase)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector4F LogP1(this Vector4F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z), TSelf.LogP1(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector4F Log2(this Vector4F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z), TSelf.Log2(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector4F Log2P1(this Vector4F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z), TSelf.Log2P1(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector4F Log10(this Vector4F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z), TSelf.Log10(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector4F Log10P1(this Vector4F x) - where TSelf : IFloatingPointIeee754, ILogarithmicFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z), TSelf.Log10P1(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector4F Exp(this Vector4F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z), TSelf.Exp(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector4F ExpM1(this Vector4F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z), TSelf.ExpM1(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector4F Exp2(this Vector4F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z), TSelf.Exp2(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector4F Exp2M1(this Vector4F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z), TSelf.Exp2M1(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector4F Exp10(this Vector4F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z), TSelf.Exp10(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static Vector4F Exp10M1(this Vector4F x) - where TSelf : IFloatingPointIeee754, IExponentialFunctions => + where TSelf : IFloatingPointIeee754 => new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z), TSelf.Exp10M1(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Acos(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Acos(x.X), TSelf.Acos(x.Y), TSelf.Acos(x.Z), TSelf.Acos(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F AcosPi(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y), TSelf.AcosPi(x.Z), TSelf.AcosPi(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Asin(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Asin(x.X), TSelf.Asin(x.Y), TSelf.Asin(x.Z), TSelf.Asin(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F AsinPi(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y), TSelf.AsinPi(x.Z), TSelf.AsinPi(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Atan(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan(x.X), TSelf.Atan(x.Y), TSelf.Atan(x.Z), TSelf.Atan(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F AtanPi(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y), TSelf.AtanPi(x.Z), TSelf.AtanPi(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Cos(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Cos(x.X), TSelf.Cos(x.Y), TSelf.Cos(x.Z), TSelf.Cos(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F CosPi(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y), TSelf.CosPi(x.Z), TSelf.CosPi(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Sin(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Sin(x.X), TSelf.Sin(x.Y), TSelf.Sin(x.Z), TSelf.Sin(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F SinPi(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y), TSelf.SinPi(x.Z), TSelf.SinPi(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Tan(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Tan(x.X), TSelf.Tan(x.Y), TSelf.Tan(x.Z), TSelf.Tan(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F TanPi(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y), TSelf.TanPi(x.Z), TSelf.TanPi(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F DegreesToRadians(this Vector4F degrees) + where TSelf : IFloatingPointIeee754 => + new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y), TSelf.DegreesToRadians(degrees.Z), TSelf.DegreesToRadians(degrees.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F RadiansToDegrees(this Vector4F radians) + where TSelf : IFloatingPointIeee754 => + new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y), TSelf.RadiansToDegrees(radians.Z), TSelf.RadiansToDegrees(radians.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Acosh(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y), TSelf.Acosh(x.Z), TSelf.Acosh(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Asinh(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y), TSelf.Asinh(x.Z), TSelf.Asinh(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Atanh(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y), TSelf.Atanh(x.Z), TSelf.Atanh(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Cosh(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y), TSelf.Cosh(x.Z), TSelf.Cosh(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Sinh(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y), TSelf.Sinh(x.Z), TSelf.Sinh(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4F Tanh(this Vector4F x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y), TSelf.Tanh(x.Z), TSelf.Tanh(x.W)); } } diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4I.cs index 16c3e21720..3b7442adbc 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4I.cs @@ -13,105 +13,6 @@ namespace Silk.NET.Maths /// A structure representing a 4D integer vector. internal partial struct Vector4I { - /// Returns a vector with the component-wise maximum of this and another vector. - public Vector4I Max(Vector4I other) => - new Vector4I(T.Max(X, other.X), T.Max(Y, other.Y), T.Max(Z, other.Z), T.Max(W, other.W)); - - /// Returns a vector with the component-wise maximum of two vectors. - public static Vector4I Max(Vector4I left, Vector4I right) => - new Vector4I(T.Max(left.X, right.X), T.Max(left.Y, right.Y), T.Max(left.Z, right.Z), T.Max(left.W, right.W)); - - /// Returns a vector with the component-wise maximum of this vector and a scalar. - public Vector4I Max(T scalar) => - new Vector4I(T.Max(X, scalar), T.Max(Y, scalar), T.Max(Z, scalar), T.Max(W, scalar)); - - /// Returns a vector with the component-wise maximum of a vector and a scalar. - public static Vector4I Max(Vector4I vector, T scalar) => - new Vector4I(T.Max(vector.X, scalar), T.Max(vector.Y, scalar), T.Max(vector.Z, scalar), T.Max(vector.W, scalar)); - - /// Returns a vector with the component-wise minimum of this and another vector. - public Vector4I Min(Vector4I other) => - new Vector4I(T.Min(X, other.X), T.Min(Y, other.Y), T.Min(Z, other.Z), T.Min(W, other.W)); - - /// Returns a vector with the component-wise minimum of two vectors. - public static Vector4I Min(Vector4I left, Vector4I right) => - new Vector4I(T.Min(left.X, right.X), T.Min(left.Y, right.Y), T.Min(left.Z, right.Z), T.Min(left.W, right.W)); - - /// Returns a vector with the component-wise minimum of this vector and a scalar. - public Vector4I Min(T scalar) => - new Vector4I(T.Min(X, scalar), T.Min(Y, scalar), T.Min(Z, scalar), T.Min(W, scalar)); - - /// Returns a vector with the component-wise minimum of a vector and a scalar. - public static Vector4I Min(Vector4I vector, T scalar) => - new Vector4I(T.Min(vector.X, scalar), T.Min(vector.Y, scalar), T.Min(vector.Z, scalar), T.Min(vector.W, scalar)); - - /// Clamps this vector's components between the corresponding Min and Max vectors. - public Vector4I Clamp(Vector4I min, Vector4I max) => - new Vector4I( - T.Clamp(X, min.X, max.X), - T.Clamp(Y, min.Y, max.Y), - T.Clamp(Z, min.Z, max.Z), - T.Clamp(W, min.W, max.W) - ); - - /// Clamps the components of a vector between the corresponding Min and Max vectors. - public static Vector4I Clamp(Vector4I vector, Vector4I min, Vector4I max) => - new Vector4I( - T.Clamp(vector.X, min.X, max.X), - T.Clamp(vector.Y, min.Y, max.Y), - T.Clamp(vector.Z, min.Z, max.Z), - T.Clamp(vector.W, min.W, max.W) - ); - - /// Clamps this vector's components between the Min and Max scalar values. - public Vector4I Clamp(T min, T max) => - new Vector4I( - T.Clamp(X, min, max), - T.Clamp(Y, min, max), - T.Clamp(Z, min, max), - T.Clamp(W, min, max) - ); - - /// Clamps the components of a vector between the Min and Max scalar values. - public static Vector4I Clamp(Vector4I vector, T min, T max) => - new Vector4I( - T.Clamp(vector.X, min, max), - T.Clamp(vector.Y, min, max), - T.Clamp(vector.Z, min, max), - T.Clamp(vector.W, min, max) - ); - - /// Returns a vector with the absolute value of each component of this vector. - public Vector4I Abs() => new Vector4I(T.Abs(X), T.Abs(Y), T.Abs(Z), T.Abs(W)); - - /// Returns a vector with the absolute value of each component of the specified vector. - public static Vector4I Abs(Vector4I vector) => - new Vector4I(T.Abs(vector.X), T.Abs(vector.Y), T.Abs(vector.Z), T.Abs(vector.W)); - - /// Returns a vector where each component is the sign of the original vector's component. - public Vector4I Sign() => - new Vector4I(T.CreateChecked(T.Sign(X)), T.CreateChecked(T.Sign(Y)), T.CreateChecked(T.Sign(Z)), T.CreateChecked(T.Sign(W))); - - /// Returns a vector where each component is the sign of the input vector's component. - public static Vector4I Sign(Vector4I vector) => - new Vector4I(T.CreateChecked(T.Sign(vector.X)), T.CreateChecked(T.Sign(vector.Y)), T.CreateChecked(T.Sign(vector.Z)), T.CreateChecked(T.Sign(vector.W))); - - /// Copies the sign of each component from another vector to this vector's components. - public Vector4I CopySign(Vector4I signSource) => - new Vector4I(T.CopySign(X, signSource.X), T.CopySign(Y, signSource.Y), T.CopySign(Z, signSource.Z), T.CopySign(W, signSource.W)); - - /// Copies the sign of each component from another vector to a new vector. - public static Vector4I CopySign(Vector4I value, Vector4I signSource) => - new Vector4I(T.CopySign(value.X, signSource.X), T.CopySign(value.Y, signSource.Y), T.CopySign(value.Z, signSource.Z), T.CopySign(value.W, signSource.W)); - - /// Copies the sign of a scalar onto each component of this vector. - public Vector4I CopySign(T signScalar) => - new Vector4I(T.CopySign(X, signScalar), T.CopySign(Y, signScalar), T.CopySign(Z, signScalar), T.CopySign(W, signScalar)); - - /// Copies the sign of a scalar onto each component of a new vector. - public static Vector4I CopySign(Vector4I value, T signScalar) => - new Vector4I(T.CopySign(value.X, signScalar), T.CopySign(value.Y, signScalar), T.CopySign(value.Z, signScalar), T.CopySign(value.W, signScalar)); - // Casts /// Explicitly casts a System.Numerics.Vector4 to a Vector4I. @@ -122,10 +23,6 @@ public static explicit operator Vector4I(System.Numerics.Vector4 v) => public static explicit operator System.Numerics.Vector4(Vector4I v) => new System.Numerics.Vector4(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z), Convert.ToSingle(v.W)); - // IBinaryInteger - public static Vector4I Log2(Vector4I x) => - new Vector4I(T.Log2(x.X), T.Log2(x.Y), T.Log2(x.Z), T.Log2(x.W)); - public static (Vector4I Quotient, Vector4I Remainder) DivRem(Vector4I left, Vector4I right) { var (qX, rX) = T.DivRem(left.X, right.X); @@ -134,8 +31,5 @@ public static (Vector4I Quotient, Vector4I Remainder) DivRem(Vector4I l var (qW, rW) = T.DivRem(left.W, right.W); return (new Vector4I(qX, qY, qZ, qW), new Vector4I(rX, rY, rZ, rW)); } - - public static Vector4I PopCount(Vector4I x) => - new Vector4I(T.PopCount(x.X), T.PopCount(x.Y), T.PopCount(x.Z), T.PopCount(x.W)); } } diff --git a/sources/Maths/Maths/Vector4I.gen.cs b/sources/Maths/Maths/Vector4I.gen.cs index 04eb7ca61c..b87494d968 100644 --- a/sources/Maths/Maths/Vector4I.gen.cs +++ b/sources/Maths/Maths/Vector4I.gen.cs @@ -54,22 +54,22 @@ public Vector4I(ReadOnlySpan values) } /// Gets a vector whose 4 elements are equal to one. - public static Vector4I One => new(Scalar.One); + public static Vector4I One => new(T.One); /// Returns a vector whose 4 elements are equal to zero. public static Vector4I Zero => default; /// Gets the vector (1, 0, 0, 0). - public static Vector4I UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero, Scalar.Zero); + public static Vector4I UnitX => new(T.One, T.Zero, T.Zero, T.Zero); /// Gets the vector (0, 1, 0, 0). - public static Vector4I UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero, Scalar.Zero); + public static Vector4I UnitY => new(T.Zero, T.One, T.Zero, T.Zero); /// Gets the vector (0, 0, 1, 0). - public static Vector4I UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One, Scalar.Zero); + public static Vector4I UnitZ => new(T.Zero, T.Zero, T.One, T.Zero); /// Gets the vector (0, 0, 0, 1). - public static Vector4I UnitW => new(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); + public static Vector4I UnitW => new(T.Zero, T.Zero, T.Zero, T.One); /// Gets a vector with all bits set for each component. public static Vector4I AllBitsSet => new Vector4I(T.AllBitsSet, T.AllBitsSet, T.AllBitsSet, T.AllBitsSet); @@ -379,44 +379,65 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm /// public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); + /// Desconstructs a vector into its components. + /// The X component. + /// The Y component. + /// The Z component. + /// The W component. + public void Deconstruct(out T x, out T y, out T z, out T w) + { + x = X; + y = Y; + z = Z; + w = W; + } + + /// Implicitly casts a to a . + public static implicit operator Vector4I((T X, T Y, T Z, T W) v) => + new(v.X, v.Y, v.Z, v.W); + + /// Implicitly casts a to a . + public static implicit operator (T X, T Y, T Z, T W)(Vector4I v) => + (v.X, v.Y, v.Z, v.W); + public static Vector4I operator +(Vector4I vector) => vector; public static Vector4I operator -(Vector4I vector) => - new Vector4I(-vector.X, -vector.Y, -vector.Z, -vector.W); + new(-vector.X, -vector.Y, -vector.Z, -vector.W); public static Vector4I operator +(Vector4I left, Vector4I right) => - new Vector4I(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); + new(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); public static Vector4I operator -(Vector4I left, Vector4I right) => - new Vector4I(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); + new(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); public static Vector4I operator *(Vector4I left, Vector4I right) => - new Vector4I(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W); + new(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W); public static Vector4I operator /(Vector4I left, Vector4I right) => - new Vector4I(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W); + new(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W); public static Vector4I operator %(Vector4I left, Vector4I right) => - new Vector4I(left.X % right.X, left.Y % right.Y, left.Z % right.Z, left.W % right.W); + new(left.X % right.X, left.Y % right.Y, left.Z % right.Z, left.W % right.W); public static Vector4I operator +(Vector4I vector, T scalar) => - new Vector4I(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar); + new(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar); public static Vector4I operator -(Vector4I vector, T scalar) => - new Vector4I(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar); + new(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar); public static Vector4I operator *(Vector4I vector, T scalar) => - new Vector4I(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar); + new(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar); public static Vector4I operator *(T scalar, Vector4I vector) => - new Vector4I(scalar * vector.X, scalar * vector.Y, scalar * vector.Z, scalar * vector.W); + new(scalar * vector.X, scalar * vector.Y, scalar * vector.Z, scalar * vector.W); public static Vector4I operator /(Vector4I vector, T scalar) => - new Vector4I(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); + new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); public static Vector4I operator %(Vector4I vector, T scalar) => - new Vector4I(vector.X % scalar, vector.Y % scalar, vector.Z % scalar, vector.W % scalar); + new(vector.X % scalar, vector.Y % scalar, vector.Z % scalar, vector.W % scalar); public static Vector4I operator ~(Vector4I vector) => new Vector4I(~vector.X, ~vector.Y, ~vector.Z, ~vector.W); @@ -464,56 +485,136 @@ public static Vector4I Reflect(Vector4I vector, Vector4I normal) return vector - (normal * (dot + dot)); } - public static Vector4I Log(this Vector4I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z), TSelf.Log(x.W)); - - public static Vector4I Log(this Vector4I x, Vector4I newBase) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z), TSelf.Log(x.W, newBase.W)); - - public static Vector4I LogP1(this Vector4I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z), TSelf.LogP1(x.W)); - - public static Vector4I Log2(this Vector4I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z), TSelf.Log2(x.W)); - - public static Vector4I Log2P1(this Vector4I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z), TSelf.Log2P1(x.W)); - - public static Vector4I Log10(this Vector4I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z), TSelf.Log10(x.W)); - - public static Vector4I Log10P1(this Vector4I x) - where TSelf : IBinaryInteger, ILogarithmicFunctions => - new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z), TSelf.Log10P1(x.W)); - - public static Vector4I Exp(this Vector4I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z), TSelf.Exp(x.W)); - - public static Vector4I ExpM1(this Vector4I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z), TSelf.ExpM1(x.W)); - - public static Vector4I Exp2(this Vector4I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z), TSelf.Exp2(x.W)); - - public static Vector4I Exp2M1(this Vector4I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z), TSelf.Exp2M1(x.W)); - - public static Vector4I Exp10(this Vector4I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z), TSelf.Exp10(x.W)); - - public static Vector4I Exp10M1(this Vector4I x) - where TSelf : IBinaryInteger, IExponentialFunctions => - new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z), TSelf.Exp10M1(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4I Sign(this Vector4I value) + where TSelf : IBinaryInteger => + new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z), TSelf.Sign(value.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4I Max(this Vector4I x, Vector4I y) + where TSelf : IBinaryInteger => + new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z), TSelf.Max(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4I Max(this Vector4I x, TSelf y) + where TSelf : IBinaryInteger => + new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y), TSelf.Max(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4I MaxNumber(this Vector4I x, Vector4I y) + where TSelf : IBinaryInteger => + new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z), TSelf.MaxNumber(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4I MaxNumber(this Vector4I x, TSelf y) + where TSelf : IBinaryInteger => + new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y), TSelf.MaxNumber(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4I Min(this Vector4I x, Vector4I y) + where TSelf : IBinaryInteger => + new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z), TSelf.Min(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4I Min(this Vector4I x, TSelf y) + where TSelf : IBinaryInteger => + new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y), TSelf.Min(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4I MinNumber(this Vector4I x, Vector4I y) + where TSelf : IBinaryInteger => + new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z), TSelf.MinNumber(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4I MinNumber(this Vector4I x, TSelf y) + where TSelf : IBinaryInteger => + new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y), TSelf.MinNumber(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4I Clamp(this Vector4I value, Vector4I min, Vector4I max) + where TSelf : IBinaryInteger => + new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z), TSelf.Clamp(value.W, min.W, max.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector4I Clamp(this Vector4I value, TSelf min, TSelf max) + where TSelf : IBinaryInteger => + new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max), TSelf.Clamp(value.W, min, max)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4I CopySign(this Vector4I value, Vector4I sign) + where TSelf : IBinaryInteger => + new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z), TSelf.CopySign(value.W, sign.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4I CopySign(this Vector4I value, TSelf sign) + where TSelf : IBinaryInteger => + new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign), TSelf.CopySign(value.W, sign)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4I Abs(this Vector4I value) + where TSelf : IBinaryInteger => + new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z), TSelf.Abs(value.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4I MaxMagnitude(this Vector4I x, Vector4I y) + where TSelf : IBinaryInteger => + new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z), TSelf.MaxMagnitude(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4I MaxMagnitudeNumber(this Vector4I x, Vector4I y) + where TSelf : IBinaryInteger => + new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z), TSelf.MaxMagnitudeNumber(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4I MinMagnitude(this Vector4I x, Vector4I y) + where TSelf : IBinaryInteger => + new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z), TSelf.MinMagnitude(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4I MinMagnitudeNumber(this Vector4I x, Vector4I y) + where TSelf : IBinaryInteger => + new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z), TSelf.MinMagnitudeNumber(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4I Log2(this Vector4I value) + where TSelf : IBinaryInteger => + new(TSelf.Log2(value.X), TSelf.Log2(value.Y), TSelf.Log2(value.Z), TSelf.Log2(value.W)); } } From 070c6f57e06d066169e8cf2701652febde62f44e Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Mon, 30 Jun 2025 16:56:01 -0700 Subject: [PATCH 35/67] Replace generated I/F types with D types. --- sources/Maths/Maths/Box3D.cs | 5 +- sources/Maths/Maths/Legacy/Vector2D.Ops.cs | 288 -------- sources/Maths/Maths/Legacy/Vector2D.cs | 356 ---------- sources/Maths/Maths/Legacy/Vector3D.Ops.cs | 299 --------- sources/Maths/Maths/Legacy/Vector3D.cs | 383 ----------- sources/Maths/Maths/Legacy/Vector4D.Ops.cs | 357 ---------- sources/Maths/Maths/Legacy/Vector4D.cs | 417 ------------ .../{Matrix2x2F.gen.cs => Matrix2X2.gen.cs} | 40 +- .../{Matrix2x3F.gen.cs => Matrix2X3.gen.cs} | 40 +- .../{Matrix2x4F.gen.cs => Matrix2X4.gen.cs} | 42 +- sources/Maths/Maths/Matrix2x2I.gen.cs | 122 ---- sources/Maths/Maths/Matrix2x3I.gen.cs | 134 ---- sources/Maths/Maths/Matrix2x4I.gen.cs | 152 ----- .../{Matrix3x2F.gen.cs => Matrix3X2.gen.cs} | 42 +- .../{Matrix3x3F.gen.cs => Matrix3X3.gen.cs} | 46 +- .../{Matrix3x4F.gen.cs => Matrix3X4.gen.cs} | 46 +- sources/Maths/Maths/Matrix3x2I.gen.cs | 144 ---- sources/Maths/Maths/Matrix3x3I.gen.cs | 171 ----- sources/Maths/Maths/Matrix3x4I.gen.cs | 187 ------ .../{Matrix4x2F.gen.cs => Matrix4X2.gen.cs} | 46 +- .../{Matrix4x3F.gen.cs => Matrix4X3.gen.cs} | 48 +- sources/Maths/Maths/Matrix4x2I.gen.cs | 173 ----- sources/Maths/Maths/Matrix4x3I.gen.cs | 198 ------ sources/Maths/Maths/Matrix4x4F.gen.cs | 240 ------- sources/Maths/Maths/Matrix4x4I.gen.cs | 231 ------- .../{Matrix5x4F.gen.cs => Matrix5X4.gen.cs} | 42 +- sources/Maths/Maths/Matrix5x4I.gen.cs | 206 ------ sources/Maths/Maths/Vector2D.cs | 78 +++ .../{Vector2F.gen.cs => Vector2D.gen.cs} | 429 ++++++------ sources/Maths/Maths/Vector2F.cs | 67 -- sources/Maths/Maths/Vector2I.cs | 40 -- sources/Maths/Maths/Vector2I.gen.cs | 542 --------------- .../Maths/Maths/{Vector3I.cs => Vector3D.cs} | 24 +- .../{Vector3F.gen.cs => Vector3D.gen.cs} | 435 ++++++------ sources/Maths/Maths/Vector3I.gen.cs | 581 ---------------- .../Maths/Maths/{Vector4I.cs => Vector4D.cs} | 16 +- .../{Vector4F.gen.cs => Vector4D.gen.cs} | 441 +++++++------ sources/Maths/Maths/Vector4I.gen.cs | 620 ------------------ 38 files changed, 966 insertions(+), 6762 deletions(-) delete mode 100644 sources/Maths/Maths/Legacy/Vector2D.Ops.cs delete mode 100644 sources/Maths/Maths/Legacy/Vector2D.cs delete mode 100644 sources/Maths/Maths/Legacy/Vector3D.Ops.cs delete mode 100644 sources/Maths/Maths/Legacy/Vector3D.cs delete mode 100644 sources/Maths/Maths/Legacy/Vector4D.Ops.cs delete mode 100644 sources/Maths/Maths/Legacy/Vector4D.cs rename sources/Maths/Maths/{Matrix2x2F.gen.cs => Matrix2X2.gen.cs} (77%) rename sources/Maths/Maths/{Matrix2x3F.gen.cs => Matrix2X3.gen.cs} (79%) rename sources/Maths/Maths/{Matrix2x4F.gen.cs => Matrix2X4.gen.cs} (81%) delete mode 100644 sources/Maths/Maths/Matrix2x2I.gen.cs delete mode 100644 sources/Maths/Maths/Matrix2x3I.gen.cs delete mode 100644 sources/Maths/Maths/Matrix2x4I.gen.cs rename sources/Maths/Maths/{Matrix3x2F.gen.cs => Matrix3X2.gen.cs} (79%) rename sources/Maths/Maths/{Matrix3x3F.gen.cs => Matrix3X3.gen.cs} (81%) rename sources/Maths/Maths/{Matrix3x4F.gen.cs => Matrix3X4.gen.cs} (83%) delete mode 100644 sources/Maths/Maths/Matrix3x2I.gen.cs delete mode 100644 sources/Maths/Maths/Matrix3x3I.gen.cs delete mode 100644 sources/Maths/Maths/Matrix3x4I.gen.cs rename sources/Maths/Maths/{Matrix4x2F.gen.cs => Matrix4X2.gen.cs} (81%) rename sources/Maths/Maths/{Matrix4x3F.gen.cs => Matrix4X3.gen.cs} (83%) delete mode 100644 sources/Maths/Maths/Matrix4x2I.gen.cs delete mode 100644 sources/Maths/Maths/Matrix4x3I.gen.cs delete mode 100644 sources/Maths/Maths/Matrix4x4F.gen.cs delete mode 100644 sources/Maths/Maths/Matrix4x4I.gen.cs rename sources/Maths/Maths/{Matrix5x4F.gen.cs => Matrix5X4.gen.cs} (86%) delete mode 100644 sources/Maths/Maths/Matrix5x4I.gen.cs create mode 100644 sources/Maths/Maths/Vector2D.cs rename sources/Maths/Maths/{Vector2F.gen.cs => Vector2D.gen.cs} (73%) delete mode 100644 sources/Maths/Maths/Vector2F.cs delete mode 100644 sources/Maths/Maths/Vector2I.cs delete mode 100644 sources/Maths/Maths/Vector2I.gen.cs rename sources/Maths/Maths/{Vector3I.cs => Vector3D.cs} (69%) rename sources/Maths/Maths/{Vector3F.gen.cs => Vector3D.gen.cs} (75%) delete mode 100644 sources/Maths/Maths/Vector3I.gen.cs rename sources/Maths/Maths/{Vector4I.cs => Vector4D.cs} (69%) rename sources/Maths/Maths/{Vector4F.gen.cs => Vector4D.gen.cs} (76%) delete mode 100644 sources/Maths/Maths/Vector4I.gen.cs diff --git a/sources/Maths/Maths/Box3D.cs b/sources/Maths/Maths/Box3D.cs index 36c4ab815c..48812a2039 100644 --- a/sources/Maths/Maths/Box3D.cs +++ b/sources/Maths/Maths/Box3D.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -157,7 +158,7 @@ public Box3D GetScaled(Vector3D scale, Vector3D anchor) /// The anchor. /// The calculated box. public Box3D GetScaled(Vector3D scale, Vector3D anchor) - where TScale : unmanaged, IFormattable, IEquatable, IComparable + where TScale : INumberBase { var convertedAnchor = anchor.As(); var min = (scale * (Min.As() - convertedAnchor)) + convertedAnchor; @@ -226,4 +227,4 @@ public Box3D As() where TOther : unmanaged, IFormattable, IEquat return new(Min.As(), Max.As()); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Legacy/Vector2D.Ops.cs b/sources/Maths/Maths/Legacy/Vector2D.Ops.cs deleted file mode 100644 index df68ebed3b..0000000000 --- a/sources/Maths/Maths/Legacy/Vector2D.Ops.cs +++ /dev/null @@ -1,288 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - /// - /// Methods for working with - /// - public static class Vector2D - { - /// Returns a vector whose elements are the absolute values of each of the specified vector's elements. - /// A vector. - /// The absolute value vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Abs(Vector2D value) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Abs(value.X), Scalar.Abs(value.Y)); - - /// Adds two vectors together. - /// The first vector to add. - /// The second vector to add. - /// The summed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Add(Vector2D left, Vector2D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Add(left.X, right.X), Scalar.Add(left.Y, right.Y)); - - /// Restricts a vector between a minimum and a maximum value. - /// The vector to restrict. - /// The minimum value. - /// The maximum value. - /// The restricted vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Clamp(Vector2D value1, Vector2D min, Vector2D max) - where T : unmanaged, IFormattable, IEquatable, IComparable - // We must follow HLSL behavior in the case user specified min value is bigger than max value. - => Min(Max(value1, min), max); - - /// Computes the Euclidean distance between the two given points. - /// The first point. - /// The second point. - /// The distance. - [MethodImpl((MethodImplOptions) 768)] - public static T Distance(Vector2D value1, Vector2D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => Scalar.Sqrt(DistanceSquared(value1, value2)); - - /// Returns the Euclidean distance squared between two specified points. - /// The first point. - /// The second point. - /// The distance squared. - [MethodImpl((MethodImplOptions) 768)] - public static T DistanceSquared(Vector2D value1, Vector2D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - var difference = value1 - value2; - return Dot(difference, difference); - } - - /// Divides the first vector by the second. - /// The first vector. - /// The second vector. - /// The vector resulting from the division. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Divide(Vector2D left, Vector2D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Divide(left.X, right.X), Scalar.Divide(left.Y, right.Y)); - - /// Divides the specified vector by a specified scalar value. - /// The vector. - /// The scalar value. - /// The vector that results from the division. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Divide(Vector2D left, T divisor) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Divide(left.X, divisor), Scalar.Divide(left.Y, divisor)); - - /// Returns the dot product of two vectors. - /// The first vector. - /// The second vector. - /// The dot product. - [MethodImpl((MethodImplOptions) 768)] - public static T Dot(Vector2D value1, Vector2D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => Scalar.Add(Scalar.Multiply(value1.X, value2.X), Scalar.Multiply(value1.Y, value2.Y)); - - /// Linearly interpolates between two vectors based on the given weighting. - /// The first source vector. - /// The second source vector. - /// Value between 0 and 1 indicating the weight of the second source vector. - /// The interpolated vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Lerp(Vector2D value1, Vector2D value2, T amount) - where T : unmanaged, IFormattable, IEquatable, IComparable - => (value1 * Scalar.Subtract(Scalar.One, amount)) + (value2 * amount); - - /// Returns a vector whose elements are the maximum of each of the pairs of elements in the two source vectors - /// The first source vector - /// The second source vector - /// The maximized vector - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Max(Vector2D value1, Vector2D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Max(value1.X, value2.X), Scalar.Max(value1.Y, value2.Y)); - - /// Returns a vector whose elements are the minimum of each of the pairs of elements in the two source vectors. - /// The first source vector. - /// The second source vector. - /// The minimized vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Min(Vector2D value1, Vector2D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Min(value1.X, value2.X), Scalar.Min(value1.Y, value2.Y)); - - /// Multiplies two vectors together. - /// The first source vector. - /// The second source vector. - /// The product vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Multiply(Vector2D left, Vector2D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Multiply(left.X, right.X), Scalar.Multiply(left.Y, right.Y)); - - /// Multiplies a vector by the given scalar. - /// The source vector. - /// The scalar value. - /// The scaled vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Multiply(Vector2D left, T right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Multiply(left.X, right), Scalar.Multiply(left.Y, right)); - - /// Multiplies a vector by the given scalar. - /// The scalar value. - /// The source vector. - /// The scaled vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Multiply(T left, Vector2D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Multiply(left, right.X), Scalar.Multiply(left, right.Y)); - - /// Negates a given vector. - /// The source vector. - /// The negated vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Negate(Vector2D value) - where T : unmanaged, IFormattable, IEquatable, IComparable - => -value; - - /// Returns a vector with the same direction as the given vector, but with a length of 1. - /// The vector to normalize. - /// The normalized vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Normalize(Vector2D value) - where T : unmanaged, IFormattable, IEquatable, IComparable - => value / value.Length; - - /// Returns the reflection of a vector off a surface that has the specified normal. - /// The source vector. - /// The normal of the surface being reflected off. - /// The reflected vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Reflect(Vector2D vector, Vector2D normal) - where T : unmanaged, IFormattable, IEquatable, IComparable - => vector - Scalar.Multiply(Scalar.Two, Dot(vector, normal)) * normal; - - /// Returns a vector whose elements are the square root of each of the source vector's elements. - /// The source vector. - /// The square root vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D SquareRoot(Vector2D value) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Sqrt(value.X), Scalar.Sqrt(value.Y)); - - /// Subtracts the second vector from the first. - /// The first source vector. - /// The second source vector. - /// The difference vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Subtract(Vector2D left, Vector2D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left - right; - - /// Transforms a vector by the given matrix. - /// The source vector. - /// The transformation matrix. - /// The transformed vector. - public static Vector2D Transform(Vector2D position, Matrix4X4 matrix) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M11), Scalar.Multiply(position.Y, matrix.M21)), matrix.M41), - Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M12), Scalar.Multiply(position.Y, matrix.M22)), matrix.M42) - ); - } - - /// Transforms a vector normal by the given matrix. - /// The source vector. - /// The transformation matrix. - /// The transformed vector. - public static Vector2D TransformNormal(Vector2D normal, Matrix4X4 matrix) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Scalar.Add(Scalar.Multiply(normal.X, matrix.M11), Scalar.Multiply(normal.Y, matrix.M21)), - Scalar.Add(Scalar.Multiply(normal.X, matrix.M12), Scalar.Multiply(normal.Y, matrix.M22))); - } - - /// Transforms a vector by the given Quaternion rotation value. - /// The source vector to be rotated. - /// The rotation to apply. - /// The transformed vector. - public static Vector2D Transform(Vector2D value, Legacy.Quaternion rotation) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - T x2 = Scalar.Add(rotation.X, rotation.X); - T y2 = Scalar.Add(rotation.Y, rotation.Y); - T z2 = Scalar.Add(rotation.Z, rotation.Z); - - T wz2 = Scalar.Multiply(rotation.W, z2); - T xx2 = Scalar.Multiply(rotation.X, x2); - T xy2 = Scalar.Multiply(rotation.X, y2); - T yy2 = Scalar.Multiply(rotation.Y, y2); - T zz2 = Scalar.Multiply(rotation.Z, z2); - - return new( - Scalar.Add(Scalar.Multiply(value.X, Scalar.Subtract(Scalar.Subtract(Scalar.One, yy2), zz2)), Scalar.Multiply(value.Y, Scalar.Subtract(xy2, wz2))), - Scalar.Add(Scalar.Multiply(value.X, Scalar.Add(xy2, wz2)), Scalar.Multiply(value.Y, Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), zz2))) - ); - } - - /// Transforms a vector by the given matrix. - /// The source vector. - /// The transformation matrix. - /// The transformed vector. - public static Vector2D Transform(Vector2D position, Matrix3X2 matrix) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M11), Scalar.Multiply(position.Y, matrix.M21)), matrix.M31), - Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M12), Scalar.Multiply(position.Y, matrix.M22)), matrix.M32) - ); - } - - /// Transforms a vector normal by the given matrix. - /// The source vector. - /// The transformation matrix. - /// The transformed vector. - public static Vector2D TransformNormal(Vector2D normal, Matrix3X2 matrix) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Scalar.Add(Scalar.Multiply(normal.X, matrix.M11), Scalar.Multiply(normal.Y, matrix.M21)), - Scalar.Add(Scalar.Multiply(normal.X, matrix.M12), Scalar.Multiply(normal.Y, matrix.M22)) - ); - } - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Multiply(Vector2D value1, Matrix2X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Multiply(Vector2D value1, Matrix2X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Multiply(Vector2D value1, Matrix2X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => value1 * value2; - } -} diff --git a/sources/Maths/Maths/Legacy/Vector2D.cs b/sources/Maths/Maths/Legacy/Vector2D.cs deleted file mode 100644 index cb5b5fabdb..0000000000 --- a/sources/Maths/Maths/Legacy/Vector2D.cs +++ /dev/null @@ -1,356 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Globalization; -using System.Runtime.CompilerServices; -using System.Runtime.Serialization; -using System.Text; - -namespace Silk.NET.Maths -{ - /// A structure encapsulating two values and provides hardware accelerated methods. - [Serializable] - [DataContract] - public struct Vector2D - : IEquatable>, IFormattable - where T : unmanaged, IFormattable, IEquatable, IComparable - { - /// The X component of the vector. - [DataMember] - public T X; - - /// The Y component of the vector. - [DataMember] - public T Y; - - /// Creates a new object whose two elements have the same value. - /// The value to assign to both elements. - public Vector2D(T value) => (X, Y) = (value, value); - - /// Creates a vector whose elements have the specified values. - /// The value to assign to the field. - /// The value to assign to the field. - public Vector2D(T x, T y) => (X, Y) = (x, y); - - /// Gets a vector whose 2 elements are equal to one. - public static Vector2D One => new(Scalar.One); - - /// Gets the vector (1,0). - public static Vector2D UnitX => new(Scalar.One, Scalar.Zero); - - /// Gets the vector (0,1). - public static Vector2D UnitY => new(Scalar.Zero, Scalar.One); - - /// Returns a vector whose 2 elements are equal to zero. - public static Vector2D Zero => default; - - /// - /// Indexer for the components of this vector. - /// - /// The component to select. Zero based. - public T this[int i] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 1 || i < 0) - ThrowHelper(); - } - - VerifyBounds(i); - return Unsafe.Add(ref X, i); - } - } - - /// Copies the elements of the vector to a specified array. - /// The destination array. - /// is null - /// The number of elements in the current instance is greater than in the array. - /// is multidimensional. - /// must have at least two elements. The method copies the vector's elements starting at index 0. - [MethodImpl((MethodImplOptions) 768)] - public readonly void CopyTo(T[]? array) => CopyTo(array, 0); - - /// Copies the elements of the vector to a specified array starting at a specified index position. - /// The destination array. - /// The index at which to copy the first element of the vector. - /// is null - /// The number of elements in the current instance is greater than in the array. - /// is less then zero. - /// is greater then or equal to the array length. - /// is multidimensional. - /// array must have a sufficient number of elements to accommodate the two vector elements. In other words, elements index and index + 1 must already exist in array. - [MethodImpl((MethodImplOptions) 768)] - public readonly void CopyTo(T[]? array, int index) - { - if (array is null) - { - throw new NullReferenceException("Object reference not set to an instance of an object."); - } - - if ((index < 0) || (index >= array.Length)) - { - throw new ArgumentOutOfRangeException(nameof(index), "Specified argument was out of the range of valid values."); - } - - if ((array.Length - index) < 2) - { - throw new ArgumentException("Value does not fall within the expected range."); - } - - array[index] = X; - array[index + 1] = Y; - } - - /// Returns a boolean indicating whether the given is equal to this instance. - /// The to compare this instance to. - /// True if the other is equal to this instance; False otherwise. - public readonly bool Equals(Vector2D other) => this == other; - - /// Returns a boolean indicating whether the given Object is equal to this instance. - /// The Object to compare against. - /// True if the Object is equal to this Vector2D; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) => (obj is Vector2D other) && Equals(other); - - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() => HashCode.Combine(X, Y); - - /// Returns the length of the vector. - /// The vector's length. - public T Length - { - [MethodImpl((MethodImplOptions) 768)] - get => Scalar.Sqrt(LengthSquared); - } - - /// Returns the length of the vector squared. This operation is cheaper than Length(). - /// The vector's length squared. - public readonly T LengthSquared - { - [MethodImpl((MethodImplOptions) 768)] - get => Vector2D.Dot(this, this); - } - - /// Adds two vectors together. - /// The first source vector. - /// The second source vector. - /// The summed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D operator +(Vector2D left, Vector2D right) - => new(Scalar.Add(left.X, right.X), Scalar.Add(left.Y, right.Y)); - - /// Divides the first vector by the second. - /// The first source vector. - /// The second source vector. - /// The vector resulting from the division. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D operator /(Vector2D left, Vector2D right) - => new(Scalar.Divide(left.X, right.X), Scalar.Divide(left.Y, right.Y)); - - /// Divides the vector by the given scalar. - /// The source vector. - /// The scalar value. - /// The result of the division. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D operator /(Vector2D value1, T value2) - => new(Scalar.Divide(value1.X, value2), Scalar.Divide(value1.Y, value2)); - - /// Returns a boolean indicating whether the two given vectors are equal. - /// The first vector to compare. - /// The second vector to compare. - /// True if the vectors are equal; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public static bool operator ==(Vector2D left, Vector2D right) - => Scalar.Equal(left.X, right.X) && Scalar.Equal(left.Y, right.Y); - - /// Returns a boolean indicating whether the two given vectors are not equal. - /// The first vector to compare. - /// The second vector to compare. - /// True if the vectors are not equal; False if they are equal. - [MethodImpl((MethodImplOptions) 768)] - public static bool operator !=(Vector2D left, Vector2D right) => !(left == right); - - /// Multiplies two vectors together. - /// The first source vector. - /// The second source vector. - /// The product vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D operator *(Vector2D left, Vector2D right) - => new(Scalar.Multiply(left.X, right.X), Scalar.Multiply(left.Y, right.Y)); - - /// Multiplies a vector by the given scalar. - /// The source vector. - /// The scalar value. - /// The scaled vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D operator *(Vector2D left, T right) - => new(Scalar.Multiply(left.X, right), Scalar.Multiply(left.Y, right)); - - /// Multiplies a vector by the given scalar. - /// The scalar value. - /// The source vector. - /// The scaled vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D operator *(T left, Vector2D right) => right * left; - - /// Subtracts the second vector from the first. - /// The first source vector. - /// The second source vector. - /// The difference vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D operator -(Vector2D left, Vector2D right) - => new(Scalar.Subtract(left.X, right.X), Scalar.Subtract(left.Y, right.Y)); - - /// Negates a given vector. - /// The source vector. - /// The negated vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D operator -(Vector2D value) => Zero - value; - - /// Returns a String representing this instance. - /// The string representation. - public override readonly string ToString() => ToString("G", CultureInfo.CurrentCulture); - - /// Returns a String representing this instance, using the specified format to format individual elements. - /// The format of individual elements. - /// The string representation. - public readonly string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture); - - /// Returns a String representing this instance, using the specified format to format individual elements and the given IFormatProvider. - /// The format of individual elements. - /// The format provider to use when formatting elements. - /// The string representation. - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - StringBuilder sb = new(); - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - sb.Append('<'); - sb.Append(X.ToString(format, formatProvider)); - sb.Append(separator); - sb.Append(' '); - sb.Append(Y.ToString(format, formatProvider)); - sb.Append('>'); - return sb.ToString(); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector2D(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector2D(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Converts a into - /// - /// The source vector - /// The vector - public static explicit operator System.Numerics.Vector2(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector2D(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector2D(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector2D(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector2D(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector2D(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector2D(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector2D(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector2D(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector2D(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector2D(Vector2D from) - => new(Scalar.As(from.X), Scalar.As(from.Y)); - - /// - /// Returns this vector casted to - /// - /// The type to cast to - /// The casted vector - public Vector2D As() where TOther : unmanaged, IFormattable, IEquatable, IComparable - { - return new(Scalar.As(X), Scalar.As(Y)); - } - } -} diff --git a/sources/Maths/Maths/Legacy/Vector3D.Ops.cs b/sources/Maths/Maths/Legacy/Vector3D.Ops.cs deleted file mode 100644 index 618c53b805..0000000000 --- a/sources/Maths/Maths/Legacy/Vector3D.Ops.cs +++ /dev/null @@ -1,299 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - /// - /// Methods for working with - /// - public static class Vector3D - { - - /// Returns a vector whose elements are the absolute values of each of the source vector's elements. - /// The source vector. - /// The absolute value vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Abs(Vector3D value) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Abs(value.X), Scalar.Abs(value.Y), Scalar.Abs(value.Z)); - - /// Adds two vectors together. - /// The first source vector. - /// The second source vector. - /// The summed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Add(Vector3D left, Vector3D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left + right; - - /// Restricts a vector between a min and max value. - /// The source vector. - /// The minimum value. - /// The maximum value. - /// The restricted vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Clamp(Vector3D value1, Vector3D min, Vector3D max) - where T : unmanaged, IFormattable, IEquatable, IComparable - // We must follow HLSL behavior in the case user specified min value is bigger than max value. - => Min(Max(value1, min), max); - - /// Computes the cross product of two vectors. - /// The first vector. - /// The second vector. - /// The cross product. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Cross(Vector3D vector1, Vector3D vector2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new( - Scalar.Subtract(Scalar.Multiply(vector1.Y, vector2.Z), - Scalar.Multiply(vector1.Z, vector2.Y)), - Scalar.Subtract(Scalar.Multiply(vector1.Z, vector2.X), - Scalar.Multiply(vector1.X, vector2.Z)), - Scalar.Subtract(Scalar.Multiply(vector1.X, vector2.Y), - Scalar.Multiply(vector1.Y, vector2.X))); - - /// Returns the Euclidean distance between the two given points. - /// The first point. - /// The second point. - /// The distance. - [MethodImpl((MethodImplOptions) 768)] - public static T Distance(Vector3D value1, Vector3D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => Scalar.Sqrt(DistanceSquared(value1, value2)); - - /// Returns the Euclidean distance squared between the two given points. - /// The first point. - /// The second point. - /// The distance squared. - [MethodImpl((MethodImplOptions) 768)] - public static T DistanceSquared(Vector3D value1, Vector3D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - var difference = value1 - value2; - return Dot(difference, difference); - } - - /// Divides the first vector by the second. - /// The first source vector. - /// The second source vector. - /// The vector resulting from the division. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Divide(Vector3D left, Vector3D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left / right; - - /// Divides the vector by the given scalar. - /// The source vector. - /// The scalar value. - /// The result of the division. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Divide(Vector3D left, T divisor) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left / divisor; - - /// Returns the dot product of two vectors. - /// The first vector. - /// The second vector. - /// The dot product. - [MethodImpl((MethodImplOptions) 768)] - public static T Dot(Vector3D vector1, Vector3D vector2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => Scalar.Add( - Scalar.Add(Scalar.Multiply(vector1.X, vector2.X), - Scalar.Multiply(vector1.Y, vector2.Y)), - Scalar.Multiply(vector1.Z, vector2.Z)); - - /// Linearly interpolates between two vectors based on the given weighting. - /// The first source vector. - /// The second source vector. - /// Value between 0 and 1 indicating the weight of the second source vector. - /// The interpolated vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Lerp(Vector3D value1, Vector3D value2, T amount) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return (value1 * Scalar.Subtract(Scalar.One, amount) + (value2 * amount)); - } - - /// Returns a vector whose elements are the maximum of each of the pairs of elements in the two source vectors. - /// The first source vector. - /// The second source vector. - /// The maximized vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Max(Vector3D value1, Vector3D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Max(value1.X, value2.X), Scalar.Max(value1.Y, value2.Y), - Scalar.Max(value1.Z, value2.Z)); - - /// Returns a vector whose elements are the minimum of each of the pairs of elements in the two source vectors. - /// The first source vector. - /// The second source vector. - /// The minimized vector. - public static Vector3D Min(Vector3D value1, Vector3D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Min(value1.X, value2.X), Scalar.Min(value1.Y, value2.Y), - Scalar.Min(value1.Z, value2.Z)); - - /// Multiplies two vectors together. - /// The first source vector. - /// The second source vector. - /// The product vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Multiply(Vector3D left, Vector3D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left * right; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Multiply(Vector3D value1, Matrix3X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Multiply(Vector3D value1, Matrix3X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Multiply(Vector3D value1, Matrix3X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => value1 * value2; - - /// Multiplies a vector by the given scalar. - /// The source vector. - /// The scalar value. - /// The scaled vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Multiply(Vector3D left, T right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left * right; - - /// Multiplies a vector by the given scalar. - /// The scalar value. - /// The source vector. - /// The scaled vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Multiply(T left, Vector3D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left * right; - - /// Negates a given vector. - /// The source vector. - /// The negated vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Negate(Vector3D value) - where T : unmanaged, IFormattable, IEquatable, IComparable - => -value; - - /// Returns a vector with the same direction as the given vector, but with a length of 1. - /// The vector to normalize. - /// The normalized vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Normalize(Vector3D value) - where T : unmanaged, IFormattable, IEquatable, IComparable - => value / value.Length; - - /// Returns the reflection of a vector off a surface that has the specified normal. - /// The source vector. - /// The normal of the surface being reflected off. - /// The reflected vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Reflect(Vector3D vector, Vector3D normal) - where T : unmanaged, IFormattable, IEquatable, IComparable - => vector - (Scalar.Multiply(Scalar.Two, Dot(vector, normal)) * normal); - - /// Returns a vector whose elements are the square root of each of the source vector's elements. - /// The source vector. - /// The square root vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D SquareRoot(Vector3D value) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Sqrt(value.X), Scalar.Sqrt(value.Y), Scalar.Sqrt(value.Z)); - - /// Subtracts the second vector from the first. - /// The first source vector. - /// The second source vector. - /// The difference vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Subtract(Vector3D left, Vector3D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left - right; - - - /// Transforms a vector by the given matrix. - /// The source vector. - /// The transformation matrix. - /// The transformed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Transform(Vector3D position, Matrix4X4 matrix) // TODO: Matrix4X3 - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M11), Scalar.Multiply(position.Y, matrix.M21)), Scalar.Multiply(position.Z, matrix.M31)), matrix.M41), - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M12), Scalar.Multiply(position.Y, matrix.M22)), Scalar.Multiply(position.Z, matrix.M32)), matrix.M42), - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M13), Scalar.Multiply(position.Y, matrix.M23)), Scalar.Multiply(position.Z, matrix.M33)), matrix.M43) - ); - } - - /// Transforms a vector by the given Quaternion rotation value. - /// The source vector to be rotated. - /// The rotation to apply. - /// The transformed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Transform(Vector3D value, Legacy.Quaternion rotation) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - T x2 = Scalar.Add(rotation.X, rotation.X); - T y2 = Scalar.Add(rotation.Y, rotation.Y); - T z2 = Scalar.Add(rotation.Z, rotation.Z); - - T wx2 = Scalar.Multiply(rotation.W, x2); - T wy2 = Scalar.Multiply(rotation.W, y2); - T wz2 = Scalar.Multiply(rotation.W, z2); - T xx2 = Scalar.Multiply(rotation.X, x2); - T xy2 = Scalar.Multiply(rotation.X, y2); - T xz2 = Scalar.Multiply(rotation.X, z2); - T yy2 = Scalar.Multiply(rotation.Y, y2); - T yz2 = Scalar.Multiply(rotation.Y, z2); - T zz2 = Scalar.Multiply(rotation.Z, z2); - - // TODO: Vectorize - return new( - Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, Scalar.Subtract(Scalar.Subtract(Scalar.One, yy2), zz2)), Scalar.Multiply(value.Y, Scalar.Subtract(xy2, wz2))), Scalar.Multiply(value.Z, Scalar.Add(xz2, wy2))), - Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, Scalar.Add(xy2, wz2)), Scalar.Multiply(value.Y, Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), zz2))), Scalar.Multiply(value.Z, Scalar.Subtract(yz2, wx2))), - Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, Scalar.Subtract(xz2, wy2)), Scalar.Multiply(value.Y, Scalar.Add(yz2, wx2))), Scalar.Multiply(value.Z, Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), yy2))) - ); - } - - - - /// Transforms a vector normal by the given matrix. - /// The source vector. - /// The transformation matrix. - /// The transformed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D TransformNormal(Vector3D normal, Matrix4X4 matrix) // TODO: Matrix3X3 - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Scalar.Add(Scalar.Add(Scalar.Multiply(normal.X, matrix.M11), Scalar.Multiply(normal.Y, matrix.M21)), Scalar.Multiply(normal.Z, matrix.M31)), - Scalar.Add(Scalar.Add(Scalar.Multiply(normal.X, matrix.M12), Scalar.Multiply(normal.Y, matrix.M22)), Scalar.Multiply(normal.Z, matrix.M32)), - Scalar.Add(Scalar.Add(Scalar.Multiply(normal.X, matrix.M13), Scalar.Multiply(normal.Y, matrix.M23)), Scalar.Multiply(normal.Z, matrix.M33)) - ); - } - } -} diff --git a/sources/Maths/Maths/Legacy/Vector3D.cs b/sources/Maths/Maths/Legacy/Vector3D.cs deleted file mode 100644 index 486057d3f7..0000000000 --- a/sources/Maths/Maths/Legacy/Vector3D.cs +++ /dev/null @@ -1,383 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Globalization; -using System.Runtime.CompilerServices; -using System.Runtime.Serialization; -using System.Text; - -namespace Silk.NET.Maths -{ - /// A structure encapsulating three values and provides hardware accelerated methods. - [Serializable] - [DataContract] - public struct Vector3D - : IEquatable>, IFormattable - where T : unmanaged, IFormattable, IEquatable, IComparable - { - /// The X component of the vector. - [DataMember] - public T X; - - /// The Y component of the vector. - [DataMember] - public T Y; - - /// The Z component of the vector. - [DataMember] - public T Z; - - /// Constructs a vector whose elements are all the single specified value. - /// The element to fill the vector with. - public Vector3D(T value) => (X, Y, Z) = (value, value, value); - - /// Constructs a from the given and a third value. - /// The Vector to extract X and Y components from. - /// The Z component. - public Vector3D(Vector2D value, T z) => (X, Y, Z) = (value.X, value.Y, z); - - /// Constructs a vector with the given individual elements. - /// The X component. - /// The Y component. - /// The Z component. - public Vector3D(T x, T y, T z) => (X, Y, Z) = (x, y, z); - - /// Returns the vector (0,0,0). - public static Vector3D Zero => default; - - /// Returns the vector (1,1,1). - public static Vector3D One => new(Scalar.One); - - /// Returns the vector (1,0,0). - public static Vector3D UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero); - - /// Returns the vector (0,1,0). - public static Vector3D UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero); - - /// Returns the vector (0,0,1). - public static Vector3D UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One); - - /// - /// Indexer for the components of this vector. - /// - /// The component to select. Zero based. - public T this[int i] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 2 || i < 0) - ThrowHelper(); - } - - VerifyBounds(i); - return Unsafe.Add(ref X, i); - } - } - - /// Adds two vectors together. - /// The first source vector. - /// The second source vector. - /// The summed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D operator +(Vector3D left, Vector3D right) - => new(Scalar.Add(left.X, right.X), Scalar.Add(left.Y, right.Y), Scalar.Add(left.Z, right.Z)); - - /// Divides the first vector by the second. - /// The first source vector. - /// The second source vector. - /// The vector resulting from the division. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D operator /(Vector3D left, Vector3D right) - => new(Scalar.Divide(left.X, right.X), Scalar.Divide(left.Y, right.Y), - Scalar.Divide(left.Z, right.Z)); - - /// Divides the vector by the given scalar. - /// The source vector. - /// The scalar value. - /// The result of the division. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D operator /(Vector3D value1, T value2) - => new(Scalar.Divide(value1.X, value2), Scalar.Divide(value1.Y, value2), - Scalar.Divide(value1.Z, value2)); - - /// Returns a boolean indicating whether the two given vectors are equal. - /// The first vector to compare. - /// The second vector to compare. - /// True if the vectors are equal; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public static bool operator ==(Vector3D left, Vector3D right) - => Scalar.Equal(left.X, right.X) - && Scalar.Equal(left.Y, right.Y) - && Scalar.Equal(left.Z, right.Z); - - /// Returns a boolean indicating whether the two given vectors are not equal. - /// The first vector to compare. - /// The second vector to compare. - /// True if the vectors are not equal; False if they are equal. - [MethodImpl((MethodImplOptions) 768)] - public static bool operator !=(Vector3D left, Vector3D right) => !(left == right); - - /// Multiplies two vectors together. - /// The first source vector. - /// The second source vector. - /// The product vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D operator *(Vector3D left, Vector3D right) - => new(Scalar.Multiply(left.X, right.X), Scalar.Multiply(left.Y, right.Y), - Scalar.Multiply(left.Z, right.Z)); - - /// Multiplies a vector by the given scalar. - /// The source vector. - /// The scalar value. - /// The scaled vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D operator *(Vector3D left, T right) - => new(Scalar.Multiply(left.X, right), Scalar.Multiply(left.Y, right), - Scalar.Multiply(left.Z, right)); - - /// Multiplies a vector by the given scalar. - /// The scalar value. - /// The source vector. - /// The scaled vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D operator *(T left, Vector3D right) - => right * left; - - /// Subtracts the second vector from the first. - /// The first source vector. - /// The second source vector. - /// The difference vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D operator -(Vector3D left, Vector3D right) - => new(Scalar.Subtract(left.X, right.X), Scalar.Subtract(left.Y, right.Y), - Scalar.Subtract(left.Z, right.Z)); - - /// Negates a given vector. - /// The source vector. - /// The negated vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D operator -(Vector3D value) - => Zero - value; - - /// Copies the contents of the vector into the given array. - [MethodImpl((MethodImplOptions) 768)] - public readonly void CopyTo(T[]? array) - => CopyTo(array, 0); - - /// Copies the contents of the vector into the given array, starting from index. - /// If array is null. - /// If array is multidimensional. - /// If index is greater than end of the array or index is less than zero. - /// If number of elements in source vector is greater than those available in destination array. - [MethodImpl((MethodImplOptions) 768)] - public readonly void CopyTo(T[]? array, int index) - { - if (array is null) - { - throw new NullReferenceException("Object reference not set to an instance of an object."); - } - - if ((index < 0) || (index >= array.Length)) - { - throw new ArgumentOutOfRangeException(nameof(index), "Specified argument was out of the range of valid values."); - } - - if ((array.Length - index) < 3) - { - throw new ArgumentException("Value does not fall within the expected range."); - } - - array[index] = X; - array[index + 1] = Y; - array[index + 2] = Z; - } - - /// Returns a boolean indicating whether the given Object is equal to this instance. - /// The Object to compare against. - /// True if the Object is equal to this Vector3D; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) - { - return (obj is Vector3D other) && Equals(other); - } - - /// Returns a boolean indicating whether the given is equal to this instance. - /// The to compare this instance to. - /// True if the other is equal to this instance; False otherwise. - public readonly bool Equals(Vector3D other) - { - return this == other; - } - - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - return HashCode.Combine(X, Y, Z); - } - - /// Returns the length of the vector. - /// The vector's length. - public T Length - { - [MethodImpl((MethodImplOptions) 768)] - get => Scalar.Sqrt(LengthSquared); - } - - /// Returns the length of the vector squared. This operation is cheaper than Length(). - /// The vector's length squared. - public T LengthSquared - { - [MethodImpl((MethodImplOptions) 768)] - get => Vector3D.Dot(this, this); - } - - /// Returns a String representing this instance. - /// The string representation. - public override readonly string ToString() => ToString("G", CultureInfo.CurrentCulture); - - /// Returns a String representing this instance, using the specified format to format individual elements. - /// The format of individual elements. - /// The string representation. - public readonly string ToString(string? format) => ToString(format, CultureInfo.CurrentCulture); - - /// Returns a String representing this instance, using the specified format to format individual elements and the given IFormatProvider. - /// The format of individual elements. - /// The format provider to use when formatting elements. - /// The string representation. - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - StringBuilder sb = new(); - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - sb.Append('<'); - sb.Append(X.ToString(format, formatProvider)); - sb.Append(separator); - sb.Append(' '); - sb.Append(Y.ToString(format, formatProvider)); - sb.Append(separator); - sb.Append(' '); - sb.Append(Z.ToString(format, formatProvider)); - sb.Append('>'); - return sb.ToString(); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector3D(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector3D(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Converts a into - /// - /// The source vector - /// The vector - public static explicit operator System.Numerics.Vector3(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector3D(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector3D(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector3D(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector3D(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector3D(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector3D(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector3D(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector3D(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector3D(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector3D(Vector3D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z)); - - /// - /// Returns this vector casted to - /// - /// The type to cast to - /// The casted vector - public Vector3D As() where TOther : unmanaged, IFormattable, IEquatable, IComparable - { - return new(Scalar.As(X), Scalar.As(Y), Scalar.As(Z)); - } - } -} diff --git a/sources/Maths/Maths/Legacy/Vector4D.Ops.cs b/sources/Maths/Maths/Legacy/Vector4D.Ops.cs deleted file mode 100644 index b86726fc19..0000000000 --- a/sources/Maths/Maths/Legacy/Vector4D.Ops.cs +++ /dev/null @@ -1,357 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - /// - /// Methods for working with - /// - public static class Vector4D - { - /// Returns a vector whose elements are the absolute values of each of the source vector's elements. - /// The source vector. - /// The absolute value vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Abs(Vector4D value) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new( - Scalar.Abs(value.X), - Scalar.Abs(value.Y), - Scalar.Abs(value.Z), - Scalar.Abs(value.W) - ); - - /// Adds two vectors together. - /// The first source vector. - /// The second source vector. - /// The summed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Add(Vector4D left, Vector4D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left + right; - - /// Restricts a vector between a min and max value. - /// The source vector. - /// The minimum value. - /// The maximum value. - /// The restricted vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Clamp(Vector4D value1, Vector4D min, Vector4D max) - where T : unmanaged, IFormattable, IEquatable, IComparable - // We must follow HLSL behavior in the case user specified min value is bigger than max value. - => Min(Max(value1, min), max); - - /// Returns the Euclidean distance between the two given points. - /// The first point. - /// The second point. - /// The distance. - [MethodImpl((MethodImplOptions) 768)] - public static T Distance(Vector4D value1, Vector4D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => Scalar.Sqrt(DistanceSquared(value1, value2)); - - /// Returns the Euclidean distance squared between the two given points. - /// The first point. - /// The second point. - /// The distance squared. - [MethodImpl((MethodImplOptions) 768)] - public static T DistanceSquared(Vector4D value1, Vector4D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - var difference = value1 - value2; - return Dot(difference, difference); - } - - /// Divides the first vector by the second. - /// The first source vector. - /// The second source vector. - /// The vector resulting from the division. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Divide(Vector4D left, Vector4D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left / right; - - /// Divides the vector by the given scalar. - /// The source vector. - /// The scalar value. - /// The result of the division. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Divide(Vector4D left, T divisor) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left / divisor; - - /// Returns the dot product of two vectors. - /// The first vector. - /// The second vector. - /// The dot product. - [MethodImpl((MethodImplOptions) 768)] - public static T Dot(Vector4D vector1, Vector4D vector2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => Scalar.Add( - Scalar.Add( - Scalar.Add(Scalar.Multiply(vector1.X, vector2.X), - Scalar.Multiply(vector1.Y, vector2.Y)), Scalar.Multiply(vector1.Z, vector2.Z)), - Scalar.Multiply(vector1.W, vector2.W)); - - /// Linearly interpolates between two vectors based on the given weighting. - /// The first source vector. - /// The second source vector. - /// Value between 0 and 1 indicating the weight of the second source vector. - /// The interpolated vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Lerp(Vector4D value1, Vector4D value2, T amount) - where T : unmanaged, IFormattable, IEquatable, IComparable - => (value1 * Scalar.Subtract(Scalar.One, amount)) + (value2 * amount); - - /// Returns a vector whose elements are the maximum of each of the pairs of elements in the two source vectors. - /// The first source vector. - /// The second source vector. - /// The maximized vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Max(Vector4D value1, Vector4D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Max(value1.X, value2.X), Scalar.Max(value1.Y, value2.Y), - Scalar.Max(value1.Z, value2.Z), Scalar.Max(value1.W, value2.W)); - - /// Returns a vector whose elements are the minimum of each of the pairs of elements in the two source vectors. - /// The first source vector. - /// The second source vector. - /// The minimized vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Min(Vector4D value1, Vector4D value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => new(Scalar.Min(value1.X, value2.X), Scalar.Min(value1.Y, value2.Y), - Scalar.Min(value1.Z, value2.Z), Scalar.Min(value1.W, value2.W)); - - /// Multiplies two vectors together. - /// The first source vector. - /// The second source vector. - /// The product vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Multiply(Vector4D left, Vector4D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left * right; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Multiply(Vector4D value1, Matrix4X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Multiply(Vector4D value1, Matrix4X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Multiply(Vector4D value1, Matrix4X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable - => value1 * value2; - - /// Multiplies a vector by the given scalar. - /// The source vector. - /// The scalar value. - /// The scaled vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Multiply(Vector4D left, T right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left * right; - - /// Multiplies a vector by the given scalar. - /// The scalar value. - /// The source vector. - /// The scaled vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Multiply(T left, Vector4D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left * right; - - /// Negates a given vector. - /// The source vector. - /// The negated vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Negate(Vector4D value) - where T : unmanaged, IFormattable, IEquatable, IComparable - => -value; - - /// Returns a vector with the same direction as the given vector, but with a length of 1. - /// The vector to normalize. - /// The normalized vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Normalize(Vector4D vector) - where T : unmanaged, IFormattable, IEquatable, IComparable - => vector / vector.Length; - - /// Returns a vector whose elements are the square root of each of the source vector's elements. - /// The source vector. - /// The square root vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D SquareRoot(Vector4D value) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new(Scalar.Sqrt(value.X), Scalar.Sqrt(value.Y), Scalar.Sqrt(value.Z), - Scalar.Sqrt(value.W)); - } - - /// Subtracts the second vector from the first. - /// The first source vector. - /// The second source vector. - /// The difference vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Subtract(Vector4D left, Vector4D right) - where T : unmanaged, IFormattable, IEquatable, IComparable - => left - right; - - /// Transforms a vector by the given matrix. - /// The source vector. - /// The transformation matrix. - /// The transformed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Transform(Vector2D position, Matrix4X4 matrix) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M11), Scalar.Multiply(position.Y, matrix.M21)), matrix.M41), - Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M12), Scalar.Multiply(position.Y, matrix.M22)), matrix.M42), - Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M13), Scalar.Multiply(position.Y, matrix.M23)), matrix.M43), - Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M14), Scalar.Multiply(position.Y, matrix.M24)), matrix.M44) - ); - } - - /// Transforms a vector by the given Quaternion rotation value. - /// The source vector to be rotated. - /// The rotation to apply. - /// The transformed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Transform(Vector2D value, Silk.NET.Maths.Legacy.Quaternion rotation) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - T x2 = Scalar.Add(rotation.X, rotation.X); - T y2 = Scalar.Add(rotation.Y, rotation.Y); - T z2 = Scalar.Add(rotation.Z, rotation.Z); - - T wx2 = Scalar.Multiply(rotation.W, x2); - T wy2 = Scalar.Multiply(rotation.W, y2); - T wz2 = Scalar.Multiply(rotation.W, z2); - T xx2 = Scalar.Multiply(rotation.X, x2); - T xy2 = Scalar.Multiply(rotation.X, y2); - T xz2 = Scalar.Multiply(rotation.X, z2); - T yy2 = Scalar.Multiply(rotation.Y, y2); - T yz2 = Scalar.Multiply(rotation.Y, z2); - T zz2 = Scalar.Multiply(rotation.Z, z2); - - return new( - Scalar.Add(Scalar.Multiply(value.X, Scalar.Subtract(Scalar.Subtract(Scalar.One, yy2), zz2)), Scalar.Multiply(value.Y, Scalar.Subtract(xy2, wz2))), - Scalar.Add(Scalar.Multiply(value.X, Scalar.Add(xy2, wz2)), Scalar.Multiply(value.Y, Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), zz2))), - Scalar.Add(Scalar.Multiply(value.X, Scalar.Subtract(xz2, wy2)), Scalar.Multiply(value.Y, Scalar.Add(yz2, wx2))), - Scalar.One - ); - } - - /// Transforms a vector by the given matrix. - /// The source vector. - /// The transformation matrix. - /// The transformed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Transform(Vector3D position, Matrix4X4 matrix) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M11), Scalar.Multiply(position.Y, matrix.M21)), Scalar.Multiply(position.Z, matrix.M31)), matrix.M41), - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M12), Scalar.Multiply(position.Y, matrix.M22)), Scalar.Multiply(position.Z, matrix.M32)), matrix.M42), - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M13), Scalar.Multiply(position.Y, matrix.M23)), Scalar.Multiply(position.Z, matrix.M33)), matrix.M43), - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(position.X, matrix.M14), Scalar.Multiply(position.Y, matrix.M24)), Scalar.Multiply(position.Z, matrix.M34)), matrix.M44) - ); - } - - /// Transforms a vector by the given Quaternion rotation value. - /// The source vector to be rotated. - /// The rotation to apply. - /// The transformed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Transform(Vector3D value, Legacy.Quaternion rotation) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - T x2 = Scalar.Add(rotation.X, rotation.X); - T y2 = Scalar.Add(rotation.Y, rotation.Y); - T z2 = Scalar.Add(rotation.Z, rotation.Z); - - T wx2 = Scalar.Multiply(rotation.W, x2); - T wy2 = Scalar.Multiply(rotation.W, y2); - T wz2 = Scalar.Multiply(rotation.W, z2); - T xx2 = Scalar.Multiply(rotation.X, x2); - T xy2 = Scalar.Multiply(rotation.X, y2); - T xz2 = Scalar.Multiply(rotation.X, z2); - T yy2 = Scalar.Multiply(rotation.Y, y2); - T yz2 = Scalar.Multiply(rotation.Y, z2); - T zz2 = Scalar.Multiply(rotation.Z, z2); - - return new( - Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, Scalar.Subtract(Scalar.Subtract(Scalar.One, yy2), zz2)), Scalar.Multiply(value.Y, Scalar.Subtract(xy2, wz2))), Scalar.Multiply(value.Z, Scalar.Add(xz2, wy2))), - Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, Scalar.Add(xy2, wz2)), Scalar.Multiply(value.Y, Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), zz2))), Scalar.Multiply(value.Z, Scalar.Subtract(yz2, wx2))), - Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, Scalar.Subtract(xz2, wy2)), Scalar.Multiply(value.Y, Scalar.Add(yz2, wx2))), Scalar.Multiply(value.Z, Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), yy2))), - Scalar.One - ); - } - - /// Transforms a vector by the given matrix. - /// The source vector. - /// The transformation matrix. - /// The transformed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Transform(Vector4D vector, Matrix4X4 matrix) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(vector.X, matrix.M11), Scalar.Multiply(vector.Y, matrix.M21)), Scalar.Multiply(vector.Z, matrix.M31)), Scalar.Multiply(vector.W, matrix.M41)), - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(vector.X, matrix.M12), Scalar.Multiply(vector.Y, matrix.M22)), Scalar.Multiply(vector.Z, matrix.M32)), Scalar.Multiply(vector.W, matrix.M42)), - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(vector.X, matrix.M13), Scalar.Multiply(vector.Y, matrix.M23)), Scalar.Multiply(vector.Z, matrix.M33)), Scalar.Multiply(vector.W, matrix.M43)), - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(vector.X, matrix.M14), Scalar.Multiply(vector.Y, matrix.M24)), Scalar.Multiply(vector.Z, matrix.M34)), Scalar.Multiply(vector.W, matrix.M44)) - ); - } - - /// Transforms a vector by the given Quaternion rotation value. - /// The source vector to be rotated. - /// The rotation to apply. - /// The transformed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Transform(Vector4D value, Legacy.Quaternion rotation) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - T x2 = Scalar.Add(rotation.X, rotation.X); - T y2 = Scalar.Add(rotation.Y, rotation.Y); - T z2 = Scalar.Add(rotation.Z, rotation.Z); - - T wx2 = Scalar.Multiply(rotation.W, x2); - T wy2 = Scalar.Multiply(rotation.W, y2); - T wz2 = Scalar.Multiply(rotation.W, z2); - T xx2 = Scalar.Multiply(rotation.X, x2); - T xy2 = Scalar.Multiply(rotation.X, y2); - T xz2 = Scalar.Multiply(rotation.X, z2); - T yy2 = Scalar.Multiply(rotation.Y, y2); - T yz2 = Scalar.Multiply(rotation.Y, z2); - T zz2 = Scalar.Multiply(rotation.Z, z2); - - return new( - Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, Scalar.Subtract(Scalar.Subtract(Scalar.One, yy2), zz2)), Scalar.Multiply(value.Y, Scalar.Subtract(xy2, wz2))), Scalar.Multiply(value.Z, Scalar.Add(xz2, wy2))), - Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, Scalar.Add(xy2, wz2)), Scalar.Multiply(value.Y, Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), zz2))), Scalar.Multiply(value.Z, Scalar.Subtract(yz2, wx2))), - Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, Scalar.Subtract(xz2, wy2)), Scalar.Multiply(value.Y, Scalar.Add(yz2, wx2))), Scalar.Multiply(value.Z, Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), yy2))), - value.W - ); - } - } -} diff --git a/sources/Maths/Maths/Legacy/Vector4D.cs b/sources/Maths/Maths/Legacy/Vector4D.cs deleted file mode 100644 index 3722ecde42..0000000000 --- a/sources/Maths/Maths/Legacy/Vector4D.cs +++ /dev/null @@ -1,417 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Globalization; -using System.Runtime.CompilerServices; -using System.Runtime.Serialization; -using System.Text; - -namespace Silk.NET.Maths -{ - /// A structure encapsulating four single precision floating point values and provides hardware accelerated methods. - [Serializable] - [DataContract] - public struct Vector4D - : IEquatable>, IFormattable - where T : unmanaged, IFormattable, IEquatable, IComparable - { - /// The X component of the vector. - [DataMember] - public T X; - - /// The Y component of the vector. - [DataMember] - public T Y; - - /// The Z component of the vector. - [DataMember] - public T Z; - - /// The W component of the vector. - [DataMember] - public T W; - - /// - /// Indexer for the components of this vector. - /// - /// The component to select. Zero based. - public T this[int i] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 3 || i < 0) - ThrowHelper(); - } - - VerifyBounds(i); - return Unsafe.Add(ref X, i); - } - } - - /// Constructs a vector whose elements are all the single specified value. - /// The element to fill the vector with. - public Vector4D(T value) => (X, Y, Z, W) = (value, value, value, value); - - /// Constructs a from the given and a Z and W component. - /// The vector to use as the X and Y components. - /// The Z component. - /// The W component. - public Vector4D(Vector2D value, T z, T w) => (X, Y, Z, W) = (value.X, value.Y, z, w); - - /// Constructs a from the given and a W component. - /// The vector to use as the X, Y, and Z components. - /// The W component. - public Vector4D(Vector3D value, T w) => (X, Y, Z, W) = (value.X, value.Y, value.Z, w); - - /// Constructs a vector with the given individual elements. - /// W component. - /// X component. - /// Y component. - /// Z component. - public Vector4D(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); - - /// Returns the vector (0,0,0,0). - public static Vector4D Zero => default; - - /// Returns the vector (1,1,1,1). - public static Vector4D One => new(Scalar.One); - - /// Returns the vector (1,0,0,0). - public static Vector4D UnitX => new(Scalar.One, Scalar.Zero, Scalar.Zero, Scalar.Zero); - - /// Returns the vector (0,1,0,0). - public static Vector4D UnitY => new(Scalar.Zero, Scalar.One, Scalar.Zero, Scalar.Zero); - - /// Returns the vector (0,0,1,0). - public static Vector4D UnitZ => new(Scalar.Zero, Scalar.Zero, Scalar.One, Scalar.Zero); - - /// Returns the vector (0,0,0,1). - public static Vector4D UnitW => new(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); - - /// Adds two vectors together. - /// The first source vector. - /// The second source vector. - /// The summed vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D operator +(Vector4D left, Vector4D right) - => new(Scalar.Add(left.X, right.X), Scalar.Add(left.Y, right.Y), Scalar.Add(left.Z, right.Z), - Scalar.Add(left.W, right.W)); - - /// Divides the first vector by the second. - /// The first source vector. - /// The second source vector. - /// The vector resulting from the division. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D operator /(Vector4D left, Vector4D right) - => new(Scalar.Divide(left.X, right.X), Scalar.Divide(left.Y, right.Y), Scalar.Divide(left.Z, right.Z), - Scalar.Divide(left.W, right.W)); - - /// Divides the vector by the given scalar. - /// The source vector. - /// The scalar value. - /// The result of the division. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D operator /(Vector4D value1, T value2) - => new(Scalar.Divide(value1.X, value2), Scalar.Divide(value1.Y, value2), - Scalar.Divide(value1.Z, value2), Scalar.Divide(value1.W, value2)); - - /// Returns a boolean indicating whether the two given vectors are equal. - /// The first vector to compare. - /// The second vector to compare. - /// True if the vectors are equal; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public static bool operator ==(Vector4D left, Vector4D right) - => Scalar.Equal(left.X, right.X) - && Scalar.Equal(left.Y, right.Y) - && Scalar.Equal(left.Z, right.Z) - && Scalar.Equal(left.W, right.W); - - /// Returns a boolean indicating whether the two given vectors are not equal. - /// The first vector to compare. - /// The second vector to compare. - /// True if the vectors are not equal; False if they are equal. - [MethodImpl((MethodImplOptions) 768)] - public static bool operator !=(Vector4D left, Vector4D right) - => !(left == right); - - /// Multiplies two vectors together. - /// The first source vector. - /// The second source vector. - /// The product vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D operator *(Vector4D left, Vector4D right) - => new(Scalar.Multiply(left.X, right.X), Scalar.Multiply(left.Y, right.Y), - Scalar.Multiply(left.Z, right.Z), Scalar.Multiply(left.W, right.W)); - - /// Multiplies a vector by the given scalar. - /// The source vector. - /// The scalar value. - /// The scaled vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D operator *(Vector4D left, T right) - => new(Scalar.Multiply(left.X, right), Scalar.Multiply(left.Y, right), - Scalar.Multiply(left.Z, right), Scalar.Multiply(left.W, right)); - - /// Multiplies a vector by the given scalar. - /// The scalar value. - /// The source vector. - /// The scaled vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D operator *(T left, Vector4D right) - => right * left; - - /// Subtracts the second vector from the first. - /// The first source vector. - /// The second source vector. - /// The difference vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D operator -(Vector4D left, Vector4D right) - => new(Scalar.Subtract(left.X, right.X), Scalar.Subtract(left.Y, right.Y), - Scalar.Subtract(left.Z, right.Z), Scalar.Subtract(left.W, right.W)); - - /// Negates a given vector. - /// The source vector. - /// The negated vector. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D operator -(Vector4D value) => Zero - value; - - /// Copies the contents of the vector into the given array. - [MethodImpl((MethodImplOptions) 768)] - public readonly void CopyTo(T[]? array) - => CopyTo(array, 0); - - /// Copies the contents of the vector into the given array, starting from index. - /// If array is null. - /// If array is multidimensional. - /// If index is greater than end of the array or index is less than zero. - /// If number of elements in source vector is greater than those available in destination array. - [MethodImpl((MethodImplOptions) 768)] - public readonly void CopyTo(T[]? array, int index) - { - if (array is null) - { - throw new NullReferenceException("Object reference not set to an instance of an object."); - } - - if ((index < 0) || (index >= array.Length)) - { - throw new ArgumentOutOfRangeException(nameof(index), "Specified argument was out of the range of valid values."); - } - - if ((array.Length - index) < 4) - { - throw new ArgumentException("Value does not fall within the expected range."); - } - - array[index] = X; - array[index + 1] = Y; - array[index + 2] = Z; - array[index + 3] = W; - } - - /// Returns a boolean indicating whether the given is equal to this instance. - /// The to compare this instance to. - /// True if the other is equal to this instance; False otherwise. - public readonly bool Equals(Vector4D other) - => this == other; - - /// Returns a boolean indicating whether the given Object is equal to this instance. - /// The Object to compare against. - /// True if the Object is equal to this Vector4D; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) - => (obj is Vector4D other) && Equals(other); - - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - => HashCode.Combine(X, Y, Z, W); - - /// Returns the length of the vector. This operation is cheaper than Length(). - /// The vector's length. - public T Length - { - [MethodImpl((MethodImplOptions) 768)] - get => Scalar.Sqrt(LengthSquared); - } - - /// Returns the length of the vector squared. - /// The vector's length squared. - public T LengthSquared - { - [MethodImpl((MethodImplOptions) 768)] - get => Vector4D.Dot(this, this); - } - - /// Returns a String representing this instance. - /// The string representation. - public override readonly string ToString() - { - return ToString("G", CultureInfo.CurrentCulture); - } - - /// Returns a String representing this instance, using the specified format to format individual elements. - /// The format of individual elements. - /// The string representation. - public readonly string ToString(string? format) - { - return ToString(format, CultureInfo.CurrentCulture); - } - - /// Returns a String representing this instance, using the specified format to format individual elements - /// and the given IFormatProvider. - /// The format of individual elements. - /// The format provider to use when formatting elements. - /// The string representation. - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - StringBuilder sb = new(); - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - sb.Append('<'); - sb.Append(X.ToString(format, formatProvider)); - sb.Append(separator); - sb.Append(' '); - sb.Append(Y.ToString(format, formatProvider)); - sb.Append(separator); - sb.Append(' '); - sb.Append(Z.ToString(format, formatProvider)); - sb.Append(separator); - sb.Append(' '); - sb.Append(W.ToString(format, formatProvider)); - sb.Append('>'); - return sb.ToString(); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector4D(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector4D(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into - /// - /// The source vector - /// The vector - public static explicit operator System.Numerics.Vector4(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector4D(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector4D(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector4D(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector4D(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector4D(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector4D(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector4D(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector4D(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector4D(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Vector4D(Vector4D from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Returns this vector casted to - /// - /// The type to cast to - /// The casted vector - public Vector4D As() where TOther : unmanaged, IFormattable, IEquatable, IComparable - { - return new(Scalar.As(X), Scalar.As(Y), Scalar.As(Z), Scalar.As(W)); - } - } -} diff --git a/sources/Maths/Maths/Matrix2x2F.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs similarity index 77% rename from sources/Maths/Maths/Matrix2x2F.gen.cs rename to sources/Maths/Maths/Matrix2X2.gen.cs index 0d43a43ed1..fb351734b6 100644 --- a/sources/Maths/Maths/Matrix2x2F.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -3,28 +3,28 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix2x2F : - IEquatable> - where T : IFloatingPointIeee754 + public partial struct Matrix2X2 : + IEquatable> + where T : INumberBase { /// The multiplicative identity matrix of size 2x2. - public static readonly Matrix2x2F Identity = new( + public static readonly Matrix2X2 Identity = new( new(T.MultiplicativeIdentity, T.Zero), new(T.Zero, T.MultiplicativeIdentity)); /// The 1st row of the matrix represented as a vector. - public Vector2F Row1; + public Vector2D Row1; /// The 2nd row of the matrix represented as a vector. - public Vector2F Row2; + public Vector2D Row2; /// - /// Constructs a from the given rows. + /// Constructs a from the given rows. /// - public Matrix2x2F(Vector2F row1, Vector2F row2) => (Row1, Row2) = (row1, row2); + public Matrix2X2(Vector2D row1, Vector2D row2) => (Row1, Row2) = (row1, row2); [UnscopedRef] - public ref Vector2F this[int row] + public ref Vector2D this[int row] { get { @@ -60,16 +60,16 @@ public ref Vector2F this[int row] public ref T M22 => ref Row2.Y; /// - public override bool Equals(object? obj) => obj is Matrix2x2F other && Equals(other); + public override bool Equals(object? obj) => obj is Matrix2X2 other && Equals(other); /// - public bool Equals(Matrix2x2F other) => this == other; + public bool Equals(Matrix2X2 other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); /// Computes the transpose of the matrix. - public Matrix2x2F Transpose() => + public Matrix2X2 Transpose() => new(new(M11, M21), new(M12, M22)); @@ -77,7 +77,7 @@ public Matrix2x2F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix2x2F left, Matrix2x2F right) => + public static bool operator ==(Matrix2X2 left, Matrix2X2 right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; @@ -85,13 +85,13 @@ public Matrix2x2F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix2x2F left, Matrix2x2F right) => !(left == right); + public static bool operator !=(Matrix2X2 left, Matrix2X2 right) => !(left == right); /// Adds two matrices together. /// The first source matrix. /// The second source matrix. /// The result of the addition. - public static Matrix2x2F operator +(Matrix2x2F left, Matrix2x2F right) => + public static Matrix2X2 operator +(Matrix2X2 left, Matrix2X2 right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); @@ -99,14 +99,14 @@ public Matrix2x2F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the subtraction. - public static Matrix2x2F operator -(Matrix2x2F left, Matrix2x2F right) => + public static Matrix2X2 operator -(Matrix2X2 left, Matrix2X2 right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); /// Returns a new matrix with the negated elements of the given matrix. /// The source matrix. /// The negated matrix. - public static Matrix2x2F operator -(Matrix2x2F value) => + public static Matrix2X2 operator -(Matrix2X2 value) => new(-value.Row1, -value.Row2); @@ -114,14 +114,14 @@ public Matrix2x2F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix2x2F operator *(Matrix2x2F left, Matrix2x2F right) => + public static Matrix2X2 operator *(Matrix2X2 left, Matrix2X2 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); } - static partial class Matrix2x2F + public static partial class Matrix2X2 { - public static Matrix2x2F Lerp(Matrix2x2F value1, Matrix2x2F value2, T amount) + public static Matrix2X2 Lerp(Matrix2X2 value1, Matrix2X2 value2, T amount) where T : IFloatingPointIeee754 => new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount)), new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount))); diff --git a/sources/Maths/Maths/Matrix2x3F.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs similarity index 79% rename from sources/Maths/Maths/Matrix2x3F.gen.cs rename to sources/Maths/Maths/Matrix2X3.gen.cs index 9c946035c6..2039da3a7d 100644 --- a/sources/Maths/Maths/Matrix2x3F.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -3,23 +3,23 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix2x3F : - IEquatable> - where T : IFloatingPointIeee754 + public partial struct Matrix2X3 : + IEquatable> + where T : INumberBase { /// The 1st row of the matrix represented as a vector. - public Vector3F Row1; + public Vector3D Row1; /// The 2nd row of the matrix represented as a vector. - public Vector3F Row2; + public Vector3D Row2; /// - /// Constructs a from the given rows. + /// Constructs a from the given rows. /// - public Matrix2x3F(Vector3F row1, Vector3F row2) => (Row1, Row2) = (row1, row2); + public Matrix2X3(Vector3D row1, Vector3D row2) => (Row1, Row2) = (row1, row2); [UnscopedRef] - public ref Vector3F this[int row] + public ref Vector3D this[int row] { get { @@ -63,16 +63,16 @@ public ref Vector3F this[int row] public ref T M23 => ref Row2.Z; /// - public override bool Equals(object? obj) => obj is Matrix2x3F other && Equals(other); + public override bool Equals(object? obj) => obj is Matrix2X3 other && Equals(other); /// - public bool Equals(Matrix2x3F other) => this == other; + public bool Equals(Matrix2X3 other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); /// Computes the transpose of the matrix. - public Matrix3x2F Transpose() => + public Matrix3X2 Transpose() => new(new(M11, M21), new(M12, M22), new(M13, M23)); @@ -81,7 +81,7 @@ public Matrix3x2F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix2x3F left, Matrix2x3F right) => + public static bool operator ==(Matrix2X3 left, Matrix2X3 right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; @@ -89,13 +89,13 @@ public Matrix3x2F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix2x3F left, Matrix2x3F right) => !(left == right); + public static bool operator !=(Matrix2X3 left, Matrix2X3 right) => !(left == right); /// Adds two matrices together. /// The first source matrix. /// The second source matrix. /// The result of the addition. - public static Matrix2x3F operator +(Matrix2x3F left, Matrix2x3F right) => + public static Matrix2X3 operator +(Matrix2X3 left, Matrix2X3 right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); @@ -103,14 +103,14 @@ public Matrix3x2F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the subtraction. - public static Matrix2x3F operator -(Matrix2x3F left, Matrix2x3F right) => + public static Matrix2X3 operator -(Matrix2X3 left, Matrix2X3 right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); /// Returns a new matrix with the negated elements of the given matrix. /// The source matrix. /// The negated matrix. - public static Matrix2x3F operator -(Matrix2x3F value) => + public static Matrix2X3 operator -(Matrix2X3 value) => new(-value.Row1, -value.Row2); @@ -118,7 +118,7 @@ public Matrix3x2F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix2x3F operator *(Matrix2x2F left, Matrix2x3F right) => + public static Matrix2X3 operator *(Matrix2X2 left, Matrix2X3 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); @@ -126,14 +126,14 @@ public Matrix3x2F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix2x2F operator *(Matrix2x3F left, Matrix3x2F right) => + public static Matrix2X2 operator *(Matrix2X3 left, Matrix3X2 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); } - static partial class Matrix2x3F + public static partial class Matrix2X3 { - public static Matrix2x3F Lerp(Matrix2x3F value1, Matrix2x3F value2, T amount) + public static Matrix2X3 Lerp(Matrix2X3 value1, Matrix2X3 value2, T amount) where T : IFloatingPointIeee754 => new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount)), new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount))); diff --git a/sources/Maths/Maths/Matrix2x4F.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs similarity index 81% rename from sources/Maths/Maths/Matrix2x4F.gen.cs rename to sources/Maths/Maths/Matrix2X4.gen.cs index b4d4f8c6f0..10496deda3 100644 --- a/sources/Maths/Maths/Matrix2x4F.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -3,23 +3,23 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix2x4F : - IEquatable> - where T : IFloatingPointIeee754 + public partial struct Matrix2X4 : + IEquatable> + where T : INumberBase { /// The 1st row of the matrix represented as a vector. - public Vector4F Row1; + public Vector4D Row1; /// The 2nd row of the matrix represented as a vector. - public Vector4F Row2; + public Vector4D Row2; /// - /// Constructs a from the given rows. + /// Constructs a from the given rows. /// - public Matrix2x4F(Vector4F row1, Vector4F row2) => (Row1, Row2) = (row1, row2); + public Matrix2X4(Vector4D row1, Vector4D row2) => (Row1, Row2) = (row1, row2); [UnscopedRef] - public ref Vector4F this[int row] + public ref Vector4D this[int row] { get { @@ -71,16 +71,16 @@ public ref Vector4F this[int row] public ref T M24 => ref Row2.W; /// - public override bool Equals(object? obj) => obj is Matrix2x4F other && Equals(other); + public override bool Equals(object? obj) => obj is Matrix2X4 other && Equals(other); /// - public bool Equals(Matrix2x4F other) => this == other; + public bool Equals(Matrix2X4 other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); /// Computes the transpose of the matrix. - public Matrix4x2F Transpose() => + public Matrix4X2 Transpose() => new(new(M11, M21), new(M12, M22), new(M13, M23), @@ -90,7 +90,7 @@ public Matrix4x2F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix2x4F left, Matrix2x4F right) => + public static bool operator ==(Matrix2X4 left, Matrix2X4 right) => left.Row1 == right.Row1 && left.Row2 == right.Row2; @@ -98,13 +98,13 @@ public Matrix4x2F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix2x4F left, Matrix2x4F right) => !(left == right); + public static bool operator !=(Matrix2X4 left, Matrix2X4 right) => !(left == right); /// Adds two matrices together. /// The first source matrix. /// The second source matrix. /// The result of the addition. - public static Matrix2x4F operator +(Matrix2x4F left, Matrix2x4F right) => + public static Matrix2X4 operator +(Matrix2X4 left, Matrix2X4 right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2); @@ -112,14 +112,14 @@ public Matrix4x2F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the subtraction. - public static Matrix2x4F operator -(Matrix2x4F left, Matrix2x4F right) => + public static Matrix2X4 operator -(Matrix2X4 left, Matrix2X4 right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2); /// Returns a new matrix with the negated elements of the given matrix. /// The source matrix. /// The negated matrix. - public static Matrix2x4F operator -(Matrix2x4F value) => + public static Matrix2X4 operator -(Matrix2X4 value) => new(-value.Row1, -value.Row2); @@ -127,7 +127,7 @@ public Matrix4x2F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix2x4F operator *(Matrix2x2F left, Matrix2x4F right) => + public static Matrix2X4 operator *(Matrix2X2 left, Matrix2X4 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); @@ -135,7 +135,7 @@ public Matrix4x2F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix2x2F operator *(Matrix2x4F left, Matrix4x2F right) => + public static Matrix2X2 operator *(Matrix2X4 left, Matrix4X2 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); @@ -143,15 +143,15 @@ public Matrix4x2F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix3x4F operator *(Matrix3x2F left, Matrix2x4F right) => + public static Matrix3X4 operator *(Matrix3X2 left, Matrix2X4 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } - static partial class Matrix2x4F + public static partial class Matrix2X4 { - public static Matrix2x4F Lerp(Matrix2x4F value1, Matrix2x4F value2, T amount) + public static Matrix2X4 Lerp(Matrix2X4 value1, Matrix2X4 value2, T amount) where T : IFloatingPointIeee754 => new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount), T.Lerp(value1.M14, value2.M14, amount)), new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount), T.Lerp(value1.M24, value2.M24, amount))); diff --git a/sources/Maths/Maths/Matrix2x2I.gen.cs b/sources/Maths/Maths/Matrix2x2I.gen.cs deleted file mode 100644 index 662608b49d..0000000000 --- a/sources/Maths/Maths/Matrix2x2I.gen.cs +++ /dev/null @@ -1,122 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - - partial struct Matrix2x2I : - IEquatable> - where T : IBinaryInteger - { - /// The multiplicative identity matrix of size 2x2. - public static readonly Matrix2x2I Identity = new( - new(T.MultiplicativeIdentity, T.Zero), - new(T.Zero, T.MultiplicativeIdentity)); - - /// The 1st row of the matrix represented as a vector. - public Vector2I Row1; - - /// The 2nd row of the matrix represented as a vector. - public Vector2I Row2; - - /// - /// Constructs a from the given rows. - /// - public Matrix2x2I(Vector2I row1, Vector2I row2) => (Row1, Row2) = (row1, row2); - - [UnscopedRef] - public ref Vector2I this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - } - - throw new ArgumentOutOfRangeException(nameof(row)); - } - } - - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - - /// Gets the element in the 1st row and 1st column of the matrix. - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// - public override bool Equals(object? obj) => obj is Matrix2x2I other && Equals(other); - - /// - public bool Equals(Matrix2x2I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(Row1, Row2); - - /// Computes the transpose of the matrix. - public Matrix2x2I Transpose() => - new(new(M11, M21), - new(M12, M22)); - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix2x2I left, Matrix2x2I right) => - left.Row1 == right.Row1 && - left.Row2 == right.Row2; - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix2x2I left, Matrix2x2I right) => !(left == right); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix2x2I operator +(Matrix2x2I left, Matrix2x2I right) => - new(left.Row1 + right.Row1, - left.Row2 + right.Row2); - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix2x2I operator -(Matrix2x2I left, Matrix2x2I right) => - new(left.Row1 - right.Row1, - left.Row2 - right.Row2); - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix2x2I operator -(Matrix2x2I value) => - new(-value.Row1, - -value.Row2); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2x2I operator *(Matrix2x2I left, Matrix2x2I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2, - left.M21 * right.Row1 + left.M22 * right.Row2); - } - -} diff --git a/sources/Maths/Maths/Matrix2x3I.gen.cs b/sources/Maths/Maths/Matrix2x3I.gen.cs deleted file mode 100644 index 03431eaac6..0000000000 --- a/sources/Maths/Maths/Matrix2x3I.gen.cs +++ /dev/null @@ -1,134 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - - partial struct Matrix2x3I : - IEquatable> - where T : IBinaryInteger - { - /// The 1st row of the matrix represented as a vector. - public Vector3I Row1; - - /// The 2nd row of the matrix represented as a vector. - public Vector3I Row2; - - /// - /// Constructs a from the given rows. - /// - public Matrix2x3I(Vector3I row1, Vector3I row2) => (Row1, Row2) = (row1, row2); - - [UnscopedRef] - public ref Vector3I this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - } - - throw new ArgumentOutOfRangeException(nameof(row)); - } - } - - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - - /// Gets the element in the 1st row and 1st column of the matrix. - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 1st row and 3rd column of the matrix. - [UnscopedRef] - public ref T M13 => ref Row1.Z; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// Gets the element in the 2nd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M23 => ref Row2.Z; - - /// - public override bool Equals(object? obj) => obj is Matrix2x3I other && Equals(other); - - /// - public bool Equals(Matrix2x3I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(Row1, Row2); - - /// Computes the transpose of the matrix. - public Matrix3x2I Transpose() => - new(new(M11, M21), - new(M12, M22), - new(M13, M23)); - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix2x3I left, Matrix2x3I right) => - left.Row1 == right.Row1 && - left.Row2 == right.Row2; - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix2x3I left, Matrix2x3I right) => !(left == right); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix2x3I operator +(Matrix2x3I left, Matrix2x3I right) => - new(left.Row1 + right.Row1, - left.Row2 + right.Row2); - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix2x3I operator -(Matrix2x3I left, Matrix2x3I right) => - new(left.Row1 - right.Row1, - left.Row2 - right.Row2); - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix2x3I operator -(Matrix2x3I value) => - new(-value.Row1, - -value.Row2); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2x3I operator *(Matrix2x2I left, Matrix2x3I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2, - left.M21 * right.Row1 + left.M22 * right.Row2); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2x2I operator *(Matrix2x3I left, Matrix3x2I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); - } - -} diff --git a/sources/Maths/Maths/Matrix2x4I.gen.cs b/sources/Maths/Maths/Matrix2x4I.gen.cs deleted file mode 100644 index e116d0b528..0000000000 --- a/sources/Maths/Maths/Matrix2x4I.gen.cs +++ /dev/null @@ -1,152 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - - partial struct Matrix2x4I : - IEquatable> - where T : IBinaryInteger - { - /// The 1st row of the matrix represented as a vector. - public Vector4I Row1; - - /// The 2nd row of the matrix represented as a vector. - public Vector4I Row2; - - /// - /// Constructs a from the given rows. - /// - public Matrix2x4I(Vector4I row1, Vector4I row2) => (Row1, Row2) = (row1, row2); - - [UnscopedRef] - public ref Vector4I this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - } - - throw new ArgumentOutOfRangeException(nameof(row)); - } - } - - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - - /// Gets the element in the 1st row and 1st column of the matrix. - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 1st row and 3rd column of the matrix. - [UnscopedRef] - public ref T M13 => ref Row1.Z; - - /// Gets the element in the 1st row and 4th column of the matrix. - [UnscopedRef] - public ref T M14 => ref Row1.W; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// Gets the element in the 2nd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M23 => ref Row2.Z; - - /// Gets the element in the 2nd row and 4th column of the matrix. - [UnscopedRef] - public ref T M24 => ref Row2.W; - - /// - public override bool Equals(object? obj) => obj is Matrix2x4I other && Equals(other); - - /// - public bool Equals(Matrix2x4I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(Row1, Row2); - - /// Computes the transpose of the matrix. - public Matrix4x2I Transpose() => - new(new(M11, M21), - new(M12, M22), - new(M13, M23), - new(M14, M24)); - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix2x4I left, Matrix2x4I right) => - left.Row1 == right.Row1 && - left.Row2 == right.Row2; - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix2x4I left, Matrix2x4I right) => !(left == right); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix2x4I operator +(Matrix2x4I left, Matrix2x4I right) => - new(left.Row1 + right.Row1, - left.Row2 + right.Row2); - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix2x4I operator -(Matrix2x4I left, Matrix2x4I right) => - new(left.Row1 - right.Row1, - left.Row2 - right.Row2); - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix2x4I operator -(Matrix2x4I value) => - new(-value.Row1, - -value.Row2); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2x4I operator *(Matrix2x2I left, Matrix2x4I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2, - left.M21 * right.Row1 + left.M22 * right.Row2); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2x2I operator *(Matrix2x4I left, Matrix4x2I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3x4I operator *(Matrix3x2I left, Matrix2x4I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2, - left.M21 * right.Row1 + left.M22 * right.Row2, - left.M31 * right.Row1 + left.M32 * right.Row2); - } - -} diff --git a/sources/Maths/Maths/Matrix3x2F.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs similarity index 79% rename from sources/Maths/Maths/Matrix3x2F.gen.cs rename to sources/Maths/Maths/Matrix3X2.gen.cs index fa7209a596..bde0ebf4e0 100644 --- a/sources/Maths/Maths/Matrix3x2F.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -3,26 +3,26 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix3x2F : - IEquatable> - where T : IFloatingPointIeee754 + public partial struct Matrix3X2 : + IEquatable> + where T : INumberBase { /// The 1st row of the matrix represented as a vector. - public Vector2F Row1; + public Vector2D Row1; /// The 2nd row of the matrix represented as a vector. - public Vector2F Row2; + public Vector2D Row2; /// The 3rd row of the matrix represented as a vector. - public Vector2F Row3; + public Vector2D Row3; /// - /// Constructs a from the given rows. + /// Constructs a from the given rows. /// - public Matrix3x2F(Vector2F row1, Vector2F row2, Vector2F row3) => (Row1, Row2, Row3) = (row1, row2, row3); + public Matrix3X2(Vector2D row1, Vector2D row2, Vector2D row3) => (Row1, Row2, Row3) = (row1, row2, row3); [UnscopedRef] - public ref Vector2F this[int row] + public ref Vector2D this[int row] { get { @@ -68,16 +68,16 @@ public ref Vector2F this[int row] public ref T M32 => ref Row3.Y; /// - public override bool Equals(object? obj) => obj is Matrix3x2F other && Equals(other); + public override bool Equals(object? obj) => obj is Matrix3X2 other && Equals(other); /// - public bool Equals(Matrix3x2F other) => this == other; + public bool Equals(Matrix3X2 other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); /// Computes the transpose of the matrix. - public Matrix2x3F Transpose() => + public Matrix2X3 Transpose() => new(new(M11, M21, M31), new(M12, M22, M32)); @@ -85,7 +85,7 @@ public Matrix2x3F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix3x2F left, Matrix3x2F right) => + public static bool operator ==(Matrix3X2 left, Matrix3X2 right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; @@ -94,13 +94,13 @@ public Matrix2x3F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix3x2F left, Matrix3x2F right) => !(left == right); + public static bool operator !=(Matrix3X2 left, Matrix3X2 right) => !(left == right); /// Adds two matrices together. /// The first source matrix. /// The second source matrix. /// The result of the addition. - public static Matrix3x2F operator +(Matrix3x2F left, Matrix3x2F right) => + public static Matrix3X2 operator +(Matrix3X2 left, Matrix3X2 right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); @@ -109,7 +109,7 @@ public Matrix2x3F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the subtraction. - public static Matrix3x2F operator -(Matrix3x2F left, Matrix3x2F right) => + public static Matrix3X2 operator -(Matrix3X2 left, Matrix3X2 right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); @@ -117,7 +117,7 @@ public Matrix2x3F Transpose() => /// Returns a new matrix with the negated elements of the given matrix. /// The source matrix. /// The negated matrix. - public static Matrix3x2F operator -(Matrix3x2F value) => + public static Matrix3X2 operator -(Matrix3X2 value) => new(-value.Row1, -value.Row2, -value.Row3); @@ -126,7 +126,7 @@ public Matrix2x3F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix3x2F operator *(Matrix3x2F left, Matrix2x2F right) => + public static Matrix3X2 operator *(Matrix3X2 left, Matrix2X2 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); @@ -135,15 +135,15 @@ public Matrix2x3F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix3x3F operator *(Matrix3x2F left, Matrix2x3F right) => + public static Matrix3X3 operator *(Matrix3X2 left, Matrix2X3 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); } - static partial class Matrix3x2F + public static partial class Matrix3X2 { - public static Matrix3x2F Lerp(Matrix3x2F value1, Matrix3x2F value2, T amount) + public static Matrix3X2 Lerp(Matrix3X2 value1, Matrix3X2 value2, T amount) where T : IFloatingPointIeee754 => new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount)), new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount)), diff --git a/sources/Maths/Maths/Matrix3x3F.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs similarity index 81% rename from sources/Maths/Maths/Matrix3x3F.gen.cs rename to sources/Maths/Maths/Matrix3X3.gen.cs index 2c94325eb2..df79a5c810 100644 --- a/sources/Maths/Maths/Matrix3x3F.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -3,32 +3,32 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix3x3F : - IEquatable> - where T : IFloatingPointIeee754 + public partial struct Matrix3X3 : + IEquatable> + where T : INumberBase { /// The multiplicative identity matrix of size 3x3. - public static readonly Matrix3x3F Identity = new( + public static readonly Matrix3X3 Identity = new( new(T.MultiplicativeIdentity, T.Zero, T.Zero), new(T.Zero, T.MultiplicativeIdentity, T.Zero), new(T.Zero, T.Zero, T.MultiplicativeIdentity)); /// The 1st row of the matrix represented as a vector. - public Vector3F Row1; + public Vector3D Row1; /// The 2nd row of the matrix represented as a vector. - public Vector3F Row2; + public Vector3D Row2; /// The 3rd row of the matrix represented as a vector. - public Vector3F Row3; + public Vector3D Row3; /// - /// Constructs a from the given rows. + /// Constructs a from the given rows. /// - public Matrix3x3F(Vector3F row1, Vector3F row2, Vector3F row3) => (Row1, Row2, Row3) = (row1, row2, row3); + public Matrix3X3(Vector3D row1, Vector3D row2, Vector3D row3) => (Row1, Row2, Row3) = (row1, row2, row3); [UnscopedRef] - public ref Vector3F this[int row] + public ref Vector3D this[int row] { get { @@ -86,16 +86,16 @@ public ref Vector3F this[int row] public ref T M33 => ref Row3.Z; /// - public override bool Equals(object? obj) => obj is Matrix3x3F other && Equals(other); + public override bool Equals(object? obj) => obj is Matrix3X3 other && Equals(other); /// - public bool Equals(Matrix3x3F other) => this == other; + public bool Equals(Matrix3X3 other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); /// Computes the transpose of the matrix. - public Matrix3x3F Transpose() => + public Matrix3X3 Transpose() => new(new(M11, M21, M31), new(M12, M22, M32), new(M13, M23, M33)); @@ -104,7 +104,7 @@ public Matrix3x3F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix3x3F left, Matrix3x3F right) => + public static bool operator ==(Matrix3X3 left, Matrix3X3 right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; @@ -113,13 +113,13 @@ public Matrix3x3F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix3x3F left, Matrix3x3F right) => !(left == right); + public static bool operator !=(Matrix3X3 left, Matrix3X3 right) => !(left == right); /// Adds two matrices together. /// The first source matrix. /// The second source matrix. /// The result of the addition. - public static Matrix3x3F operator +(Matrix3x3F left, Matrix3x3F right) => + public static Matrix3X3 operator +(Matrix3X3 left, Matrix3X3 right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); @@ -128,7 +128,7 @@ public Matrix3x3F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the subtraction. - public static Matrix3x3F operator -(Matrix3x3F left, Matrix3x3F right) => + public static Matrix3X3 operator -(Matrix3X3 left, Matrix3X3 right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); @@ -136,7 +136,7 @@ public Matrix3x3F Transpose() => /// Returns a new matrix with the negated elements of the given matrix. /// The source matrix. /// The negated matrix. - public static Matrix3x3F operator -(Matrix3x3F value) => + public static Matrix3X3 operator -(Matrix3X3 value) => new(-value.Row1, -value.Row2, -value.Row3); @@ -145,7 +145,7 @@ public Matrix3x3F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix2x3F operator *(Matrix2x3F left, Matrix3x3F right) => + public static Matrix2X3 operator *(Matrix2X3 left, Matrix3X3 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); @@ -153,7 +153,7 @@ public Matrix3x3F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix3x2F operator *(Matrix3x3F left, Matrix3x2F right) => + public static Matrix3X2 operator *(Matrix3X3 left, Matrix3X2 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); @@ -162,15 +162,15 @@ public Matrix3x3F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix3x3F operator *(Matrix3x3F left, Matrix3x3F right) => + public static Matrix3X3 operator *(Matrix3X3 left, Matrix3X3 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); } - static partial class Matrix3x3F + public static partial class Matrix3X3 { - public static Matrix3x3F Lerp(Matrix3x3F value1, Matrix3x3F value2, T amount) + public static Matrix3X3 Lerp(Matrix3X3 value1, Matrix3X3 value2, T amount) where T : IFloatingPointIeee754 => new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount)), new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount)), diff --git a/sources/Maths/Maths/Matrix3x4F.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs similarity index 83% rename from sources/Maths/Maths/Matrix3x4F.gen.cs rename to sources/Maths/Maths/Matrix3X4.gen.cs index 45de27a659..72a40e990d 100644 --- a/sources/Maths/Maths/Matrix3x4F.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -3,26 +3,26 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix3x4F : - IEquatable> - where T : IFloatingPointIeee754 + public partial struct Matrix3X4 : + IEquatable> + where T : INumberBase { /// The 1st row of the matrix represented as a vector. - public Vector4F Row1; + public Vector4D Row1; /// The 2nd row of the matrix represented as a vector. - public Vector4F Row2; + public Vector4D Row2; /// The 3rd row of the matrix represented as a vector. - public Vector4F Row3; + public Vector4D Row3; /// - /// Constructs a from the given rows. + /// Constructs a from the given rows. /// - public Matrix3x4F(Vector4F row1, Vector4F row2, Vector4F row3) => (Row1, Row2, Row3) = (row1, row2, row3); + public Matrix3X4(Vector4D row1, Vector4D row2, Vector4D row3) => (Row1, Row2, Row3) = (row1, row2, row3); [UnscopedRef] - public ref Vector4F this[int row] + public ref Vector4D this[int row] { get { @@ -92,16 +92,16 @@ public ref Vector4F this[int row] public ref T M34 => ref Row3.W; /// - public override bool Equals(object? obj) => obj is Matrix3x4F other && Equals(other); + public override bool Equals(object? obj) => obj is Matrix3X4 other && Equals(other); /// - public bool Equals(Matrix3x4F other) => this == other; + public bool Equals(Matrix3X4 other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); /// Computes the transpose of the matrix. - public Matrix4x3F Transpose() => + public Matrix4X3 Transpose() => new(new(M11, M21, M31), new(M12, M22, M32), new(M13, M23, M33), @@ -111,7 +111,7 @@ public Matrix4x3F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix3x4F left, Matrix3x4F right) => + public static bool operator ==(Matrix3X4 left, Matrix3X4 right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3; @@ -120,13 +120,13 @@ public Matrix4x3F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix3x4F left, Matrix3x4F right) => !(left == right); + public static bool operator !=(Matrix3X4 left, Matrix3X4 right) => !(left == right); /// Adds two matrices together. /// The first source matrix. /// The second source matrix. /// The result of the addition. - public static Matrix3x4F operator +(Matrix3x4F left, Matrix3x4F right) => + public static Matrix3X4 operator +(Matrix3X4 left, Matrix3X4 right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3); @@ -135,7 +135,7 @@ public Matrix4x3F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the subtraction. - public static Matrix3x4F operator -(Matrix3x4F left, Matrix3x4F right) => + public static Matrix3X4 operator -(Matrix3X4 left, Matrix3X4 right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3); @@ -143,7 +143,7 @@ public Matrix4x3F Transpose() => /// Returns a new matrix with the negated elements of the given matrix. /// The source matrix. /// The negated matrix. - public static Matrix3x4F operator -(Matrix3x4F value) => + public static Matrix3X4 operator -(Matrix3X4 value) => new(-value.Row1, -value.Row2, -value.Row3); @@ -152,7 +152,7 @@ public Matrix4x3F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix2x4F operator *(Matrix2x3F left, Matrix3x4F right) => + public static Matrix2X4 operator *(Matrix2X3 left, Matrix3X4 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); @@ -160,7 +160,7 @@ public Matrix4x3F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix3x4F operator *(Matrix3x3F left, Matrix3x4F right) => + public static Matrix3X4 operator *(Matrix3X3 left, Matrix3X4 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); @@ -169,7 +169,7 @@ public Matrix4x3F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix3x2F operator *(Matrix3x4F left, Matrix4x2F right) => + public static Matrix3X2 operator *(Matrix3X4 left, Matrix4X2 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); @@ -178,15 +178,15 @@ public Matrix4x3F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix3x3F operator *(Matrix3x4F left, Matrix4x3F right) => + public static Matrix3X3 operator *(Matrix3X4 left, Matrix4X3 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); } - static partial class Matrix3x4F + public static partial class Matrix3X4 { - public static Matrix3x4F Lerp(Matrix3x4F value1, Matrix3x4F value2, T amount) + public static Matrix3X4 Lerp(Matrix3X4 value1, Matrix3X4 value2, T amount) where T : IFloatingPointIeee754 => new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount), T.Lerp(value1.M14, value2.M14, amount)), new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount), T.Lerp(value1.M24, value2.M24, amount)), diff --git a/sources/Maths/Maths/Matrix3x2I.gen.cs b/sources/Maths/Maths/Matrix3x2I.gen.cs deleted file mode 100644 index 868cfc9584..0000000000 --- a/sources/Maths/Maths/Matrix3x2I.gen.cs +++ /dev/null @@ -1,144 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - - partial struct Matrix3x2I : - IEquatable> - where T : IBinaryInteger - { - /// The 1st row of the matrix represented as a vector. - public Vector2I Row1; - - /// The 2nd row of the matrix represented as a vector. - public Vector2I Row2; - - /// The 3rd row of the matrix represented as a vector. - public Vector2I Row3; - - /// - /// Constructs a from the given rows. - /// - public Matrix3x2I(Vector2I row1, Vector2I row2, Vector2I row3) => (Row1, Row2, Row3) = (row1, row2, row3); - - [UnscopedRef] - public ref Vector2I this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - } - - throw new ArgumentOutOfRangeException(nameof(row)); - } - } - - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - - /// Gets the element in the 1st row and 1st column of the matrix. - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// Gets the element in the 3rd row and 1st column of the matrix. - [UnscopedRef] - public ref T M31 => ref Row3.X; - - /// Gets the element in the 3rd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M32 => ref Row3.Y; - - /// - public override bool Equals(object? obj) => obj is Matrix3x2I other && Equals(other); - - /// - public bool Equals(Matrix3x2I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); - - /// Computes the transpose of the matrix. - public Matrix2x3I Transpose() => - new(new(M11, M21, M31), - new(M12, M22, M32)); - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix3x2I left, Matrix3x2I right) => - left.Row1 == right.Row1 && - left.Row2 == right.Row2 && - left.Row3 == right.Row3; - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix3x2I left, Matrix3x2I right) => !(left == right); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix3x2I operator +(Matrix3x2I left, Matrix3x2I right) => - new(left.Row1 + right.Row1, - left.Row2 + right.Row2, - left.Row3 + right.Row3); - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix3x2I operator -(Matrix3x2I left, Matrix3x2I right) => - new(left.Row1 - right.Row1, - left.Row2 - right.Row2, - left.Row3 - right.Row3); - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix3x2I operator -(Matrix3x2I value) => - new(-value.Row1, - -value.Row2, - -value.Row3); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3x2I operator *(Matrix3x2I left, Matrix2x2I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2, - left.M21 * right.Row1 + left.M22 * right.Row2, - left.M31 * right.Row1 + left.M32 * right.Row2); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3x3I operator *(Matrix3x2I left, Matrix2x3I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2, - left.M21 * right.Row1 + left.M22 * right.Row2, - left.M31 * right.Row1 + left.M32 * right.Row2); - } - -} diff --git a/sources/Maths/Maths/Matrix3x3I.gen.cs b/sources/Maths/Maths/Matrix3x3I.gen.cs deleted file mode 100644 index 3cee1adfaf..0000000000 --- a/sources/Maths/Maths/Matrix3x3I.gen.cs +++ /dev/null @@ -1,171 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - - partial struct Matrix3x3I : - IEquatable> - where T : IBinaryInteger - { - /// The multiplicative identity matrix of size 3x3. - public static readonly Matrix3x3I Identity = new( - new(T.MultiplicativeIdentity, T.Zero, T.Zero), - new(T.Zero, T.MultiplicativeIdentity, T.Zero), - new(T.Zero, T.Zero, T.MultiplicativeIdentity)); - - /// The 1st row of the matrix represented as a vector. - public Vector3I Row1; - - /// The 2nd row of the matrix represented as a vector. - public Vector3I Row2; - - /// The 3rd row of the matrix represented as a vector. - public Vector3I Row3; - - /// - /// Constructs a from the given rows. - /// - public Matrix3x3I(Vector3I row1, Vector3I row2, Vector3I row3) => (Row1, Row2, Row3) = (row1, row2, row3); - - [UnscopedRef] - public ref Vector3I this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - } - - throw new ArgumentOutOfRangeException(nameof(row)); - } - } - - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - - /// Gets the element in the 1st row and 1st column of the matrix. - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 1st row and 3rd column of the matrix. - [UnscopedRef] - public ref T M13 => ref Row1.Z; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// Gets the element in the 2nd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M23 => ref Row2.Z; - - /// Gets the element in the 3rd row and 1st column of the matrix. - [UnscopedRef] - public ref T M31 => ref Row3.X; - - /// Gets the element in the 3rd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M32 => ref Row3.Y; - - /// Gets the element in the 3rd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M33 => ref Row3.Z; - - /// - public override bool Equals(object? obj) => obj is Matrix3x3I other && Equals(other); - - /// - public bool Equals(Matrix3x3I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); - - /// Computes the transpose of the matrix. - public Matrix3x3I Transpose() => - new(new(M11, M21, M31), - new(M12, M22, M32), - new(M13, M23, M33)); - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix3x3I left, Matrix3x3I right) => - left.Row1 == right.Row1 && - left.Row2 == right.Row2 && - left.Row3 == right.Row3; - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix3x3I left, Matrix3x3I right) => !(left == right); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix3x3I operator +(Matrix3x3I left, Matrix3x3I right) => - new(left.Row1 + right.Row1, - left.Row2 + right.Row2, - left.Row3 + right.Row3); - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix3x3I operator -(Matrix3x3I left, Matrix3x3I right) => - new(left.Row1 - right.Row1, - left.Row2 - right.Row2, - left.Row3 - right.Row3); - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix3x3I operator -(Matrix3x3I value) => - new(-value.Row1, - -value.Row2, - -value.Row3); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2x3I operator *(Matrix2x3I left, Matrix3x3I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3x2I operator *(Matrix3x3I left, Matrix3x2I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3x3I operator *(Matrix3x3I left, Matrix3x3I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); - } - -} diff --git a/sources/Maths/Maths/Matrix3x4I.gen.cs b/sources/Maths/Maths/Matrix3x4I.gen.cs deleted file mode 100644 index 83fba2ab2f..0000000000 --- a/sources/Maths/Maths/Matrix3x4I.gen.cs +++ /dev/null @@ -1,187 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - - partial struct Matrix3x4I : - IEquatable> - where T : IBinaryInteger - { - /// The 1st row of the matrix represented as a vector. - public Vector4I Row1; - - /// The 2nd row of the matrix represented as a vector. - public Vector4I Row2; - - /// The 3rd row of the matrix represented as a vector. - public Vector4I Row3; - - /// - /// Constructs a from the given rows. - /// - public Matrix3x4I(Vector4I row1, Vector4I row2, Vector4I row3) => (Row1, Row2, Row3) = (row1, row2, row3); - - [UnscopedRef] - public ref Vector4I this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - } - - throw new ArgumentOutOfRangeException(nameof(row)); - } - } - - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - - /// Gets the element in the 1st row and 1st column of the matrix. - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 1st row and 3rd column of the matrix. - [UnscopedRef] - public ref T M13 => ref Row1.Z; - - /// Gets the element in the 1st row and 4th column of the matrix. - [UnscopedRef] - public ref T M14 => ref Row1.W; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// Gets the element in the 2nd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M23 => ref Row2.Z; - - /// Gets the element in the 2nd row and 4th column of the matrix. - [UnscopedRef] - public ref T M24 => ref Row2.W; - - /// Gets the element in the 3rd row and 1st column of the matrix. - [UnscopedRef] - public ref T M31 => ref Row3.X; - - /// Gets the element in the 3rd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M32 => ref Row3.Y; - - /// Gets the element in the 3rd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M33 => ref Row3.Z; - - /// Gets the element in the 3rd row and 4th column of the matrix. - [UnscopedRef] - public ref T M34 => ref Row3.W; - - /// - public override bool Equals(object? obj) => obj is Matrix3x4I other && Equals(other); - - /// - public bool Equals(Matrix3x4I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); - - /// Computes the transpose of the matrix. - public Matrix4x3I Transpose() => - new(new(M11, M21, M31), - new(M12, M22, M32), - new(M13, M23, M33), - new(M14, M24, M34)); - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix3x4I left, Matrix3x4I right) => - left.Row1 == right.Row1 && - left.Row2 == right.Row2 && - left.Row3 == right.Row3; - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix3x4I left, Matrix3x4I right) => !(left == right); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix3x4I operator +(Matrix3x4I left, Matrix3x4I right) => - new(left.Row1 + right.Row1, - left.Row2 + right.Row2, - left.Row3 + right.Row3); - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix3x4I operator -(Matrix3x4I left, Matrix3x4I right) => - new(left.Row1 - right.Row1, - left.Row2 - right.Row2, - left.Row3 - right.Row3); - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix3x4I operator -(Matrix3x4I value) => - new(-value.Row1, - -value.Row2, - -value.Row3); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2x4I operator *(Matrix2x3I left, Matrix3x4I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3x4I operator *(Matrix3x3I left, Matrix3x4I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3x2I operator *(Matrix3x4I left, Matrix4x2I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3x3I operator *(Matrix3x4I left, Matrix4x3I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); - } - -} diff --git a/sources/Maths/Maths/Matrix4x2F.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs similarity index 81% rename from sources/Maths/Maths/Matrix4x2F.gen.cs rename to sources/Maths/Maths/Matrix4X2.gen.cs index b5d608a7e0..36b257c507 100644 --- a/sources/Maths/Maths/Matrix4x2F.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -3,29 +3,29 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix4x2F : - IEquatable> - where T : IFloatingPointIeee754 + public partial struct Matrix4X2 : + IEquatable> + where T : INumberBase { /// The 1st row of the matrix represented as a vector. - public Vector2F Row1; + public Vector2D Row1; /// The 2nd row of the matrix represented as a vector. - public Vector2F Row2; + public Vector2D Row2; /// The 3rd row of the matrix represented as a vector. - public Vector2F Row3; + public Vector2D Row3; /// The 4th row of the matrix represented as a vector. - public Vector2F Row4; + public Vector2D Row4; /// - /// Constructs a from the given rows. + /// Constructs a from the given rows. /// - public Matrix4x2F(Vector2F row1, Vector2F row2, Vector2F row3, Vector2F row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + public Matrix4X2(Vector2D row1, Vector2D row2, Vector2D row3, Vector2D row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); [UnscopedRef] - public ref Vector2F this[int row] + public ref Vector2D this[int row] { get { @@ -81,16 +81,16 @@ public ref Vector2F this[int row] public ref T M42 => ref Row4.Y; /// - public override bool Equals(object? obj) => obj is Matrix4x2F other && Equals(other); + public override bool Equals(object? obj) => obj is Matrix4X2 other && Equals(other); /// - public bool Equals(Matrix4x2F other) => this == other; + public bool Equals(Matrix4X2 other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); /// Computes the transpose of the matrix. - public Matrix2x4F Transpose() => + public Matrix2X4 Transpose() => new(new(M11, M21, M31, M41), new(M12, M22, M32, M42)); @@ -98,7 +98,7 @@ public Matrix2x4F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix4x2F left, Matrix4x2F right) => + public static bool operator ==(Matrix4X2 left, Matrix4X2 right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && @@ -108,13 +108,13 @@ public Matrix2x4F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix4x2F left, Matrix4x2F right) => !(left == right); + public static bool operator !=(Matrix4X2 left, Matrix4X2 right) => !(left == right); /// Adds two matrices together. /// The first source matrix. /// The second source matrix. /// The result of the addition. - public static Matrix4x2F operator +(Matrix4x2F left, Matrix4x2F right) => + public static Matrix4X2 operator +(Matrix4X2 left, Matrix4X2 right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, @@ -124,7 +124,7 @@ public Matrix2x4F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the subtraction. - public static Matrix4x2F operator -(Matrix4x2F left, Matrix4x2F right) => + public static Matrix4X2 operator -(Matrix4X2 left, Matrix4X2 right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, @@ -133,7 +133,7 @@ public Matrix2x4F Transpose() => /// Returns a new matrix with the negated elements of the given matrix. /// The source matrix. /// The negated matrix. - public static Matrix4x2F operator -(Matrix4x2F value) => + public static Matrix4X2 operator -(Matrix4X2 value) => new(-value.Row1, -value.Row2, -value.Row3, @@ -143,7 +143,7 @@ public Matrix2x4F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix4x2F operator *(Matrix4x2F left, Matrix2x2F right) => + public static Matrix4X2 operator *(Matrix4X2 left, Matrix2X2 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, @@ -153,7 +153,7 @@ public Matrix2x4F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix4x3F operator *(Matrix4x2F left, Matrix2x3F right) => + public static Matrix4X3 operator *(Matrix4X2 left, Matrix2X3 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, @@ -163,16 +163,16 @@ public Matrix2x4F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix4x4F operator *(Matrix4x2F left, Matrix2x4F right) => + public static Matrix4X4 operator *(Matrix4X2 left, Matrix2X4 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); } - static partial class Matrix4x2F + public static partial class Matrix4X2 { - public static Matrix4x2F Lerp(Matrix4x2F value1, Matrix4x2F value2, T amount) + public static Matrix4X2 Lerp(Matrix4X2 value1, Matrix4X2 value2, T amount) where T : IFloatingPointIeee754 => new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount)), new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount)), diff --git a/sources/Maths/Maths/Matrix4x3F.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs similarity index 83% rename from sources/Maths/Maths/Matrix4x3F.gen.cs rename to sources/Maths/Maths/Matrix4X3.gen.cs index 5600ad456c..ba7647e55a 100644 --- a/sources/Maths/Maths/Matrix4x3F.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -3,29 +3,29 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix4x3F : - IEquatable> - where T : IFloatingPointIeee754 + public partial struct Matrix4X3 : + IEquatable> + where T : INumberBase { /// The 1st row of the matrix represented as a vector. - public Vector3F Row1; + public Vector3D Row1; /// The 2nd row of the matrix represented as a vector. - public Vector3F Row2; + public Vector3D Row2; /// The 3rd row of the matrix represented as a vector. - public Vector3F Row3; + public Vector3D Row3; /// The 4th row of the matrix represented as a vector. - public Vector3F Row4; + public Vector3D Row4; /// - /// Constructs a from the given rows. + /// Constructs a from the given rows. /// - public Matrix4x3F(Vector3F row1, Vector3F row2, Vector3F row3, Vector3F row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + public Matrix4X3(Vector3D row1, Vector3D row2, Vector3D row3, Vector3D row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); [UnscopedRef] - public ref Vector3F this[int row] + public ref Vector3D this[int row] { get { @@ -97,16 +97,16 @@ public ref Vector3F this[int row] public ref T M43 => ref Row4.Z; /// - public override bool Equals(object? obj) => obj is Matrix4x3F other && Equals(other); + public override bool Equals(object? obj) => obj is Matrix4X3 other && Equals(other); /// - public bool Equals(Matrix4x3F other) => this == other; + public bool Equals(Matrix4X3 other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); /// Computes the transpose of the matrix. - public Matrix3x4F Transpose() => + public Matrix3X4 Transpose() => new(new(M11, M21, M31, M41), new(M12, M22, M32, M42), new(M13, M23, M33, M43)); @@ -115,7 +115,7 @@ public Matrix3x4F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix4x3F left, Matrix4x3F right) => + public static bool operator ==(Matrix4X3 left, Matrix4X3 right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && @@ -125,13 +125,13 @@ public Matrix3x4F Transpose() => /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix4x3F left, Matrix4x3F right) => !(left == right); + public static bool operator !=(Matrix4X3 left, Matrix4X3 right) => !(left == right); /// Adds two matrices together. /// The first source matrix. /// The second source matrix. /// The result of the addition. - public static Matrix4x3F operator +(Matrix4x3F left, Matrix4x3F right) => + public static Matrix4X3 operator +(Matrix4X3 left, Matrix4X3 right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, @@ -141,7 +141,7 @@ public Matrix3x4F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the subtraction. - public static Matrix4x3F operator -(Matrix4x3F left, Matrix4x3F right) => + public static Matrix4X3 operator -(Matrix4X3 left, Matrix4X3 right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, @@ -150,7 +150,7 @@ public Matrix3x4F Transpose() => /// Returns a new matrix with the negated elements of the given matrix. /// The source matrix. /// The negated matrix. - public static Matrix4x3F operator -(Matrix4x3F value) => + public static Matrix4X3 operator -(Matrix4X3 value) => new(-value.Row1, -value.Row2, -value.Row3, @@ -160,7 +160,7 @@ public Matrix3x4F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix2x3F operator *(Matrix2x4F left, Matrix4x3F right) => + public static Matrix2X3 operator *(Matrix2X4 left, Matrix4X3 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); @@ -168,7 +168,7 @@ public Matrix3x4F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix4x2F operator *(Matrix4x3F left, Matrix3x2F right) => + public static Matrix4X2 operator *(Matrix4X3 left, Matrix3X2 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, @@ -178,7 +178,7 @@ public Matrix3x4F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix4x3F operator *(Matrix4x3F left, Matrix3x3F right) => + public static Matrix4X3 operator *(Matrix4X3 left, Matrix3X3 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, @@ -188,16 +188,16 @@ public Matrix3x4F Transpose() => /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix4x4F operator *(Matrix4x3F left, Matrix3x4F right) => + public static Matrix4X4 operator *(Matrix4X3 left, Matrix3X4 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); } - static partial class Matrix4x3F + public static partial class Matrix4X3 { - public static Matrix4x3F Lerp(Matrix4x3F value1, Matrix4x3F value2, T amount) + public static Matrix4X3 Lerp(Matrix4X3 value1, Matrix4X3 value2, T amount) where T : IFloatingPointIeee754 => new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount)), new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount)), diff --git a/sources/Maths/Maths/Matrix4x2I.gen.cs b/sources/Maths/Maths/Matrix4x2I.gen.cs deleted file mode 100644 index a1d468858e..0000000000 --- a/sources/Maths/Maths/Matrix4x2I.gen.cs +++ /dev/null @@ -1,173 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - - partial struct Matrix4x2I : - IEquatable> - where T : IBinaryInteger - { - /// The 1st row of the matrix represented as a vector. - public Vector2I Row1; - - /// The 2nd row of the matrix represented as a vector. - public Vector2I Row2; - - /// The 3rd row of the matrix represented as a vector. - public Vector2I Row3; - - /// The 4th row of the matrix represented as a vector. - public Vector2I Row4; - - /// - /// Constructs a from the given rows. - /// - public Matrix4x2I(Vector2I row1, Vector2I row2, Vector2I row3, Vector2I row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); - - [UnscopedRef] - public ref Vector2I this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - case 3: - return ref Row4; - } - - throw new ArgumentOutOfRangeException(nameof(row)); - } - } - - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - - /// Gets the element in the 1st row and 1st column of the matrix. - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// Gets the element in the 3rd row and 1st column of the matrix. - [UnscopedRef] - public ref T M31 => ref Row3.X; - - /// Gets the element in the 3rd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M32 => ref Row3.Y; - - /// Gets the element in the 4th row and 1st column of the matrix. - [UnscopedRef] - public ref T M41 => ref Row4.X; - - /// Gets the element in the 4th row and 2nd column of the matrix. - [UnscopedRef] - public ref T M42 => ref Row4.Y; - - /// - public override bool Equals(object? obj) => obj is Matrix4x2I other && Equals(other); - - /// - public bool Equals(Matrix4x2I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); - - /// Computes the transpose of the matrix. - public Matrix2x4I Transpose() => - new(new(M11, M21, M31, M41), - new(M12, M22, M32, M42)); - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix4x2I left, Matrix4x2I right) => - left.Row1 == right.Row1 && - left.Row2 == right.Row2 && - left.Row3 == right.Row3 && - left.Row4 == right.Row4; - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix4x2I left, Matrix4x2I right) => !(left == right); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix4x2I operator +(Matrix4x2I left, Matrix4x2I right) => - new(left.Row1 + right.Row1, - left.Row2 + right.Row2, - left.Row3 + right.Row3, - left.Row4 + right.Row4); - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix4x2I operator -(Matrix4x2I left, Matrix4x2I right) => - new(left.Row1 - right.Row1, - left.Row2 - right.Row2, - left.Row3 - right.Row3, - left.Row4 - right.Row4); - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix4x2I operator -(Matrix4x2I value) => - new(-value.Row1, - -value.Row2, - -value.Row3, - -value.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4x2I operator *(Matrix4x2I left, Matrix2x2I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2, - left.M21 * right.Row1 + left.M22 * right.Row2, - left.M31 * right.Row1 + left.M32 * right.Row2, - left.M41 * right.Row1 + left.M42 * right.Row2); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4x3I operator *(Matrix4x2I left, Matrix2x3I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2, - left.M21 * right.Row1 + left.M22 * right.Row2, - left.M31 * right.Row1 + left.M32 * right.Row2, - left.M41 * right.Row1 + left.M42 * right.Row2); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4x4I operator *(Matrix4x2I left, Matrix2x4I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2, - left.M21 * right.Row1 + left.M22 * right.Row2, - left.M31 * right.Row1 + left.M32 * right.Row2, - left.M41 * right.Row1 + left.M42 * right.Row2); - } - -} diff --git a/sources/Maths/Maths/Matrix4x3I.gen.cs b/sources/Maths/Maths/Matrix4x3I.gen.cs deleted file mode 100644 index 49b3576f0a..0000000000 --- a/sources/Maths/Maths/Matrix4x3I.gen.cs +++ /dev/null @@ -1,198 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - - partial struct Matrix4x3I : - IEquatable> - where T : IBinaryInteger - { - /// The 1st row of the matrix represented as a vector. - public Vector3I Row1; - - /// The 2nd row of the matrix represented as a vector. - public Vector3I Row2; - - /// The 3rd row of the matrix represented as a vector. - public Vector3I Row3; - - /// The 4th row of the matrix represented as a vector. - public Vector3I Row4; - - /// - /// Constructs a from the given rows. - /// - public Matrix4x3I(Vector3I row1, Vector3I row2, Vector3I row3, Vector3I row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); - - [UnscopedRef] - public ref Vector3I this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - case 3: - return ref Row4; - } - - throw new ArgumentOutOfRangeException(nameof(row)); - } - } - - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - - /// Gets the element in the 1st row and 1st column of the matrix. - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 1st row and 3rd column of the matrix. - [UnscopedRef] - public ref T M13 => ref Row1.Z; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// Gets the element in the 2nd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M23 => ref Row2.Z; - - /// Gets the element in the 3rd row and 1st column of the matrix. - [UnscopedRef] - public ref T M31 => ref Row3.X; - - /// Gets the element in the 3rd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M32 => ref Row3.Y; - - /// Gets the element in the 3rd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M33 => ref Row3.Z; - - /// Gets the element in the 4th row and 1st column of the matrix. - [UnscopedRef] - public ref T M41 => ref Row4.X; - - /// Gets the element in the 4th row and 2nd column of the matrix. - [UnscopedRef] - public ref T M42 => ref Row4.Y; - - /// Gets the element in the 4th row and 3rd column of the matrix. - [UnscopedRef] - public ref T M43 => ref Row4.Z; - - /// - public override bool Equals(object? obj) => obj is Matrix4x3I other && Equals(other); - - /// - public bool Equals(Matrix4x3I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); - - /// Computes the transpose of the matrix. - public Matrix3x4I Transpose() => - new(new(M11, M21, M31, M41), - new(M12, M22, M32, M42), - new(M13, M23, M33, M43)); - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix4x3I left, Matrix4x3I right) => - left.Row1 == right.Row1 && - left.Row2 == right.Row2 && - left.Row3 == right.Row3 && - left.Row4 == right.Row4; - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix4x3I left, Matrix4x3I right) => !(left == right); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix4x3I operator +(Matrix4x3I left, Matrix4x3I right) => - new(left.Row1 + right.Row1, - left.Row2 + right.Row2, - left.Row3 + right.Row3, - left.Row4 + right.Row4); - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix4x3I operator -(Matrix4x3I left, Matrix4x3I right) => - new(left.Row1 - right.Row1, - left.Row2 - right.Row2, - left.Row3 - right.Row3, - left.Row4 - right.Row4); - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix4x3I operator -(Matrix4x3I value) => - new(-value.Row1, - -value.Row2, - -value.Row3, - -value.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2x3I operator *(Matrix2x4I left, Matrix4x3I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4x2I operator *(Matrix4x3I left, Matrix3x2I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, - left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4x3I operator *(Matrix4x3I left, Matrix3x3I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, - left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4x4I operator *(Matrix4x3I left, Matrix3x4I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, - left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); - } - -} diff --git a/sources/Maths/Maths/Matrix4x4F.gen.cs b/sources/Maths/Maths/Matrix4x4F.gen.cs deleted file mode 100644 index 9c2acdddf3..0000000000 --- a/sources/Maths/Maths/Matrix4x4F.gen.cs +++ /dev/null @@ -1,240 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - - partial struct Matrix4x4F : - IEquatable> - where T : IFloatingPointIeee754 - { - /// The multiplicative identity matrix of size 4x4. - public static readonly Matrix4x4F Identity = new( - new(T.MultiplicativeIdentity, T.Zero, T.Zero, T.Zero), - new(T.Zero, T.MultiplicativeIdentity, T.Zero, T.Zero), - new(T.Zero, T.Zero, T.MultiplicativeIdentity, T.Zero), - new(T.Zero, T.Zero, T.Zero, T.MultiplicativeIdentity)); - - /// The 1st row of the matrix represented as a vector. - public Vector4F Row1; - - /// The 2nd row of the matrix represented as a vector. - public Vector4F Row2; - - /// The 3rd row of the matrix represented as a vector. - public Vector4F Row3; - - /// The 4th row of the matrix represented as a vector. - public Vector4F Row4; - - /// - /// Constructs a from the given rows. - /// - public Matrix4x4F(Vector4F row1, Vector4F row2, Vector4F row3, Vector4F row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); - - [UnscopedRef] - public ref Vector4F this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - case 3: - return ref Row4; - } - - throw new ArgumentOutOfRangeException(nameof(row)); - } - } - - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - - /// Gets the element in the 1st row and 1st column of the matrix. - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 1st row and 3rd column of the matrix. - [UnscopedRef] - public ref T M13 => ref Row1.Z; - - /// Gets the element in the 1st row and 4th column of the matrix. - [UnscopedRef] - public ref T M14 => ref Row1.W; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// Gets the element in the 2nd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M23 => ref Row2.Z; - - /// Gets the element in the 2nd row and 4th column of the matrix. - [UnscopedRef] - public ref T M24 => ref Row2.W; - - /// Gets the element in the 3rd row and 1st column of the matrix. - [UnscopedRef] - public ref T M31 => ref Row3.X; - - /// Gets the element in the 3rd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M32 => ref Row3.Y; - - /// Gets the element in the 3rd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M33 => ref Row3.Z; - - /// Gets the element in the 3rd row and 4th column of the matrix. - [UnscopedRef] - public ref T M34 => ref Row3.W; - - /// Gets the element in the 4th row and 1st column of the matrix. - [UnscopedRef] - public ref T M41 => ref Row4.X; - - /// Gets the element in the 4th row and 2nd column of the matrix. - [UnscopedRef] - public ref T M42 => ref Row4.Y; - - /// Gets the element in the 4th row and 3rd column of the matrix. - [UnscopedRef] - public ref T M43 => ref Row4.Z; - - /// Gets the element in the 4th row and 4th column of the matrix. - [UnscopedRef] - public ref T M44 => ref Row4.W; - - /// - public override bool Equals(object? obj) => obj is Matrix4x4F other && Equals(other); - - /// - public bool Equals(Matrix4x4F other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); - - /// Computes the transpose of the matrix. - public Matrix4x4F Transpose() => - new(new(M11, M21, M31, M41), - new(M12, M22, M32, M42), - new(M13, M23, M33, M43), - new(M14, M24, M34, M44)); - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix4x4F left, Matrix4x4F right) => - left.Row1 == right.Row1 && - left.Row2 == right.Row2 && - left.Row3 == right.Row3 && - left.Row4 == right.Row4; - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix4x4F left, Matrix4x4F right) => !(left == right); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix4x4F operator +(Matrix4x4F left, Matrix4x4F right) => - new(left.Row1 + right.Row1, - left.Row2 + right.Row2, - left.Row3 + right.Row3, - left.Row4 + right.Row4); - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix4x4F operator -(Matrix4x4F left, Matrix4x4F right) => - new(left.Row1 - right.Row1, - left.Row2 - right.Row2, - left.Row3 - right.Row3, - left.Row4 - right.Row4); - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix4x4F operator -(Matrix4x4F value) => - new(-value.Row1, - -value.Row2, - -value.Row3, - -value.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2x4F operator *(Matrix2x4F left, Matrix4x4F right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3x4F operator *(Matrix3x4F left, Matrix4x4F right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4x2F operator *(Matrix4x4F left, Matrix4x2F right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, - left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4x3F operator *(Matrix4x4F left, Matrix4x3F right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, - left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4x4F operator *(Matrix4x4F left, Matrix4x4F right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, - left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); - } - - static partial class Matrix4x4F - { - public static Matrix4x4F Lerp(Matrix4x4F value1, Matrix4x4F value2, T amount) - where T : IFloatingPointIeee754 => - new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount), T.Lerp(value1.M14, value2.M14, amount)), - new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount), T.Lerp(value1.M24, value2.M24, amount)), - new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount), T.Lerp(value1.M33, value2.M33, amount), T.Lerp(value1.M34, value2.M34, amount)), - new(T.Lerp(value1.M41, value2.M41, amount), T.Lerp(value1.M42, value2.M42, amount), T.Lerp(value1.M43, value2.M43, amount), T.Lerp(value1.M44, value2.M44, amount))); - } -} diff --git a/sources/Maths/Maths/Matrix4x4I.gen.cs b/sources/Maths/Maths/Matrix4x4I.gen.cs deleted file mode 100644 index ebae4c3681..0000000000 --- a/sources/Maths/Maths/Matrix4x4I.gen.cs +++ /dev/null @@ -1,231 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - - partial struct Matrix4x4I : - IEquatable> - where T : IBinaryInteger - { - /// The multiplicative identity matrix of size 4x4. - public static readonly Matrix4x4I Identity = new( - new(T.MultiplicativeIdentity, T.Zero, T.Zero, T.Zero), - new(T.Zero, T.MultiplicativeIdentity, T.Zero, T.Zero), - new(T.Zero, T.Zero, T.MultiplicativeIdentity, T.Zero), - new(T.Zero, T.Zero, T.Zero, T.MultiplicativeIdentity)); - - /// The 1st row of the matrix represented as a vector. - public Vector4I Row1; - - /// The 2nd row of the matrix represented as a vector. - public Vector4I Row2; - - /// The 3rd row of the matrix represented as a vector. - public Vector4I Row3; - - /// The 4th row of the matrix represented as a vector. - public Vector4I Row4; - - /// - /// Constructs a from the given rows. - /// - public Matrix4x4I(Vector4I row1, Vector4I row2, Vector4I row3, Vector4I row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); - - [UnscopedRef] - public ref Vector4I this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - case 3: - return ref Row4; - } - - throw new ArgumentOutOfRangeException(nameof(row)); - } - } - - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - - /// Gets the element in the 1st row and 1st column of the matrix. - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 1st row and 3rd column of the matrix. - [UnscopedRef] - public ref T M13 => ref Row1.Z; - - /// Gets the element in the 1st row and 4th column of the matrix. - [UnscopedRef] - public ref T M14 => ref Row1.W; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// Gets the element in the 2nd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M23 => ref Row2.Z; - - /// Gets the element in the 2nd row and 4th column of the matrix. - [UnscopedRef] - public ref T M24 => ref Row2.W; - - /// Gets the element in the 3rd row and 1st column of the matrix. - [UnscopedRef] - public ref T M31 => ref Row3.X; - - /// Gets the element in the 3rd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M32 => ref Row3.Y; - - /// Gets the element in the 3rd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M33 => ref Row3.Z; - - /// Gets the element in the 3rd row and 4th column of the matrix. - [UnscopedRef] - public ref T M34 => ref Row3.W; - - /// Gets the element in the 4th row and 1st column of the matrix. - [UnscopedRef] - public ref T M41 => ref Row4.X; - - /// Gets the element in the 4th row and 2nd column of the matrix. - [UnscopedRef] - public ref T M42 => ref Row4.Y; - - /// Gets the element in the 4th row and 3rd column of the matrix. - [UnscopedRef] - public ref T M43 => ref Row4.Z; - - /// Gets the element in the 4th row and 4th column of the matrix. - [UnscopedRef] - public ref T M44 => ref Row4.W; - - /// - public override bool Equals(object? obj) => obj is Matrix4x4I other && Equals(other); - - /// - public bool Equals(Matrix4x4I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); - - /// Computes the transpose of the matrix. - public Matrix4x4I Transpose() => - new(new(M11, M21, M31, M41), - new(M12, M22, M32, M42), - new(M13, M23, M33, M43), - new(M14, M24, M34, M44)); - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix4x4I left, Matrix4x4I right) => - left.Row1 == right.Row1 && - left.Row2 == right.Row2 && - left.Row3 == right.Row3 && - left.Row4 == right.Row4; - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix4x4I left, Matrix4x4I right) => !(left == right); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix4x4I operator +(Matrix4x4I left, Matrix4x4I right) => - new(left.Row1 + right.Row1, - left.Row2 + right.Row2, - left.Row3 + right.Row3, - left.Row4 + right.Row4); - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix4x4I operator -(Matrix4x4I left, Matrix4x4I right) => - new(left.Row1 - right.Row1, - left.Row2 - right.Row2, - left.Row3 - right.Row3, - left.Row4 - right.Row4); - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix4x4I operator -(Matrix4x4I value) => - new(-value.Row1, - -value.Row2, - -value.Row3, - -value.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2x4I operator *(Matrix2x4I left, Matrix4x4I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3x4I operator *(Matrix3x4I left, Matrix4x4I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4x2I operator *(Matrix4x4I left, Matrix4x2I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, - left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4x3I operator *(Matrix4x4I left, Matrix4x3I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, - left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4x4I operator *(Matrix4x4I left, Matrix4x4I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, - left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); - } - -} diff --git a/sources/Maths/Maths/Matrix5x4F.gen.cs b/sources/Maths/Maths/Matrix5X4.gen.cs similarity index 86% rename from sources/Maths/Maths/Matrix5x4F.gen.cs rename to sources/Maths/Maths/Matrix5X4.gen.cs index 0c299fd514..f2eeff2e38 100644 --- a/sources/Maths/Maths/Matrix5x4F.gen.cs +++ b/sources/Maths/Maths/Matrix5X4.gen.cs @@ -3,32 +3,32 @@ namespace Silk.NET.Maths using System.Diagnostics.CodeAnalysis; using System.Numerics; - partial struct Matrix5x4F : - IEquatable> - where T : IFloatingPointIeee754 + public partial struct Matrix5X4 : + IEquatable> + where T : INumberBase { /// The 1st row of the matrix represented as a vector. - public Vector4F Row1; + public Vector4D Row1; /// The 2nd row of the matrix represented as a vector. - public Vector4F Row2; + public Vector4D Row2; /// The 3rd row of the matrix represented as a vector. - public Vector4F Row3; + public Vector4D Row3; /// The 4th row of the matrix represented as a vector. - public Vector4F Row4; + public Vector4D Row4; /// The 5th row of the matrix represented as a vector. - public Vector4F Row5; + public Vector4D Row5; /// - /// Constructs a from the given rows. + /// Constructs a from the given rows. /// - public Matrix5x4F(Vector4F row1, Vector4F row2, Vector4F row3, Vector4F row4, Vector4F row5) => (Row1, Row2, Row3, Row4, Row5) = (row1, row2, row3, row4, row5); + public Matrix5X4(Vector4D row1, Vector4D row2, Vector4D row3, Vector4D row4, Vector4D row5) => (Row1, Row2, Row3, Row4, Row5) = (row1, row2, row3, row4, row5); [UnscopedRef] - public ref Vector4F this[int row] + public ref Vector4D this[int row] { get { @@ -134,10 +134,10 @@ public ref Vector4F this[int row] public ref T M54 => ref Row5.W; /// - public override bool Equals(object? obj) => obj is Matrix5x4F other && Equals(other); + public override bool Equals(object? obj) => obj is Matrix5X4 other && Equals(other); /// - public bool Equals(Matrix5x4F other) => this == other; + public bool Equals(Matrix5X4 other) => this == other; /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4, Row5); @@ -146,7 +146,7 @@ public ref Vector4F this[int row] /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix5x4F left, Matrix5x4F right) => + public static bool operator ==(Matrix5X4 left, Matrix5X4 right) => left.Row1 == right.Row1 && left.Row2 == right.Row2 && left.Row3 == right.Row3 && @@ -157,13 +157,13 @@ public ref Vector4F this[int row] /// The first matrix to compare. /// The second matrix to compare. /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix5x4F left, Matrix5x4F right) => !(left == right); + public static bool operator !=(Matrix5X4 left, Matrix5X4 right) => !(left == right); /// Adds two matrices together. /// The first source matrix. /// The second source matrix. /// The result of the addition. - public static Matrix5x4F operator +(Matrix5x4F left, Matrix5x4F right) => + public static Matrix5X4 operator +(Matrix5X4 left, Matrix5X4 right) => new(left.Row1 + right.Row1, left.Row2 + right.Row2, left.Row3 + right.Row3, @@ -174,7 +174,7 @@ public ref Vector4F this[int row] /// The first source matrix. /// The second source matrix. /// The result of the subtraction. - public static Matrix5x4F operator -(Matrix5x4F left, Matrix5x4F right) => + public static Matrix5X4 operator -(Matrix5X4 left, Matrix5X4 right) => new(left.Row1 - right.Row1, left.Row2 - right.Row2, left.Row3 - right.Row3, @@ -184,7 +184,7 @@ public ref Vector4F this[int row] /// Returns a new matrix with the negated elements of the given matrix. /// The source matrix. /// The negated matrix. - public static Matrix5x4F operator -(Matrix5x4F value) => + public static Matrix5X4 operator -(Matrix5X4 value) => new(-value.Row1, -value.Row2, -value.Row3, @@ -195,7 +195,7 @@ public ref Vector4F this[int row] /// The first source matrix. /// The second source matrix. /// The result of the multiplication. - public static Matrix5x4F operator *(Matrix5x4F left, Matrix4x4F right) => + public static Matrix5X4 operator *(Matrix5X4 left, Matrix4X4 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, @@ -203,9 +203,9 @@ public ref Vector4F this[int row] left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); } - static partial class Matrix5x4F + public static partial class Matrix5X4 { - public static Matrix5x4F Lerp(Matrix5x4F value1, Matrix5x4F value2, T amount) + public static Matrix5X4 Lerp(Matrix5X4 value1, Matrix5X4 value2, T amount) where T : IFloatingPointIeee754 => new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount), T.Lerp(value1.M14, value2.M14, amount)), new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount), T.Lerp(value1.M24, value2.M24, amount)), diff --git a/sources/Maths/Maths/Matrix5x4I.gen.cs b/sources/Maths/Maths/Matrix5x4I.gen.cs deleted file mode 100644 index a57e492891..0000000000 --- a/sources/Maths/Maths/Matrix5x4I.gen.cs +++ /dev/null @@ -1,206 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - - partial struct Matrix5x4I : - IEquatable> - where T : IBinaryInteger - { - /// The 1st row of the matrix represented as a vector. - public Vector4I Row1; - - /// The 2nd row of the matrix represented as a vector. - public Vector4I Row2; - - /// The 3rd row of the matrix represented as a vector. - public Vector4I Row3; - - /// The 4th row of the matrix represented as a vector. - public Vector4I Row4; - - /// The 5th row of the matrix represented as a vector. - public Vector4I Row5; - - /// - /// Constructs a from the given rows. - /// - public Matrix5x4I(Vector4I row1, Vector4I row2, Vector4I row3, Vector4I row4, Vector4I row5) => (Row1, Row2, Row3, Row4, Row5) = (row1, row2, row3, row4, row5); - - [UnscopedRef] - public ref Vector4I this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - case 3: - return ref Row4; - case 4: - return ref Row5; - } - - throw new ArgumentOutOfRangeException(nameof(row)); - } - } - - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - - /// Gets the element in the 1st row and 1st column of the matrix. - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 1st row and 3rd column of the matrix. - [UnscopedRef] - public ref T M13 => ref Row1.Z; - - /// Gets the element in the 1st row and 4th column of the matrix. - [UnscopedRef] - public ref T M14 => ref Row1.W; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// Gets the element in the 2nd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M23 => ref Row2.Z; - - /// Gets the element in the 2nd row and 4th column of the matrix. - [UnscopedRef] - public ref T M24 => ref Row2.W; - - /// Gets the element in the 3rd row and 1st column of the matrix. - [UnscopedRef] - public ref T M31 => ref Row3.X; - - /// Gets the element in the 3rd row and 2nd column of the matrix. - [UnscopedRef] - public ref T M32 => ref Row3.Y; - - /// Gets the element in the 3rd row and 3rd column of the matrix. - [UnscopedRef] - public ref T M33 => ref Row3.Z; - - /// Gets the element in the 3rd row and 4th column of the matrix. - [UnscopedRef] - public ref T M34 => ref Row3.W; - - /// Gets the element in the 4th row and 1st column of the matrix. - [UnscopedRef] - public ref T M41 => ref Row4.X; - - /// Gets the element in the 4th row and 2nd column of the matrix. - [UnscopedRef] - public ref T M42 => ref Row4.Y; - - /// Gets the element in the 4th row and 3rd column of the matrix. - [UnscopedRef] - public ref T M43 => ref Row4.Z; - - /// Gets the element in the 4th row and 4th column of the matrix. - [UnscopedRef] - public ref T M44 => ref Row4.W; - - /// Gets the element in the 5th row and 1st column of the matrix. - [UnscopedRef] - public ref T M51 => ref Row5.X; - - /// Gets the element in the 5th row and 2nd column of the matrix. - [UnscopedRef] - public ref T M52 => ref Row5.Y; - - /// Gets the element in the 5th row and 3rd column of the matrix. - [UnscopedRef] - public ref T M53 => ref Row5.Z; - - /// Gets the element in the 5th row and 4th column of the matrix. - [UnscopedRef] - public ref T M54 => ref Row5.W; - - /// - public override bool Equals(object? obj) => obj is Matrix5x4I other && Equals(other); - - /// - public bool Equals(Matrix5x4I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4, Row5); - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are equal; false otherwise. - public static bool operator ==(Matrix5x4I left, Matrix5x4I right) => - left.Row1 == right.Row1 && - left.Row2 == right.Row2 && - left.Row3 == right.Row3 && - left.Row4 == right.Row4 && - left.Row5 == right.Row5; - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// true if the given matrices are not equal; false otherwise. - public static bool operator !=(Matrix5x4I left, Matrix5x4I right) => !(left == right); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix5x4I operator +(Matrix5x4I left, Matrix5x4I right) => - new(left.Row1 + right.Row1, - left.Row2 + right.Row2, - left.Row3 + right.Row3, - left.Row4 + right.Row4, - left.Row5 + right.Row5); - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix5x4I operator -(Matrix5x4I left, Matrix5x4I right) => - new(left.Row1 - right.Row1, - left.Row2 - right.Row2, - left.Row3 - right.Row3, - left.Row4 - right.Row4, - left.Row5 - right.Row5); - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix5x4I operator -(Matrix5x4I value) => - new(-value.Row1, - -value.Row2, - -value.Row3, - -value.Row4, - -value.Row5); - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix5x4I operator *(Matrix5x4I left, Matrix4x4I right) => - new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, - left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, - left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, - left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, - left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); - } - -} diff --git a/sources/Maths/Maths/Vector2D.cs b/sources/Maths/Maths/Vector2D.cs new file mode 100644 index 0000000000..dd577a241c --- /dev/null +++ b/sources/Maths/Maths/Vector2D.cs @@ -0,0 +1,78 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + + +using System.Collections; +using System.Diagnostics.CodeAnalysis; +using System.Numerics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; + +namespace Silk.NET.Maths +{ + /// A structure representing a 2D integer vector. + public partial struct Vector2D + { + /// Computes the cross product of this vector with another vector. + public T Cross(Vector2D other) => (X * other.Y) - (Y * other.X); + + /// Computes the cross product of two vectors. + public static T Cross(Vector2D left, Vector2D right) => (left.X * right.Y) - (left.Y * right.X); + + // Casts + + /// Explicitly casts a to a . + public static explicit operator Vector2D(System.Numerics.Vector2 v) => + new Vector2D((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T))); + + /// Explicitly casts a to . + public static explicit operator System.Numerics.Vector2(Vector2D v) => + new System.Numerics.Vector2(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); + + public static (Vector2D Quotient, Vector2D Remainder) DivRem(Vector2D left, Vector2D right) + { + var (qX, rX) = T.DivRem(left.X, right.X); + var (qY, rY) = T.DivRem(left.Y, right.Y); + return (new Vector2D(qX, qY), new Vector2D(rX, rY)); + } + + /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). + public static Vector2D LerpClamped(Vector2D a, Vector2D b, T t) => + Vector2D.Lerp(a, b, T.Clamp(t, T.Zero, T.One)); + + /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). + public static Vector2D LerpClamped(Vector2D a, Vector2D b, Vector2D t) => + new( + a.X + (b.X - a.X) * T.Clamp(t.X, T.Zero, T.One), + a.Y + (b.Y - a.Y) * T.Clamp(t.Y, T.Zero, T.One) + ); + + // IFloatingPointIeee754 + + public static (Vector2D Sin, Vector2D Cos) SinCos(Vector2D x) => + (new(T.Sin(x.X), T.Sin(x.Y)), new(T.Cos(x.X), T.Cos(x.Y))); + + public static (Vector2D SinPi, Vector2D CosPi) SinCosPi(Vector2D x) => + (new(T.SinPi(x.X), T.SinPi(x.Y)), new(T.CosPi(x.X), T.CosPi(x.Y))); + + public static Vector2D FusedMultiplyAdd(Vector2D left, Vector2D right, Vector2D addend) => + new(T.FusedMultiplyAdd(left.X, right.X, addend.X), T.FusedMultiplyAdd(left.Y, right.Y, addend.Y)); + + public static Vector2D FusedMultiplyAdd(Vector2D left, Vector2D right, T addend) => + new(T.FusedMultiplyAdd(left.X, right.X, addend), T.FusedMultiplyAdd(left.Y, right.Y, addend)); + + public static Vector2D FusedMultiplyAdd(Vector2D left, T right, Vector2D addend) => + new(T.FusedMultiplyAdd(left.X, right, addend.X), T.FusedMultiplyAdd(left.Y, right, addend.Y)); + + public static Vector2D FusedMultiplyAdd(Vector2D left, T right, T addend) => + new(T.FusedMultiplyAdd(left.X, right, addend), T.FusedMultiplyAdd(left.Y, right, addend)); + } + + public static partial class Vector2D + { + /// Computes the cross product of two vectors. + public static T Cross(this Vector2D left, Vector2D right) + where T : IFloatingPointIeee754 => (left.X * right.Y) - (left.Y * right.X); + } +} diff --git a/sources/Maths/Maths/Vector2F.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs similarity index 73% rename from sources/Maths/Maths/Vector2F.gen.cs rename to sources/Maths/Maths/Vector2D.gen.cs index 66d80f2855..3c9845a843 100644 --- a/sources/Maths/Maths/Vector2F.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -6,16 +6,16 @@ namespace Silk.NET.Maths using System.Runtime.InteropServices; using System.Text; - partial struct Vector2F : - IEquatable>, + public partial struct Vector2D : + IEquatable>, IReadOnlyList, IFormattable, - IParsable>, + IParsable>, ISpanFormattable, - ISpanParsable>, + ISpanParsable>, IUtf8SpanFormattable, - IUtf8SpanParsable> - where T : IFloatingPointIeee754 + IUtf8SpanParsable> + where T : INumberBase { /// The X component of the vector. public T X; @@ -24,13 +24,13 @@ partial struct Vector2F : public T Y; /// Initializes all components of the vector to the same value. - public Vector2F(T value) => (X, Y) = (value, value); + public Vector2D(T value) => (X, Y) = (value, value); /// Initializes the vector with individual component values. - public Vector2F(T x, T y) => (X, Y) = (x, y); + public Vector2D(T x, T y) => (X, Y) = (x, y); /// Initializes the vector from a span of 2 values. - public Vector2F(ReadOnlySpan values) + public Vector2D(ReadOnlySpan values) { if (values.Length != 2) throw new ArgumentException("Input span must contain exactly 2 elements.", nameof(values)); @@ -40,19 +40,19 @@ public Vector2F(ReadOnlySpan values) } /// Gets a vector whose 2 elements are equal to one. - public static Vector2F One => new(T.One); + public static Vector2D One => new(T.One); /// Returns a vector whose 2 elements are equal to zero. - public static Vector2F Zero => default; + public static Vector2D Zero => default; /// Gets the vector (1, 0). - public static Vector2F UnitX => new(T.One, T.Zero); + public static Vector2D UnitX => new(T.One, T.Zero); /// Gets the vector (0, 1). - public static Vector2F UnitY => new(T.Zero, T.One); + public static Vector2D UnitY => new(T.Zero, T.One); /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => Vector2F.Dot(this, this); + public T LengthSquared => Vector2D.Dot(this, this); /// T IReadOnlyList.this[int index] => this[index]; @@ -127,14 +127,14 @@ public override string ToString() => public string ToString(string? format, IFormatProvider? formatProvider) => $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}>"; - /// Parses a string to a instance. - public static Vector2F Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + /// Parses a string to a instance. + public static Vector2D Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); - /// Parses a span to a instance. - public static Vector2F Parse(ReadOnlySpan s, IFormatProvider? provider) + /// Parses a span to a instance. + public static Vector2D Parse(ReadOnlySpan s, IFormatProvider? provider) { if (!TryParse(s, provider, out var result)) - throw new FormatException("Invalid format for Vector2F."); + throw new FormatException("Invalid format for Vector2D."); return result; } @@ -213,8 +213,8 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan return true; } - /// Tries to parse a span to a instance. - public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) + /// Tries to parse a span to a instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2D result) { result = default; @@ -234,15 +234,15 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [Ma if (T.TryParse(xSpan, provider, out var x) && T.TryParse(ySpan, provider, out var y)) { - result = new Vector2F(x, y); + result = new Vector2D(x, y); return true; } return false; } - /// Parses a UTF-8 span to a instance. - public static Vector2F Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + /// Parses a UTF-8 span to a instance. + public static Vector2D Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) { int charCount = Encoding.UTF8.GetCharCount(utf8Text); Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; @@ -250,8 +250,8 @@ public static Vector2F Parse(ReadOnlySpan utf8Text, IFormatProvider? pr return Parse(charBuffer, provider); } - /// Tries to parse a UTF-8 span to a instance. - public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) + /// Tries to parse a UTF-8 span to a instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2D result) { int charCount = Encoding.UTF8.GetCharCount(utf8Text); Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; @@ -259,31 +259,31 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid return TryParse(charBuffer, provider, out result); } - /// Tries to parse a string to a instance. - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => + /// Tries to parse a string to a instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2D result) => TryParse(s.AsSpan(), provider, out result); - /// Parses a span to a instance. - static Vector2F ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + /// Parses a span to a instance. + static Vector2D ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => Parse(s, provider); - /// Parses a string to a instance. - static Vector2F IParsable>.Parse(string s, IFormatProvider? provider) => + /// Parses a string to a instance. + static Vector2D IParsable>.Parse(string s, IFormatProvider? provider) => Parse(s, provider); - /// Tries to parse a span to a instance. - static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => + /// Tries to parse a span to a instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2D result) => TryParse(s, provider, out result); - /// Tries to parse a string to a instance. - static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2F result) => + /// Tries to parse a string to a instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2D result) => TryParse(s, provider, out result); /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. /// true if the given vectors are equal; false otherwise. - public static bool operator ==(Vector2F left, Vector2F right) => + public static bool operator ==(Vector2D left, Vector2D right) => left.X == right.X && left.Y == right.Y; @@ -291,13 +291,13 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm /// The first vector to compare. /// The second vector to compare. /// true if the given vectors are not equal; false otherwise. - public static bool operator !=(Vector2F left, Vector2F right) => !(left == right); + public static bool operator !=(Vector2D left, Vector2D right) => !(left == right); /// - public override bool Equals(object? obj) => obj is Vector2F other && Equals(other); + public override bool Equals(object? obj) => obj is Vector2D other && Equals(other); /// - public bool Equals(Vector2F other) => this == other; + public bool Equals(Vector2D other) => this == other; /// public override int GetHashCode() => HashCode.Combine(X, Y); @@ -311,252 +311,263 @@ public void Deconstruct(out T x, out T y) y = Y; } - /// Implicitly casts a to a . - public static implicit operator Vector2F((T X, T Y) v) => + /// Converts the components of this vector to another type. + public Vector2D As() + where TOther : INumberBase => + new(TOther.CreateSaturating(X), TOther.CreateSaturating(Y)); + + /// Implicitly casts a to a . + public static implicit operator Vector2D((T X, T Y) v) => new(v.X, v.Y); - /// Implicitly casts a to a . - public static implicit operator (T X, T Y)(Vector2F v) => + /// Implicitly casts a to a . + public static implicit operator (T X, T Y)(Vector2D v) => (v.X, v.Y); - public static Vector2F operator +(Vector2F vector) => + public static Vector2D operator +(Vector2D vector) => vector; - public static Vector2F operator -(Vector2F vector) => + public static Vector2D operator -(Vector2D vector) => new(-vector.X, -vector.Y); - public static Vector2F operator +(Vector2F left, Vector2F right) => + public static Vector2D operator +(Vector2D left, Vector2D right) => new(left.X + right.X, left.Y + right.Y); - public static Vector2F operator -(Vector2F left, Vector2F right) => + public static Vector2D operator -(Vector2D left, Vector2D right) => new(left.X - right.X, left.Y - right.Y); - public static Vector2F operator *(Vector2F left, Vector2F right) => + public static Vector2D operator *(Vector2D left, Vector2D right) => new(left.X * right.X, left.Y * right.Y); - public static Vector2F operator /(Vector2F left, Vector2F right) => + public static Vector2D operator /(Vector2D left, Vector2D right) => new(left.X / right.X, left.Y / right.Y); - public static Vector2F operator %(Vector2F left, Vector2F right) => - new(left.X % right.X, left.Y % right.Y); - - public static Vector2F operator +(Vector2F vector, T scalar) => + public static Vector2D operator +(Vector2D vector, T scalar) => new(vector.X + scalar, vector.Y + scalar); - public static Vector2F operator -(Vector2F vector, T scalar) => + public static Vector2D operator -(Vector2D vector, T scalar) => new(vector.X - scalar, vector.Y - scalar); - public static Vector2F operator *(Vector2F vector, T scalar) => + public static Vector2D operator *(Vector2D vector, T scalar) => new(vector.X * scalar, vector.Y * scalar); - public static Vector2F operator *(T scalar, Vector2F vector) => + public static Vector2D operator *(T scalar, Vector2D vector) => new(scalar * vector.X, scalar * vector.Y); - public static Vector2F operator /(Vector2F vector, T scalar) => + public static Vector2D operator /(Vector2D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar); - public static Vector2F operator %(Vector2F vector, T scalar) => - new(vector.X % scalar, vector.Y % scalar); - } - static partial class Vector2F + public static partial class Vector2D { /// Computes the dot product of two vectors. - public static T Dot(this Vector2F left, Vector2F right) - where T : IFloatingPointIeee754 => + public static T Dot(this Vector2D left, Vector2D right) + where T : INumberBase => left.X * right.X + left.Y * right.Y; /// Reflects a vector over a normal vector. - public static Vector2F Reflect(Vector2F vector, Vector2F normal) - where T : IFloatingPointIeee754 + public static Vector2D Reflect(Vector2D vector, Vector2D normal) + where T : INumberBase { T dot = vector.Dot(normal); return vector - (normal * (dot + dot)); } /// Computes the length of the vector. - public static T GetLength(this Vector2F vector) + public static T GetLength(this Vector2D vector) where T : IFloatingPointIeee754 => T.Sqrt(vector.LengthSquared); /// Normalizes a vector. - public static Vector2F Normalize(this Vector2F vector) + public static Vector2D Normalize(this Vector2D vector) where T : IFloatingPointIeee754 { T length = vector.GetLength(); - return length != T.Zero ? vector / length : Vector2F.Zero; + return length != T.Zero ? vector / length : Vector2D.Zero; } /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2I Sign(this Vector2F value) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Sign(this Vector2D value) + where TSelf : INumber => new(TSelf.Sign(value.X), TSelf.Sign(value.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F Max(this Vector2F x, Vector2F y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Max(this Vector2D x, Vector2D y) + where TSelf : INumber => new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2F Max(this Vector2F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Max(this Vector2D x, TSelf y) + where TSelf : INumber => new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F MaxNumber(this Vector2F x, Vector2F y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D MaxNumber(this Vector2D x, Vector2D y) + where TSelf : INumber => new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2F MaxNumber(this Vector2F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D MaxNumber(this Vector2D x, TSelf y) + where TSelf : INumber => new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F Min(this Vector2F x, Vector2F y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Min(this Vector2D x, Vector2D y) + where TSelf : INumber => new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2F Min(this Vector2F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Min(this Vector2D x, TSelf y) + where TSelf : INumber => new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F MinNumber(this Vector2F x, Vector2F y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D MinNumber(this Vector2D x, Vector2D y) + where TSelf : INumber => new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2F MinNumber(this Vector2F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D MinNumber(this Vector2D x, TSelf y) + where TSelf : INumber => new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F Clamp(this Vector2F value, Vector2F min, Vector2F max) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Clamp(this Vector2D value, Vector2D min, Vector2D max) + where TSelf : INumber => new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector2F Clamp(this Vector2F value, TSelf min, TSelf max) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Clamp(this Vector2D value, TSelf min, TSelf max) + where TSelf : INumber => new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F CopySign(this Vector2F value, Vector2F sign) - where TSelf : IFloatingPointIeee754 => + public static Vector2D CopySign(this Vector2D value, Vector2D sign) + where TSelf : INumber => new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2F CopySign(this Vector2F value, TSelf sign) - where TSelf : IFloatingPointIeee754 => + public static Vector2D CopySign(this Vector2D value, TSelf sign) + where TSelf : INumber => new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Abs(this Vector2F value) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Abs(this Vector2D value) + where TSelf : INumberBase => new(TSelf.Abs(value.X), TSelf.Abs(value.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F MaxMagnitude(this Vector2F x, Vector2F y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D MaxMagnitude(this Vector2D x, Vector2D y) + where TSelf : INumberBase => new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F MaxMagnitudeNumber(this Vector2F x, Vector2F y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D MaxMagnitudeNumber(this Vector2D x, Vector2D y) + where TSelf : INumberBase => new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F MinMagnitude(this Vector2F x, Vector2F y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D MinMagnitude(this Vector2D x, Vector2D y) + where TSelf : INumberBase => new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F MinMagnitudeNumber(this Vector2F x, Vector2F y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D MinMagnitudeNumber(this Vector2D x, Vector2D y) + where TSelf : INumberBase => new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D PopCount(this Vector2D value) + where TSelf : IBinaryInteger => + new(TSelf.PopCount(value.X), TSelf.PopCount(value.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D TrailingZeroCount(this Vector2D value) + where TSelf : IBinaryInteger => + new(TSelf.TrailingZeroCount(value.X), TSelf.TrailingZeroCount(value.Y)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Ceiling(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Ceiling(this Vector2D x) + where TSelf : IFloatingPoint => new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Floor(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Floor(this Vector2D x) + where TSelf : IFloatingPoint => new(TSelf.Floor(x.X), TSelf.Floor(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Round(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Round(this Vector2D x) + where TSelf : IFloatingPoint => new(TSelf.Round(x.X), TSelf.Round(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector2F Round(this Vector2F x, int digits, MidpointRounding mode) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Round(this Vector2D x, int digits, MidpointRounding mode) + where TSelf : IFloatingPoint => new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Truncate(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Truncate(this Vector2D x) + where TSelf : IFloatingPoint => new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F Atan2(this Vector2F y, Vector2F x) + public static Vector2D Atan2(this Vector2D y, Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F Atan2Pi(this Vector2F y, Vector2F x) + public static Vector2D Atan2Pi(this Vector2D y, Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y)); @@ -564,19 +575,19 @@ public static Vector2F Atan2Pi(this Vector2F y, Vector2FA vector whose members will be provided for . /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2F Lerp(this Vector2F value1, Vector2F value2, TSelf amount) + public static Vector2D Lerp(this Vector2D value1, Vector2D value2, TSelf amount) where TSelf : IFloatingPointIeee754 => new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F BitDecrement(this Vector2F x) + public static Vector2D BitDecrement(this Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F BitIncrement(this Vector2F x) + public static Vector2D BitIncrement(this Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y)); @@ -584,7 +595,7 @@ public static Vector2F BitIncrement(this Vector2F x) /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F FusedMultiplyAdd(this Vector2F left, Vector2F right, Vector2F addend) + public static Vector2D FusedMultiplyAdd(this Vector2D left, Vector2D right, Vector2D addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y)); @@ -592,300 +603,300 @@ public static Vector2F FusedMultiplyAdd(this Vector2F left, /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector2F FusedMultiplyAdd(this Vector2F left, TSelf right, TSelf addend) + public static Vector2D FusedMultiplyAdd(this Vector2D left, TSelf right, TSelf addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F Ieee754Remainder(this Vector2F left, Vector2F right) + public static Vector2D Ieee754Remainder(this Vector2D left, Vector2D right) where TSelf : IFloatingPointIeee754 => new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2F Ieee754Remainder(this Vector2F left, TSelf right) + public static Vector2D Ieee754Remainder(this Vector2D left, TSelf right) where TSelf : IFloatingPointIeee754 => new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2I ILogB(this Vector2F x) + public static Vector2D ILogB(this Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F ReciprocalEstimate(this Vector2F x) + public static Vector2D ReciprocalEstimate(this Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F ReciprocalSqrtEstimate(this Vector2F x) + public static Vector2D ReciprocalSqrtEstimate(this Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F ScaleB(this Vector2F x, Vector2I n) + public static Vector2D ScaleB(this Vector2D x, Vector2D n) where TSelf : IFloatingPointIeee754 => new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2F ScaleB(this Vector2F x, int n) + public static Vector2D ScaleB(this Vector2D x, int n) where TSelf : IFloatingPointIeee754 => new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F Pow(this Vector2F x, Vector2F y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Pow(this Vector2D x, Vector2D y) + where TSelf : IPowerFunctions => new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2F Pow(this Vector2F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Pow(this Vector2D x, TSelf y) + where TSelf : IPowerFunctions => new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Cbrt(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Cbrt(this Vector2D x) + where TSelf : IRootFunctions => new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Sqrt(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Sqrt(this Vector2D x) + where TSelf : IRootFunctions => new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2F RootN(this Vector2F x, int n) - where TSelf : IFloatingPointIeee754 => + public static Vector2D RootN(this Vector2D x, int n) + where TSelf : IRootFunctions => new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F RootN(this Vector2F x, Vector2I n) - where TSelf : IFloatingPointIeee754 => + public static Vector2D RootN(this Vector2D x, Vector2D n) + where TSelf : IRootFunctions => new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2F Hypot(this Vector2F x, Vector2F y) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Hypot(this Vector2D x, Vector2D y) + where TSelf : IRootFunctions => new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Log(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Log(this Vector2D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2F Log(this Vector2F x, TSelf newBase) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Log(this Vector2D x, TSelf newBase) + where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F LogP1(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D LogP1(this Vector2D x) + where TSelf : ILogarithmicFunctions => new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Log2(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Log2(this Vector2D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log2(x.X), TSelf.Log2(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Log2P1(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Log2P1(this Vector2D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Log10(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Log10(this Vector2D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log10(x.X), TSelf.Log10(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Log10P1(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Log10P1(this Vector2D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Exp(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Exp(this Vector2D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp(x.X), TSelf.Exp(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F ExpM1(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D ExpM1(this Vector2D x) + where TSelf : IExponentialFunctions => new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Exp2(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Exp2(this Vector2D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Exp2M1(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Exp2M1(this Vector2D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Exp10(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Exp10(this Vector2D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Exp10M1(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Exp10M1(this Vector2D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Acos(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Acos(this Vector2D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Acos(x.X), TSelf.Acos(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F AcosPi(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D AcosPi(this Vector2D x) + where TSelf : ITrigonometricFunctions => new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Asin(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Asin(this Vector2D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Asin(x.X), TSelf.Asin(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F AsinPi(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D AsinPi(this Vector2D x) + where TSelf : ITrigonometricFunctions => new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Atan(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Atan(this Vector2D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Atan(x.X), TSelf.Atan(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F AtanPi(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D AtanPi(this Vector2D x) + where TSelf : ITrigonometricFunctions => new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Cos(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Cos(this Vector2D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Cos(x.X), TSelf.Cos(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F CosPi(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D CosPi(this Vector2D x) + where TSelf : ITrigonometricFunctions => new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Sin(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Sin(this Vector2D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Sin(x.X), TSelf.Sin(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F SinPi(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D SinPi(this Vector2D x) + where TSelf : ITrigonometricFunctions => new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Tan(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Tan(this Vector2D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Tan(x.X), TSelf.Tan(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F TanPi(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D TanPi(this Vector2D x) + where TSelf : ITrigonometricFunctions => new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F DegreesToRadians(this Vector2F degrees) - where TSelf : IFloatingPointIeee754 => + public static Vector2D DegreesToRadians(this Vector2D degrees) + where TSelf : ITrigonometricFunctions => new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F RadiansToDegrees(this Vector2F radians) - where TSelf : IFloatingPointIeee754 => + public static Vector2D RadiansToDegrees(this Vector2D radians) + where TSelf : ITrigonometricFunctions => new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Acosh(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Acosh(this Vector2D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Asinh(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Asinh(this Vector2D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Atanh(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Atanh(this Vector2D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Cosh(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Cosh(this Vector2D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Sinh(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Sinh(this Vector2D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2F Tanh(this Vector2F x) - where TSelf : IFloatingPointIeee754 => + public static Vector2D Tanh(this Vector2D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y)); } } diff --git a/sources/Maths/Maths/Vector2F.cs b/sources/Maths/Maths/Vector2F.cs deleted file mode 100644 index 70db4099f6..0000000000 --- a/sources/Maths/Maths/Vector2F.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - - -using System; -using System.Collections; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Numerics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Text; - -namespace Silk.NET.Maths -{ - /// A structure representing a 2D floating-point vector. - internal partial struct Vector2F - { - /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). - public static Vector2F LerpClamped(Vector2F a, Vector2F b, T t) => - Vector2F.Lerp(a, b, T.Clamp(t, T.Zero, T.One)); - - /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). - public static Vector2F LerpClamped(Vector2F a, Vector2F b, Vector2F t) => - new( - a.X + (b.X - a.X) * T.Clamp(t.X, T.Zero, T.One), - a.Y + (b.Y - a.Y) * T.Clamp(t.Y, T.Zero, T.One) - ); - - // Casts - - /// Explicitly casts a to a . - public static explicit operator Vector2F(System.Numerics.Vector2 v) => - new((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T))); - - /// Explicitly casts a to . - public static explicit operator System.Numerics.Vector2(Vector2F v) => - new(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); - - // IFloatingPointIeee754 - - public static (Vector2F Sin, Vector2F Cos) SinCos(Vector2F x) => - (new(T.Sin(x.X), T.Sin(x.Y)), new(T.Cos(x.X), T.Cos(x.Y))); - - public static (Vector2F SinPi, Vector2F CosPi) SinCosPi(Vector2F x) => - (new(T.SinPi(x.X), T.SinPi(x.Y)), new(T.CosPi(x.X), T.CosPi(x.Y))); - - public static Vector2F FusedMultiplyAdd(Vector2F left, Vector2F right, Vector2F addend) => - new(T.FusedMultiplyAdd(left.X, right.X, addend.X), T.FusedMultiplyAdd(left.Y, right.Y, addend.Y)); - - public static Vector2F FusedMultiplyAdd(Vector2F left, Vector2F right, T addend) => - new(T.FusedMultiplyAdd(left.X, right.X, addend), T.FusedMultiplyAdd(left.Y, right.Y, addend)); - - public static Vector2F FusedMultiplyAdd(Vector2F left, T right, Vector2F addend) => - new(T.FusedMultiplyAdd(left.X, right, addend.X), T.FusedMultiplyAdd(left.Y, right, addend.Y)); - - public static Vector2F FusedMultiplyAdd(Vector2F left, T right, T addend) => - new(T.FusedMultiplyAdd(left.X, right, addend), T.FusedMultiplyAdd(left.Y, right, addend)); - } - - static partial class Vector2F - { - /// Computes the cross product of two vectors. - public static T Cross(this Vector2F left, Vector2F right) - where T : IFloatingPointIeee754 => (left.X * right.Y) - (left.Y * right.X); - } -} diff --git a/sources/Maths/Maths/Vector2I.cs b/sources/Maths/Maths/Vector2I.cs deleted file mode 100644 index 88adc7cb6e..0000000000 --- a/sources/Maths/Maths/Vector2I.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - - -using System.Collections; -using System.Diagnostics.CodeAnalysis; -using System.Numerics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Text; - -namespace Silk.NET.Maths -{ - /// A structure representing a 2D integer vector. - internal partial struct Vector2I - { - /// Computes the cross product of this vector with another vector. - public T Cross(Vector2I other) => (X * other.Y) - (Y * other.X); - - /// Computes the cross product of two vectors. - public static T Cross(Vector2I left, Vector2I right) => (left.X * right.Y) - (left.Y * right.X); - - // Casts - - /// Explicitly casts a to a . - public static explicit operator Vector2I(System.Numerics.Vector2 v) => - new Vector2I((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T))); - - /// Explicitly casts a to . - public static explicit operator System.Numerics.Vector2(Vector2I v) => - new System.Numerics.Vector2(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); - - public static (Vector2I Quotient, Vector2I Remainder) DivRem(Vector2I left, Vector2I right) - { - var (qX, rX) = T.DivRem(left.X, right.X); - var (qY, rY) = T.DivRem(left.Y, right.Y); - return (new Vector2I(qX, qY), new Vector2I(rX, rY)); - } - } -} diff --git a/sources/Maths/Maths/Vector2I.gen.cs b/sources/Maths/Maths/Vector2I.gen.cs deleted file mode 100644 index 5295369eb4..0000000000 --- a/sources/Maths/Maths/Vector2I.gen.cs +++ /dev/null @@ -1,542 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Collections; - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - using System.Runtime.InteropServices; - using System.Text; - - partial struct Vector2I : - IEquatable>, - IReadOnlyList, - IFormattable, - IParsable>, - ISpanFormattable, - ISpanParsable>, - IUtf8SpanFormattable, - IUtf8SpanParsable> - where T : IBinaryInteger - { - /// The X component of the vector. - public T X; - - /// The Y component of the vector. - public T Y; - - /// Initializes all components of the vector to the same value. - public Vector2I(T value) => (X, Y) = (value, value); - - /// Initializes the vector with individual component values. - public Vector2I(T x, T y) => (X, Y) = (x, y); - - /// Initializes the vector from a span of 2 values. - public Vector2I(ReadOnlySpan values) - { - if (values.Length != 2) - throw new ArgumentException("Input span must contain exactly 2 elements.", nameof(values)); - - X = values[0]; - Y = values[1]; - } - - /// Gets a vector whose 2 elements are equal to one. - public static Vector2I One => new(T.One); - - /// Returns a vector whose 2 elements are equal to zero. - public static Vector2I Zero => default; - - /// Gets the vector (1, 0). - public static Vector2I UnitX => new(T.One, T.Zero); - - /// Gets the vector (0, 1). - public static Vector2I UnitY => new(T.Zero, T.One); - - /// Gets a vector with all bits set for each component. - public static Vector2I AllBitsSet => new Vector2I(T.AllBitsSet, T.AllBitsSet); - - /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => Vector2I.Dot(this, this); - - /// - T IReadOnlyList.this[int index] => this[index]; - - ///Gets the component at the specified index: 0 = X, 1 = Y. - [UnscopedRef] - public ref T this[int index] - { - get - { - switch (index) - { - case 0: - return ref X; - case 1: - return ref Y; - } - - throw new ArgumentOutOfRangeException(nameof(index)); - } - } - - /// The number of elements in the vector. - public int Count => 2; - - /// - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - - /// Returns an enumerator that iterates through the vector components. - public IEnumerator GetEnumerator() - { - yield return X; - yield return Y; - } - - /// Copies the components of the vector to the specified array starting at index 0. - public void CopyTo(T[] array) => CopyTo(array, 0); - - /// Copies the components of the vector to the specified array starting at the given index. - public void CopyTo(T[] array, int startIndex) - { - if (array == null) - throw new ArgumentNullException(nameof(array)); - if (startIndex < 0 || startIndex + 2 > array.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - - array[startIndex] = X; - array[startIndex + 1] = Y; - } - - /// Copies the components of the vector to the specified span starting at index 0. - public void CopyTo(Span span) => CopyTo(span, 0); - - /// Copies the components of the vector to the specified span starting at the given index. - public void CopyTo(Span span, int startIndex) - { - if (startIndex < 0 || startIndex + 2 > span.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - - span[startIndex] = X; - span[startIndex + 1] = Y; - } - - /// Returns a span over the vector components. - public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 2); - - /// Formats the vector as a string. - public override string ToString() => - $"<{X}, {Y}>"; - - /// Formats the vector as a string using the specified format and format provider. - public string ToString(string? format, IFormatProvider? formatProvider) => - $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}>"; - - /// Parses a string to a instance. - public static Vector2I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); - - /// Parses a span to a instance. - public static Vector2I Parse(ReadOnlySpan s, IFormatProvider? provider) - { - if (!TryParse(s, provider, out var result)) - throw new FormatException("Invalid format for Vector2I."); - - return result; - } - - /// Formats the vector as a UTF-8 string using the specified format and format provider. - public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) - { - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider)|| - !Y.TryFormat(yBuffer, out int yChars, format, provider)) - { - bytesWritten = 0; - return false; - } - - int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + - Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + - Encoding.UTF8.GetByteCount("<, >"); - - if (utf8Destination.Length < estimatedSize) - { - bytesWritten = 0; - return false; - } - - int totalBytes = 0; - - totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); - - bytesWritten = totalBytes; - return true; - } - - /// Formats the vector as a string using the specified format and format provider. - public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider) || - !Y.TryFormat(yBuffer, out int yChars, format, provider)) - { - charsWritten = 0; - return false; - } - - int requiredLength = 1 + xChars + 2 + yChars + 1; - - if (destination.Length < requiredLength) - { - charsWritten = 0; - return false; - } - - int pos = 0; - destination[pos++] = '<'; - - xBuffer[..xChars].CopyTo(destination[pos..]); - pos += xChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - yBuffer[..yChars].CopyTo(destination[pos..]); - pos += yChars; - - destination[pos++] = '>'; - - charsWritten = pos; - return true; - } - - /// Tries to parse a span to a instance. - public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) - { - result = default; - - s = s.Trim(); - if (s.Length < 4 || s[0] != '<' || s[^1] != '>') - return false; - - s = s[1..^1]; // Remove < and > - - int commaX = s.IndexOf(','); - if (commaX < 0) - return false; - - ReadOnlySpan xSpan = s[..commaX].Trim(); - ReadOnlySpan ySpan = s[(commaX + 1)..].Trim(); - - if (T.TryParse(xSpan, provider, out var x) && - T.TryParse(ySpan, provider, out var y)) - { - result = new Vector2I(x, y); - return true; - } - - return false; - } - - /// Parses a UTF-8 span to a instance. - public static Vector2I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return Parse(charBuffer, provider); - } - - /// Tries to parse a UTF-8 span to a instance. - public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return TryParse(charBuffer, provider, out result); - } - - /// Tries to parse a string to a instance. - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => - TryParse(s.AsSpan(), provider, out result); - - /// Parses a span to a instance. - static Vector2I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => - Parse(s, provider); - - /// Parses a string to a instance. - static Vector2I IParsable>.Parse(string s, IFormatProvider? provider) => - Parse(s, provider); - - /// Tries to parse a span to a instance. - static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => - TryParse(s, provider, out result); - - /// Tries to parse a string to a instance. - static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector2I result) => - TryParse(s, provider, out result); - - /// Returns a boolean indicating whether the given two vectors are equal. - /// The first vector to compare. - /// The second vector to compare. - /// true if the given vectors are equal; false otherwise. - public static bool operator ==(Vector2I left, Vector2I right) => - left.X == right.X && - left.Y == right.Y; - - /// Returns a boolean indicating whether the given two vectors are not equal. - /// The first vector to compare. - /// The second vector to compare. - /// true if the given vectors are not equal; false otherwise. - public static bool operator !=(Vector2I left, Vector2I right) => !(left == right); - - /// - public override bool Equals(object? obj) => obj is Vector2I other && Equals(other); - - /// - public bool Equals(Vector2I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(X, Y); - - /// Desconstructs a vector into its components. - /// The X component. - /// The Y component. - public void Deconstruct(out T x, out T y) - { - x = X; - y = Y; - } - - /// Implicitly casts a to a . - public static implicit operator Vector2I((T X, T Y) v) => - new(v.X, v.Y); - - /// Implicitly casts a to a . - public static implicit operator (T X, T Y)(Vector2I v) => - (v.X, v.Y); - - public static Vector2I operator +(Vector2I vector) => - vector; - - public static Vector2I operator -(Vector2I vector) => - new(-vector.X, -vector.Y); - - public static Vector2I operator +(Vector2I left, Vector2I right) => - new(left.X + right.X, left.Y + right.Y); - - public static Vector2I operator -(Vector2I left, Vector2I right) => - new(left.X - right.X, left.Y - right.Y); - - public static Vector2I operator *(Vector2I left, Vector2I right) => - new(left.X * right.X, left.Y * right.Y); - - public static Vector2I operator /(Vector2I left, Vector2I right) => - new(left.X / right.X, left.Y / right.Y); - - public static Vector2I operator %(Vector2I left, Vector2I right) => - new(left.X % right.X, left.Y % right.Y); - - public static Vector2I operator +(Vector2I vector, T scalar) => - new(vector.X + scalar, vector.Y + scalar); - - public static Vector2I operator -(Vector2I vector, T scalar) => - new(vector.X - scalar, vector.Y - scalar); - - public static Vector2I operator *(Vector2I vector, T scalar) => - new(vector.X * scalar, vector.Y * scalar); - - public static Vector2I operator *(T scalar, Vector2I vector) => - new(scalar * vector.X, scalar * vector.Y); - - public static Vector2I operator /(Vector2I vector, T scalar) => - new(vector.X / scalar, vector.Y / scalar); - - public static Vector2I operator %(Vector2I vector, T scalar) => - new(vector.X % scalar, vector.Y % scalar); - - public static Vector2I operator ~(Vector2I vector) => - new Vector2I(~vector.X, ~vector.Y); - - public static Vector2I operator &(Vector2I left, Vector2I right) => - new Vector2I(left.X & right.X, left.Y & right.Y); - - public static Vector2I operator |(Vector2I left, Vector2I right) => - new Vector2I(left.X | right.X, left.Y | right.Y); - - public static Vector2I operator ^(Vector2I left, Vector2I right) => - new Vector2I(left.X ^ right.X, left.Y ^ right.Y); - - public static Vector2I operator &(Vector2I vector, T scalar) => - new Vector2I(vector.X & scalar, vector.Y & scalar); - - public static Vector2I operator &(T scalar, Vector2I vector) => - new Vector2I(scalar & vector.X, scalar & vector.Y); - - public static Vector2I operator |(Vector2I vector, T scalar) => - new Vector2I(vector.X | scalar, vector.Y | scalar); - - public static Vector2I operator |(T scalar, Vector2I vector) => - new Vector2I(scalar | vector.X, scalar | vector.Y); - - public static Vector2I operator ^(Vector2I vector, T scalar) => - new Vector2I(vector.X ^ scalar, vector.Y ^ scalar); - - public static Vector2I operator ^(T scalar, Vector2I vector) => - new Vector2I(scalar ^ vector.X, scalar ^ vector.Y); - } - - static partial class Vector2I - { - /// Computes the dot product of two vectors. - public static T Dot(this Vector2I left, Vector2I right) - where T : IBinaryInteger => - left.X * right.X + left.Y * right.Y; - - /// Reflects a vector over a normal vector. - public static Vector2I Reflect(Vector2I vector, Vector2I normal) - where T : IBinaryInteger - { - T dot = vector.Dot(normal); - return vector - (normal * (dot + dot)); - } - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2I Sign(this Vector2I value) - where TSelf : IBinaryInteger => - new(TSelf.Sign(value.X), TSelf.Sign(value.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2I Max(this Vector2I x, Vector2I y) - where TSelf : IBinaryInteger => - new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2I Max(this Vector2I x, TSelf y) - where TSelf : IBinaryInteger => - new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2I MaxNumber(this Vector2I x, Vector2I y) - where TSelf : IBinaryInteger => - new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2I MaxNumber(this Vector2I x, TSelf y) - where TSelf : IBinaryInteger => - new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2I Min(this Vector2I x, Vector2I y) - where TSelf : IBinaryInteger => - new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2I Min(this Vector2I x, TSelf y) - where TSelf : IBinaryInteger => - new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2I MinNumber(this Vector2I x, Vector2I y) - where TSelf : IBinaryInteger => - new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2I MinNumber(this Vector2I x, TSelf y) - where TSelf : IBinaryInteger => - new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2I Clamp(this Vector2I value, Vector2I min, Vector2I max) - where TSelf : IBinaryInteger => - new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A single value provided for . - public static Vector2I Clamp(this Vector2I value, TSelf min, TSelf max) - where TSelf : IBinaryInteger => - new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2I CopySign(this Vector2I value, Vector2I sign) - where TSelf : IBinaryInteger => - new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2I CopySign(this Vector2I value, TSelf sign) - where TSelf : IBinaryInteger => - new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2I Abs(this Vector2I value) - where TSelf : IBinaryInteger => - new(TSelf.Abs(value.X), TSelf.Abs(value.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2I MaxMagnitude(this Vector2I x, Vector2I y) - where TSelf : IBinaryInteger => - new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2I MaxMagnitudeNumber(this Vector2I x, Vector2I y) - where TSelf : IBinaryInteger => - new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2I MinMagnitude(this Vector2I x, Vector2I y) - where TSelf : IBinaryInteger => - new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2I MinMagnitudeNumber(this Vector2I x, Vector2I y) - where TSelf : IBinaryInteger => - new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2I Log2(this Vector2I value) - where TSelf : IBinaryInteger => - new(TSelf.Log2(value.X), TSelf.Log2(value.Y)); - } -} diff --git a/sources/Maths/Maths/Vector3I.cs b/sources/Maths/Maths/Vector3D.cs similarity index 69% rename from sources/Maths/Maths/Vector3I.cs rename to sources/Maths/Maths/Vector3D.cs index 4141292c52..d1a2cdb784 100644 --- a/sources/Maths/Maths/Vector3I.cs +++ b/sources/Maths/Maths/Vector3D.cs @@ -12,19 +12,19 @@ namespace Silk.NET.Maths { /// A structure representing a 3D integer vector. - internal partial struct Vector3I + public partial struct Vector3D { /// Computes the cross product of this vector with another vector. - public Vector3I Cross(Vector3I other) => - new Vector3I( + public Vector3D Cross(Vector3D other) => + new Vector3D( (Y * other.Z) - (Z * other.Y), (Z * other.X) - (X * other.Z), (X * other.Y) - (Y * other.X) ); /// Computes the cross product of two vectors. - public static Vector3I Cross(Vector3I left, Vector3I right) => - new Vector3I( + public static Vector3D Cross(Vector3D left, Vector3D right) => + new Vector3D( (left.Y * right.Z) - (left.Z * right.Y), (left.Z * right.X) - (left.X * right.Z), (left.X * right.Y) - (left.Y * right.X) @@ -32,20 +32,20 @@ public static Vector3I Cross(Vector3I left, Vector3I right) => // Casts - /// Explicitly casts a to a . - public static explicit operator Vector3I(System.Numerics.Vector3 v) => - new Vector3I((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T))); + /// Explicitly casts a to a . + public static explicit operator Vector3D(System.Numerics.Vector3 v) => + new Vector3D((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T))); - /// Explicitly casts a to . - public static explicit operator System.Numerics.Vector3(Vector3I v) => + /// Explicitly casts a to . + public static explicit operator System.Numerics.Vector3(Vector3D v) => new System.Numerics.Vector3(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z)); - public static (Vector3I Quotient, Vector3I Remainder) DivRem(Vector3I left, Vector3I right) + public static (Vector3D Quotient, Vector3D Remainder) DivRem(Vector3D left, Vector3D right) { var (qX, rX) = T.DivRem(left.X, right.X); var (qY, rY) = T.DivRem(left.Y, right.Y); var (qZ, rZ) = T.DivRem(left.Z, right.Z); - return (new Vector3I(qX, qY, qZ), new Vector3I(rX, rY, rZ)); + return (new Vector3D(qX, qY, qZ), new Vector3D(rX, rY, rZ)); } } } diff --git a/sources/Maths/Maths/Vector3F.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs similarity index 75% rename from sources/Maths/Maths/Vector3F.gen.cs rename to sources/Maths/Maths/Vector3D.gen.cs index 2c0d24db9c..e894afc9a1 100644 --- a/sources/Maths/Maths/Vector3F.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -6,16 +6,16 @@ namespace Silk.NET.Maths using System.Runtime.InteropServices; using System.Text; - partial struct Vector3F : - IEquatable>, + public partial struct Vector3D : + IEquatable>, IReadOnlyList, IFormattable, - IParsable>, + IParsable>, ISpanFormattable, - ISpanParsable>, + ISpanParsable>, IUtf8SpanFormattable, - IUtf8SpanParsable> - where T : IFloatingPointIeee754 + IUtf8SpanParsable> + where T : INumberBase { /// The X component of the vector. public T X; @@ -27,16 +27,16 @@ partial struct Vector3F : public T Z; /// Initializes all components of the vector to the same value. - public Vector3F(T value) => (X, Y, Z) = (value, value, value); + public Vector3D(T value) => (X, Y, Z) = (value, value, value); /// Initializes the vector with individual component values. - public Vector3F(T x, T y, T z) => (X, Y, Z) = (x, y, z); + public Vector3D(T x, T y, T z) => (X, Y, Z) = (x, y, z); - /// Initializes the vector using a for the initial elements, and the specified component for the remainder. - public Vector3F(Vector2F other, T z) => (X, Y, Z) = (other.X, other.Y, z); + /// Initializes the vector using a for the initial elements, and the specified component for the remainder. + public Vector3D(Vector2D other, T z) => (X, Y, Z) = (other.X, other.Y, z); /// Initializes the vector from a span of 3 values. - public Vector3F(ReadOnlySpan values) + public Vector3D(ReadOnlySpan values) { if (values.Length != 3) throw new ArgumentException("Input span must contain exactly 3 elements.", nameof(values)); @@ -47,22 +47,22 @@ public Vector3F(ReadOnlySpan values) } /// Gets a vector whose 3 elements are equal to one. - public static Vector3F One => new(T.One); + public static Vector3D One => new(T.One); /// Returns a vector whose 3 elements are equal to zero. - public static Vector3F Zero => default; + public static Vector3D Zero => default; /// Gets the vector (1, 0, 0). - public static Vector3F UnitX => new(T.One, T.Zero, T.Zero); + public static Vector3D UnitX => new(T.One, T.Zero, T.Zero); /// Gets the vector (0, 1, 0). - public static Vector3F UnitY => new(T.Zero, T.One, T.Zero); + public static Vector3D UnitY => new(T.Zero, T.One, T.Zero); /// Gets the vector (0, 0, 1). - public static Vector3F UnitZ => new(T.Zero, T.Zero, T.One); + public static Vector3D UnitZ => new(T.Zero, T.Zero, T.One); /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => Vector3F.Dot(this, this); + public T LengthSquared => Vector3D.Dot(this, this); /// T IReadOnlyList.this[int index] => this[index]; @@ -142,14 +142,14 @@ public override string ToString() => public string ToString(string? format, IFormatProvider? formatProvider) => $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}, {Z.ToString(format, formatProvider)}>"; - /// Parses a string to a instance. - public static Vector3F Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + /// Parses a string to a instance. + public static Vector3D Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); - /// Parses a span to a instance. - public static Vector3F Parse(ReadOnlySpan s, IFormatProvider? provider) + /// Parses a span to a instance. + public static Vector3D Parse(ReadOnlySpan s, IFormatProvider? provider) { if (!TryParse(s, provider, out var result)) - throw new FormatException("Invalid format for Vector3F."); + throw new FormatException("Invalid format for Vector3D."); return result; } @@ -241,8 +241,8 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan return true; } - /// Tries to parse a span to a instance. - public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3F result) + /// Tries to parse a span to a instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3D result) { result = default; @@ -270,15 +270,15 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [Ma T.TryParse(ySpan, provider, out var y) && T.TryParse(zSpan, provider, out var z)) { - result = new Vector3F(x, y, z); + result = new Vector3D(x, y, z); return true; } return false; } - /// Parses a UTF-8 span to a instance. - public static Vector3F Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + /// Parses a UTF-8 span to a instance. + public static Vector3D Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) { int charCount = Encoding.UTF8.GetCharCount(utf8Text); Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; @@ -286,8 +286,8 @@ public static Vector3F Parse(ReadOnlySpan utf8Text, IFormatProvider? pr return Parse(charBuffer, provider); } - /// Tries to parse a UTF-8 span to a instance. - public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3F result) + /// Tries to parse a UTF-8 span to a instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3D result) { int charCount = Encoding.UTF8.GetCharCount(utf8Text); Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; @@ -295,31 +295,31 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid return TryParse(charBuffer, provider, out result); } - /// Tries to parse a string to a instance. - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3F result) => + /// Tries to parse a string to a instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3D result) => TryParse(s.AsSpan(), provider, out result); - /// Parses a span to a instance. - static Vector3F ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + /// Parses a span to a instance. + static Vector3D ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => Parse(s, provider); - /// Parses a string to a instance. - static Vector3F IParsable>.Parse(string s, IFormatProvider? provider) => + /// Parses a string to a instance. + static Vector3D IParsable>.Parse(string s, IFormatProvider? provider) => Parse(s, provider); - /// Tries to parse a span to a instance. - static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3F result) => + /// Tries to parse a span to a instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3D result) => TryParse(s, provider, out result); - /// Tries to parse a string to a instance. - static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3F result) => + /// Tries to parse a string to a instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3D result) => TryParse(s, provider, out result); /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. /// true if the given vectors are equal; false otherwise. - public static bool operator ==(Vector3F left, Vector3F right) => + public static bool operator ==(Vector3D left, Vector3D right) => left.X == right.X && left.Y == right.Y && left.Z == right.Z; @@ -328,13 +328,13 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm /// The first vector to compare. /// The second vector to compare. /// true if the given vectors are not equal; false otherwise. - public static bool operator !=(Vector3F left, Vector3F right) => !(left == right); + public static bool operator !=(Vector3D left, Vector3D right) => !(left == right); /// - public override bool Equals(object? obj) => obj is Vector3F other && Equals(other); + public override bool Equals(object? obj) => obj is Vector3D other && Equals(other); /// - public bool Equals(Vector3F other) => this == other; + public bool Equals(Vector3D other) => this == other; /// public override int GetHashCode() => HashCode.Combine(X, Y, Z); @@ -350,252 +350,263 @@ public void Deconstruct(out T x, out T y, out T z) z = Z; } - /// Implicitly casts a to a . - public static implicit operator Vector3F((T X, T Y, T Z) v) => + /// Converts the components of this vector to another type. + public Vector3D As() + where TOther : INumberBase => + new(TOther.CreateSaturating(X), TOther.CreateSaturating(Y), TOther.CreateSaturating(Z)); + + /// Implicitly casts a to a . + public static implicit operator Vector3D((T X, T Y, T Z) v) => new(v.X, v.Y, v.Z); - /// Implicitly casts a to a . - public static implicit operator (T X, T Y, T Z)(Vector3F v) => + /// Implicitly casts a to a . + public static implicit operator (T X, T Y, T Z)(Vector3D v) => (v.X, v.Y, v.Z); - public static Vector3F operator +(Vector3F vector) => + public static Vector3D operator +(Vector3D vector) => vector; - public static Vector3F operator -(Vector3F vector) => + public static Vector3D operator -(Vector3D vector) => new(-vector.X, -vector.Y, -vector.Z); - public static Vector3F operator +(Vector3F left, Vector3F right) => + public static Vector3D operator +(Vector3D left, Vector3D right) => new(left.X + right.X, left.Y + right.Y, left.Z + right.Z); - public static Vector3F operator -(Vector3F left, Vector3F right) => + public static Vector3D operator -(Vector3D left, Vector3D right) => new(left.X - right.X, left.Y - right.Y, left.Z - right.Z); - public static Vector3F operator *(Vector3F left, Vector3F right) => + public static Vector3D operator *(Vector3D left, Vector3D right) => new(left.X * right.X, left.Y * right.Y, left.Z * right.Z); - public static Vector3F operator /(Vector3F left, Vector3F right) => + public static Vector3D operator /(Vector3D left, Vector3D right) => new(left.X / right.X, left.Y / right.Y, left.Z / right.Z); - public static Vector3F operator %(Vector3F left, Vector3F right) => - new(left.X % right.X, left.Y % right.Y, left.Z % right.Z); - - public static Vector3F operator +(Vector3F vector, T scalar) => + public static Vector3D operator +(Vector3D vector, T scalar) => new(vector.X + scalar, vector.Y + scalar, vector.Z + scalar); - public static Vector3F operator -(Vector3F vector, T scalar) => + public static Vector3D operator -(Vector3D vector, T scalar) => new(vector.X - scalar, vector.Y - scalar, vector.Z - scalar); - public static Vector3F operator *(Vector3F vector, T scalar) => + public static Vector3D operator *(Vector3D vector, T scalar) => new(vector.X * scalar, vector.Y * scalar, vector.Z * scalar); - public static Vector3F operator *(T scalar, Vector3F vector) => + public static Vector3D operator *(T scalar, Vector3D vector) => new(scalar * vector.X, scalar * vector.Y, scalar * vector.Z); - public static Vector3F operator /(Vector3F vector, T scalar) => + public static Vector3D operator /(Vector3D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); - public static Vector3F operator %(Vector3F vector, T scalar) => - new(vector.X % scalar, vector.Y % scalar, vector.Z % scalar); - } - static partial class Vector3F + public static partial class Vector3D { /// Computes the dot product of two vectors. - public static T Dot(this Vector3F left, Vector3F right) - where T : IFloatingPointIeee754 => + public static T Dot(this Vector3D left, Vector3D right) + where T : INumberBase => left.X * right.X + left.Y * right.Y + left.Z * right.Z; /// Reflects a vector over a normal vector. - public static Vector3F Reflect(Vector3F vector, Vector3F normal) - where T : IFloatingPointIeee754 + public static Vector3D Reflect(Vector3D vector, Vector3D normal) + where T : INumberBase { T dot = vector.Dot(normal); return vector - (normal * (dot + dot)); } /// Computes the length of the vector. - public static T GetLength(this Vector3F vector) + public static T GetLength(this Vector3D vector) where T : IFloatingPointIeee754 => T.Sqrt(vector.LengthSquared); /// Normalizes a vector. - public static Vector3F Normalize(this Vector3F vector) + public static Vector3D Normalize(this Vector3D vector) where T : IFloatingPointIeee754 { T length = vector.GetLength(); - return length != T.Zero ? vector / length : Vector3F.Zero; + return length != T.Zero ? vector / length : Vector3D.Zero; } /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3I Sign(this Vector3F value) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Sign(this Vector3D value) + where TSelf : INumber => new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F Max(this Vector3F x, Vector3F y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Max(this Vector3D x, Vector3D y) + where TSelf : INumber => new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3F Max(this Vector3F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Max(this Vector3D x, TSelf y) + where TSelf : INumber => new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F MaxNumber(this Vector3F x, Vector3F y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D MaxNumber(this Vector3D x, Vector3D y) + where TSelf : INumber => new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3F MaxNumber(this Vector3F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D MaxNumber(this Vector3D x, TSelf y) + where TSelf : INumber => new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F Min(this Vector3F x, Vector3F y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Min(this Vector3D x, Vector3D y) + where TSelf : INumber => new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3F Min(this Vector3F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Min(this Vector3D x, TSelf y) + where TSelf : INumber => new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F MinNumber(this Vector3F x, Vector3F y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D MinNumber(this Vector3D x, Vector3D y) + where TSelf : INumber => new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3F MinNumber(this Vector3F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D MinNumber(this Vector3D x, TSelf y) + where TSelf : INumber => new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F Clamp(this Vector3F value, Vector3F min, Vector3F max) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Clamp(this Vector3D value, Vector3D min, Vector3D max) + where TSelf : INumber => new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector3F Clamp(this Vector3F value, TSelf min, TSelf max) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Clamp(this Vector3D value, TSelf min, TSelf max) + where TSelf : INumber => new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F CopySign(this Vector3F value, Vector3F sign) - where TSelf : IFloatingPointIeee754 => + public static Vector3D CopySign(this Vector3D value, Vector3D sign) + where TSelf : INumber => new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3F CopySign(this Vector3F value, TSelf sign) - where TSelf : IFloatingPointIeee754 => + public static Vector3D CopySign(this Vector3D value, TSelf sign) + where TSelf : INumber => new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Abs(this Vector3F value) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Abs(this Vector3D value) + where TSelf : INumberBase => new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F MaxMagnitude(this Vector3F x, Vector3F y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D MaxMagnitude(this Vector3D x, Vector3D y) + where TSelf : INumberBase => new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F MaxMagnitudeNumber(this Vector3F x, Vector3F y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D MaxMagnitudeNumber(this Vector3D x, Vector3D y) + where TSelf : INumberBase => new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F MinMagnitude(this Vector3F x, Vector3F y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D MinMagnitude(this Vector3D x, Vector3D y) + where TSelf : INumberBase => new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F MinMagnitudeNumber(this Vector3F x, Vector3F y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D MinMagnitudeNumber(this Vector3D x, Vector3D y) + where TSelf : INumberBase => new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D PopCount(this Vector3D value) + where TSelf : IBinaryInteger => + new(TSelf.PopCount(value.X), TSelf.PopCount(value.Y), TSelf.PopCount(value.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D TrailingZeroCount(this Vector3D value) + where TSelf : IBinaryInteger => + new(TSelf.TrailingZeroCount(value.X), TSelf.TrailingZeroCount(value.Y), TSelf.TrailingZeroCount(value.Z)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Ceiling(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Ceiling(this Vector3D x) + where TSelf : IFloatingPoint => new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y), TSelf.Ceiling(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Floor(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Floor(this Vector3D x) + where TSelf : IFloatingPoint => new(TSelf.Floor(x.X), TSelf.Floor(x.Y), TSelf.Floor(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Round(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Round(this Vector3D x) + where TSelf : IFloatingPoint => new(TSelf.Round(x.X), TSelf.Round(x.Y), TSelf.Round(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector3F Round(this Vector3F x, int digits, MidpointRounding mode) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Round(this Vector3D x, int digits, MidpointRounding mode) + where TSelf : IFloatingPoint => new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode), TSelf.Round(x.Z, digits, mode)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Truncate(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Truncate(this Vector3D x) + where TSelf : IFloatingPoint => new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y), TSelf.Truncate(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F Atan2(this Vector3F y, Vector3F x) + public static Vector3D Atan2(this Vector3D y, Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y), TSelf.Atan2(y.Z, x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F Atan2Pi(this Vector3F y, Vector3F x) + public static Vector3D Atan2Pi(this Vector3D y, Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y), TSelf.Atan2Pi(y.Z, x.Z)); @@ -603,19 +614,19 @@ public static Vector3F Atan2Pi(this Vector3F y, Vector3FA vector whose members will be provided for . /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3F Lerp(this Vector3F value1, Vector3F value2, TSelf amount) + public static Vector3D Lerp(this Vector3D value1, Vector3D value2, TSelf amount) where TSelf : IFloatingPointIeee754 => new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount), TSelf.Lerp(value1.Z, value2.Z, amount)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F BitDecrement(this Vector3F x) + public static Vector3D BitDecrement(this Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y), TSelf.BitDecrement(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F BitIncrement(this Vector3F x) + public static Vector3D BitIncrement(this Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y), TSelf.BitIncrement(x.Z)); @@ -623,7 +634,7 @@ public static Vector3F BitIncrement(this Vector3F x) /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F FusedMultiplyAdd(this Vector3F left, Vector3F right, Vector3F addend) + public static Vector3D FusedMultiplyAdd(this Vector3D left, Vector3D right, Vector3D addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend.Z)); @@ -631,300 +642,300 @@ public static Vector3F FusedMultiplyAdd(this Vector3F left, /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector3F FusedMultiplyAdd(this Vector3F left, TSelf right, TSelf addend) + public static Vector3D FusedMultiplyAdd(this Vector3D left, TSelf right, TSelf addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend), TSelf.FusedMultiplyAdd(left.Z, right, addend)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F Ieee754Remainder(this Vector3F left, Vector3F right) + public static Vector3D Ieee754Remainder(this Vector3D left, Vector3D right) where TSelf : IFloatingPointIeee754 => new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y), TSelf.Ieee754Remainder(left.Z, right.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3F Ieee754Remainder(this Vector3F left, TSelf right) + public static Vector3D Ieee754Remainder(this Vector3D left, TSelf right) where TSelf : IFloatingPointIeee754 => new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right), TSelf.Ieee754Remainder(left.Z, right)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3I ILogB(this Vector3F x) + public static Vector3D ILogB(this Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y), TSelf.ILogB(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F ReciprocalEstimate(this Vector3F x) + public static Vector3D ReciprocalEstimate(this Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y), TSelf.ReciprocalEstimate(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F ReciprocalSqrtEstimate(this Vector3F x) + public static Vector3D ReciprocalSqrtEstimate(this Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y), TSelf.ReciprocalSqrtEstimate(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F ScaleB(this Vector3F x, Vector3I n) + public static Vector3D ScaleB(this Vector3D x, Vector3D n) where TSelf : IFloatingPointIeee754 => new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y), TSelf.ScaleB(x.Z, n.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3F ScaleB(this Vector3F x, int n) + public static Vector3D ScaleB(this Vector3D x, int n) where TSelf : IFloatingPointIeee754 => new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n), TSelf.ScaleB(x.Z, n)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F Pow(this Vector3F x, Vector3F y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Pow(this Vector3D x, Vector3D y) + where TSelf : IPowerFunctions => new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y), TSelf.Pow(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3F Pow(this Vector3F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Pow(this Vector3D x, TSelf y) + where TSelf : IPowerFunctions => new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y), TSelf.Pow(x.Z, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Cbrt(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Cbrt(this Vector3D x) + where TSelf : IRootFunctions => new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y), TSelf.Cbrt(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Sqrt(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Sqrt(this Vector3D x) + where TSelf : IRootFunctions => new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y), TSelf.Sqrt(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3F RootN(this Vector3F x, int n) - where TSelf : IFloatingPointIeee754 => + public static Vector3D RootN(this Vector3D x, int n) + where TSelf : IRootFunctions => new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n), TSelf.RootN(x.Z, n)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F RootN(this Vector3F x, Vector3I n) - where TSelf : IFloatingPointIeee754 => + public static Vector3D RootN(this Vector3D x, Vector3D n) + where TSelf : IRootFunctions => new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y), TSelf.RootN(x.Z, n.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3F Hypot(this Vector3F x, Vector3F y) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Hypot(this Vector3D x, Vector3D y) + where TSelf : IRootFunctions => new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y), TSelf.Hypot(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Log(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Log(this Vector3D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3F Log(this Vector3F x, TSelf newBase) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Log(this Vector3D x, TSelf newBase) + where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase), TSelf.Log(x.Z, newBase)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F LogP1(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D LogP1(this Vector3D x) + where TSelf : ILogarithmicFunctions => new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Log2(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Log2(this Vector3D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Log2P1(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Log2P1(this Vector3D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Log10(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Log10(this Vector3D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Log10P1(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Log10P1(this Vector3D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Exp(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Exp(this Vector3D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F ExpM1(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D ExpM1(this Vector3D x) + where TSelf : IExponentialFunctions => new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Exp2(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Exp2(this Vector3D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Exp2M1(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Exp2M1(this Vector3D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Exp10(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Exp10(this Vector3D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Exp10M1(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Exp10M1(this Vector3D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Acos(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Acos(this Vector3D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Acos(x.X), TSelf.Acos(x.Y), TSelf.Acos(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F AcosPi(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D AcosPi(this Vector3D x) + where TSelf : ITrigonometricFunctions => new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y), TSelf.AcosPi(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Asin(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Asin(this Vector3D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Asin(x.X), TSelf.Asin(x.Y), TSelf.Asin(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F AsinPi(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D AsinPi(this Vector3D x) + where TSelf : ITrigonometricFunctions => new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y), TSelf.AsinPi(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Atan(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Atan(this Vector3D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Atan(x.X), TSelf.Atan(x.Y), TSelf.Atan(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F AtanPi(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D AtanPi(this Vector3D x) + where TSelf : ITrigonometricFunctions => new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y), TSelf.AtanPi(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Cos(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Cos(this Vector3D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Cos(x.X), TSelf.Cos(x.Y), TSelf.Cos(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F CosPi(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D CosPi(this Vector3D x) + where TSelf : ITrigonometricFunctions => new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y), TSelf.CosPi(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Sin(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Sin(this Vector3D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Sin(x.X), TSelf.Sin(x.Y), TSelf.Sin(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F SinPi(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D SinPi(this Vector3D x) + where TSelf : ITrigonometricFunctions => new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y), TSelf.SinPi(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Tan(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Tan(this Vector3D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Tan(x.X), TSelf.Tan(x.Y), TSelf.Tan(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F TanPi(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D TanPi(this Vector3D x) + where TSelf : ITrigonometricFunctions => new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y), TSelf.TanPi(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F DegreesToRadians(this Vector3F degrees) - where TSelf : IFloatingPointIeee754 => + public static Vector3D DegreesToRadians(this Vector3D degrees) + where TSelf : ITrigonometricFunctions => new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y), TSelf.DegreesToRadians(degrees.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F RadiansToDegrees(this Vector3F radians) - where TSelf : IFloatingPointIeee754 => + public static Vector3D RadiansToDegrees(this Vector3D radians) + where TSelf : ITrigonometricFunctions => new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y), TSelf.RadiansToDegrees(radians.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Acosh(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Acosh(this Vector3D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y), TSelf.Acosh(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Asinh(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Asinh(this Vector3D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y), TSelf.Asinh(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Atanh(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Atanh(this Vector3D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y), TSelf.Atanh(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Cosh(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Cosh(this Vector3D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y), TSelf.Cosh(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Sinh(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Sinh(this Vector3D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y), TSelf.Sinh(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3F Tanh(this Vector3F x) - where TSelf : IFloatingPointIeee754 => + public static Vector3D Tanh(this Vector3D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y), TSelf.Tanh(x.Z)); } } diff --git a/sources/Maths/Maths/Vector3I.gen.cs b/sources/Maths/Maths/Vector3I.gen.cs deleted file mode 100644 index 197cb262d2..0000000000 --- a/sources/Maths/Maths/Vector3I.gen.cs +++ /dev/null @@ -1,581 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Collections; - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - using System.Runtime.InteropServices; - using System.Text; - - partial struct Vector3I : - IEquatable>, - IReadOnlyList, - IFormattable, - IParsable>, - ISpanFormattable, - ISpanParsable>, - IUtf8SpanFormattable, - IUtf8SpanParsable> - where T : IBinaryInteger - { - /// The X component of the vector. - public T X; - - /// The Y component of the vector. - public T Y; - - /// The Z component of the vector. - public T Z; - - /// Initializes all components of the vector to the same value. - public Vector3I(T value) => (X, Y, Z) = (value, value, value); - - /// Initializes the vector with individual component values. - public Vector3I(T x, T y, T z) => (X, Y, Z) = (x, y, z); - - /// Initializes the vector using a for the initial elements, and the specified component for the remainder. - public Vector3I(Vector2I other, T z) => (X, Y, Z) = (other.X, other.Y, z); - - /// Initializes the vector from a span of 3 values. - public Vector3I(ReadOnlySpan values) - { - if (values.Length != 3) - throw new ArgumentException("Input span must contain exactly 3 elements.", nameof(values)); - - X = values[0]; - Y = values[1]; - Z = values[2]; - } - - /// Gets a vector whose 3 elements are equal to one. - public static Vector3I One => new(T.One); - - /// Returns a vector whose 3 elements are equal to zero. - public static Vector3I Zero => default; - - /// Gets the vector (1, 0, 0). - public static Vector3I UnitX => new(T.One, T.Zero, T.Zero); - - /// Gets the vector (0, 1, 0). - public static Vector3I UnitY => new(T.Zero, T.One, T.Zero); - - /// Gets the vector (0, 0, 1). - public static Vector3I UnitZ => new(T.Zero, T.Zero, T.One); - - /// Gets a vector with all bits set for each component. - public static Vector3I AllBitsSet => new Vector3I(T.AllBitsSet, T.AllBitsSet, T.AllBitsSet); - - /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => Vector3I.Dot(this, this); - - /// - T IReadOnlyList.this[int index] => this[index]; - - ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z. - [UnscopedRef] - public ref T this[int index] - { - get - { - switch (index) - { - case 0: - return ref X; - case 1: - return ref Y; - case 2: - return ref Z; - } - - throw new ArgumentOutOfRangeException(nameof(index)); - } - } - - /// The number of elements in the vector. - public int Count => 3; - - /// - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - - /// Returns an enumerator that iterates through the vector components. - public IEnumerator GetEnumerator() - { - yield return X; - yield return Y; - yield return Z; - } - - /// Copies the components of the vector to the specified array starting at index 0. - public void CopyTo(T[] array) => CopyTo(array, 0); - - /// Copies the components of the vector to the specified array starting at the given index. - public void CopyTo(T[] array, int startIndex) - { - if (array == null) - throw new ArgumentNullException(nameof(array)); - if (startIndex < 0 || startIndex + 3 > array.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - - array[startIndex] = X; - array[startIndex + 1] = Y; - array[startIndex + 2] = Z; - } - - /// Copies the components of the vector to the specified span starting at index 0. - public void CopyTo(Span span) => CopyTo(span, 0); - - /// Copies the components of the vector to the specified span starting at the given index. - public void CopyTo(Span span, int startIndex) - { - if (startIndex < 0 || startIndex + 3 > span.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - - span[startIndex] = X; - span[startIndex + 1] = Y; - span[startIndex + 2] = Z; - } - - /// Returns a span over the vector components. - public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 3); - - /// Formats the vector as a string. - public override string ToString() => - $"<{X}, {Y}, {Z}>"; - - /// Formats the vector as a string using the specified format and format provider. - public string ToString(string? format, IFormatProvider? formatProvider) => - $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}, {Z.ToString(format, formatProvider)}>"; - - /// Parses a string to a instance. - public static Vector3I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); - - /// Parses a span to a instance. - public static Vector3I Parse(ReadOnlySpan s, IFormatProvider? provider) - { - if (!TryParse(s, provider, out var result)) - throw new FormatException("Invalid format for Vector3I."); - - return result; - } - - /// Formats the vector as a UTF-8 string using the specified format and format provider. - public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) - { - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - Span zBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider)|| - !Y.TryFormat(yBuffer, out int yChars, format, provider)|| - !Z.TryFormat(zBuffer, out int zChars, format, provider)) - { - bytesWritten = 0; - return false; - } - - int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + - Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + - Encoding.UTF8.GetByteCount(zBuffer[..zChars]) + - Encoding.UTF8.GetByteCount("<, >"); - - if (utf8Destination.Length < estimatedSize) - { - bytesWritten = 0; - return false; - } - - int totalBytes = 0; - - totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(zBuffer[..zChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); - - bytesWritten = totalBytes; - return true; - } - - /// Formats the vector as a string using the specified format and format provider. - public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - Span zBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider) || - !Y.TryFormat(yBuffer, out int yChars, format, provider) || - !Z.TryFormat(zBuffer, out int zChars, format, provider)) - { - charsWritten = 0; - return false; - } - - int requiredLength = 1 + xChars + 2 + yChars + 2 + zChars + 1; - - if (destination.Length < requiredLength) - { - charsWritten = 0; - return false; - } - - int pos = 0; - destination[pos++] = '<'; - - xBuffer[..xChars].CopyTo(destination[pos..]); - pos += xChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - yBuffer[..yChars].CopyTo(destination[pos..]); - pos += yChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - zBuffer[..zChars].CopyTo(destination[pos..]); - pos += zChars; - - destination[pos++] = '>'; - - charsWritten = pos; - return true; - } - - /// Tries to parse a span to a instance. - public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) - { - result = default; - - s = s.Trim(); - if (s.Length < 6 || s[0] != '<' || s[^1] != '>') - return false; - - s = s[1..^1]; // Remove < and > - - int commaX = s.IndexOf(','); - if (commaX < 0) - return false; - - ReadOnlySpan remainder1 = s.Slice(commaX + 1); - int commaYRelative = remainder1.IndexOf(','); - if (commaYRelative < 0) - return false; - int commaY = commaX + 1 + commaYRelative; - - ReadOnlySpan xSpan = s[..commaX].Trim(); - ReadOnlySpan ySpan = s[(commaX + 1)..commaY].Trim(); - ReadOnlySpan zSpan = s[(commaY + 1)..].Trim(); - - if (T.TryParse(xSpan, provider, out var x) && - T.TryParse(ySpan, provider, out var y) && - T.TryParse(zSpan, provider, out var z)) - { - result = new Vector3I(x, y, z); - return true; - } - - return false; - } - - /// Parses a UTF-8 span to a instance. - public static Vector3I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return Parse(charBuffer, provider); - } - - /// Tries to parse a UTF-8 span to a instance. - public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return TryParse(charBuffer, provider, out result); - } - - /// Tries to parse a string to a instance. - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => - TryParse(s.AsSpan(), provider, out result); - - /// Parses a span to a instance. - static Vector3I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => - Parse(s, provider); - - /// Parses a string to a instance. - static Vector3I IParsable>.Parse(string s, IFormatProvider? provider) => - Parse(s, provider); - - /// Tries to parse a span to a instance. - static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => - TryParse(s, provider, out result); - - /// Tries to parse a string to a instance. - static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector3I result) => - TryParse(s, provider, out result); - - /// Returns a boolean indicating whether the given two vectors are equal. - /// The first vector to compare. - /// The second vector to compare. - /// true if the given vectors are equal; false otherwise. - public static bool operator ==(Vector3I left, Vector3I right) => - left.X == right.X && - left.Y == right.Y && - left.Z == right.Z; - - /// Returns a boolean indicating whether the given two vectors are not equal. - /// The first vector to compare. - /// The second vector to compare. - /// true if the given vectors are not equal; false otherwise. - public static bool operator !=(Vector3I left, Vector3I right) => !(left == right); - - /// - public override bool Equals(object? obj) => obj is Vector3I other && Equals(other); - - /// - public bool Equals(Vector3I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(X, Y, Z); - - /// Desconstructs a vector into its components. - /// The X component. - /// The Y component. - /// The Z component. - public void Deconstruct(out T x, out T y, out T z) - { - x = X; - y = Y; - z = Z; - } - - /// Implicitly casts a to a . - public static implicit operator Vector3I((T X, T Y, T Z) v) => - new(v.X, v.Y, v.Z); - - /// Implicitly casts a to a . - public static implicit operator (T X, T Y, T Z)(Vector3I v) => - (v.X, v.Y, v.Z); - - public static Vector3I operator +(Vector3I vector) => - vector; - - public static Vector3I operator -(Vector3I vector) => - new(-vector.X, -vector.Y, -vector.Z); - - public static Vector3I operator +(Vector3I left, Vector3I right) => - new(left.X + right.X, left.Y + right.Y, left.Z + right.Z); - - public static Vector3I operator -(Vector3I left, Vector3I right) => - new(left.X - right.X, left.Y - right.Y, left.Z - right.Z); - - public static Vector3I operator *(Vector3I left, Vector3I right) => - new(left.X * right.X, left.Y * right.Y, left.Z * right.Z); - - public static Vector3I operator /(Vector3I left, Vector3I right) => - new(left.X / right.X, left.Y / right.Y, left.Z / right.Z); - - public static Vector3I operator %(Vector3I left, Vector3I right) => - new(left.X % right.X, left.Y % right.Y, left.Z % right.Z); - - public static Vector3I operator +(Vector3I vector, T scalar) => - new(vector.X + scalar, vector.Y + scalar, vector.Z + scalar); - - public static Vector3I operator -(Vector3I vector, T scalar) => - new(vector.X - scalar, vector.Y - scalar, vector.Z - scalar); - - public static Vector3I operator *(Vector3I vector, T scalar) => - new(vector.X * scalar, vector.Y * scalar, vector.Z * scalar); - - public static Vector3I operator *(T scalar, Vector3I vector) => - new(scalar * vector.X, scalar * vector.Y, scalar * vector.Z); - - public static Vector3I operator /(Vector3I vector, T scalar) => - new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); - - public static Vector3I operator %(Vector3I vector, T scalar) => - new(vector.X % scalar, vector.Y % scalar, vector.Z % scalar); - - public static Vector3I operator ~(Vector3I vector) => - new Vector3I(~vector.X, ~vector.Y, ~vector.Z); - - public static Vector3I operator &(Vector3I left, Vector3I right) => - new Vector3I(left.X & right.X, left.Y & right.Y, left.Z & right.Z); - - public static Vector3I operator |(Vector3I left, Vector3I right) => - new Vector3I(left.X | right.X, left.Y | right.Y, left.Z | right.Z); - - public static Vector3I operator ^(Vector3I left, Vector3I right) => - new Vector3I(left.X ^ right.X, left.Y ^ right.Y, left.Z ^ right.Z); - - public static Vector3I operator &(Vector3I vector, T scalar) => - new Vector3I(vector.X & scalar, vector.Y & scalar, vector.Z & scalar); - - public static Vector3I operator &(T scalar, Vector3I vector) => - new Vector3I(scalar & vector.X, scalar & vector.Y, scalar & vector.Z); - - public static Vector3I operator |(Vector3I vector, T scalar) => - new Vector3I(vector.X | scalar, vector.Y | scalar, vector.Z | scalar); - - public static Vector3I operator |(T scalar, Vector3I vector) => - new Vector3I(scalar | vector.X, scalar | vector.Y, scalar | vector.Z); - - public static Vector3I operator ^(Vector3I vector, T scalar) => - new Vector3I(vector.X ^ scalar, vector.Y ^ scalar, vector.Z ^ scalar); - - public static Vector3I operator ^(T scalar, Vector3I vector) => - new Vector3I(scalar ^ vector.X, scalar ^ vector.Y, scalar ^ vector.Z); - } - - static partial class Vector3I - { - /// Computes the dot product of two vectors. - public static T Dot(this Vector3I left, Vector3I right) - where T : IBinaryInteger => - left.X * right.X + left.Y * right.Y + left.Z * right.Z; - - /// Reflects a vector over a normal vector. - public static Vector3I Reflect(Vector3I vector, Vector3I normal) - where T : IBinaryInteger - { - T dot = vector.Dot(normal); - return vector - (normal * (dot + dot)); - } - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3I Sign(this Vector3I value) - where TSelf : IBinaryInteger => - new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3I Max(this Vector3I x, Vector3I y) - where TSelf : IBinaryInteger => - new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3I Max(this Vector3I x, TSelf y) - where TSelf : IBinaryInteger => - new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3I MaxNumber(this Vector3I x, Vector3I y) - where TSelf : IBinaryInteger => - new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3I MaxNumber(this Vector3I x, TSelf y) - where TSelf : IBinaryInteger => - new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3I Min(this Vector3I x, Vector3I y) - where TSelf : IBinaryInteger => - new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3I Min(this Vector3I x, TSelf y) - where TSelf : IBinaryInteger => - new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3I MinNumber(this Vector3I x, Vector3I y) - where TSelf : IBinaryInteger => - new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3I MinNumber(this Vector3I x, TSelf y) - where TSelf : IBinaryInteger => - new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3I Clamp(this Vector3I value, Vector3I min, Vector3I max) - where TSelf : IBinaryInteger => - new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A single value provided for . - public static Vector3I Clamp(this Vector3I value, TSelf min, TSelf max) - where TSelf : IBinaryInteger => - new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3I CopySign(this Vector3I value, Vector3I sign) - where TSelf : IBinaryInteger => - new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3I CopySign(this Vector3I value, TSelf sign) - where TSelf : IBinaryInteger => - new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3I Abs(this Vector3I value) - where TSelf : IBinaryInteger => - new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3I MaxMagnitude(this Vector3I x, Vector3I y) - where TSelf : IBinaryInteger => - new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3I MaxMagnitudeNumber(this Vector3I x, Vector3I y) - where TSelf : IBinaryInteger => - new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3I MinMagnitude(this Vector3I x, Vector3I y) - where TSelf : IBinaryInteger => - new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3I MinMagnitudeNumber(this Vector3I x, Vector3I y) - where TSelf : IBinaryInteger => - new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3I Log2(this Vector3I value) - where TSelf : IBinaryInteger => - new(TSelf.Log2(value.X), TSelf.Log2(value.Y), TSelf.Log2(value.Z)); - } -} diff --git a/sources/Maths/Maths/Vector4I.cs b/sources/Maths/Maths/Vector4D.cs similarity index 69% rename from sources/Maths/Maths/Vector4I.cs rename to sources/Maths/Maths/Vector4D.cs index 3b7442adbc..a50f79549d 100644 --- a/sources/Maths/Maths/Vector4I.cs +++ b/sources/Maths/Maths/Vector4D.cs @@ -11,25 +11,25 @@ namespace Silk.NET.Maths { /// A structure representing a 4D integer vector. - internal partial struct Vector4I + public partial struct Vector4D { // Casts - /// Explicitly casts a System.Numerics.Vector4 to a Vector4I. - public static explicit operator Vector4I(System.Numerics.Vector4 v) => - new Vector4I((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T)), (T)Convert.ChangeType(v.W, typeof(T))); + /// Explicitly casts a System.Numerics.Vector4 to a Vector4D. + public static explicit operator Vector4D(System.Numerics.Vector4 v) => + new Vector4D((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T)), (T)Convert.ChangeType(v.W, typeof(T))); - /// Explicitly casts a Vector4I to System.Numerics.Vector4. - public static explicit operator System.Numerics.Vector4(Vector4I v) => + /// Explicitly casts a Vector4D to System.Numerics.Vector4. + public static explicit operator System.Numerics.Vector4(Vector4D v) => new System.Numerics.Vector4(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z), Convert.ToSingle(v.W)); - public static (Vector4I Quotient, Vector4I Remainder) DivRem(Vector4I left, Vector4I right) + public static (Vector4D Quotient, Vector4D Remainder) DivRem(Vector4D left, Vector4D right) { var (qX, rX) = T.DivRem(left.X, right.X); var (qY, rY) = T.DivRem(left.Y, right.Y); var (qZ, rZ) = T.DivRem(left.Z, right.Z); var (qW, rW) = T.DivRem(left.W, right.W); - return (new Vector4I(qX, qY, qZ, qW), new Vector4I(rX, rY, rZ, rW)); + return (new Vector4D(qX, qY, qZ, qW), new Vector4D(rX, rY, rZ, rW)); } } } diff --git a/sources/Maths/Maths/Vector4F.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs similarity index 76% rename from sources/Maths/Maths/Vector4F.gen.cs rename to sources/Maths/Maths/Vector4D.gen.cs index cd0dd8a87d..1cecb3c459 100644 --- a/sources/Maths/Maths/Vector4F.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -6,16 +6,16 @@ namespace Silk.NET.Maths using System.Runtime.InteropServices; using System.Text; - partial struct Vector4F : - IEquatable>, + public partial struct Vector4D : + IEquatable>, IReadOnlyList, IFormattable, - IParsable>, + IParsable>, ISpanFormattable, - ISpanParsable>, + ISpanParsable>, IUtf8SpanFormattable, - IUtf8SpanParsable> - where T : IFloatingPointIeee754 + IUtf8SpanParsable> + where T : INumberBase { /// The X component of the vector. public T X; @@ -30,19 +30,19 @@ partial struct Vector4F : public T W; /// Initializes all components of the vector to the same value. - public Vector4F(T value) => (X, Y, Z, W) = (value, value, value, value); + public Vector4D(T value) => (X, Y, Z, W) = (value, value, value, value); /// Initializes the vector with individual component values. - public Vector4F(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); + public Vector4D(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); - /// Initializes the vector using a for the initial elements, and the specified components for the remainder. - public Vector4F(Vector2F other, T z, T w) => (X, Y, Z, W) = (other.X, other.Y, z, w); + /// Initializes the vector using a for the initial elements, and the specified components for the remainder. + public Vector4D(Vector2D other, T z, T w) => (X, Y, Z, W) = (other.X, other.Y, z, w); - /// Initializes the vector using a for the initial elements, and the specified component for the remainder. - public Vector4F(Vector3F other, T w) => (X, Y, Z, W) = (other.X, other.Y, other.Z, w); + /// Initializes the vector using a for the initial elements, and the specified component for the remainder. + public Vector4D(Vector3D other, T w) => (X, Y, Z, W) = (other.X, other.Y, other.Z, w); /// Initializes the vector from a span of 4 values. - public Vector4F(ReadOnlySpan values) + public Vector4D(ReadOnlySpan values) { if (values.Length != 4) throw new ArgumentException("Input span must contain exactly 4 elements.", nameof(values)); @@ -54,25 +54,25 @@ public Vector4F(ReadOnlySpan values) } /// Gets a vector whose 4 elements are equal to one. - public static Vector4F One => new(T.One); + public static Vector4D One => new(T.One); /// Returns a vector whose 4 elements are equal to zero. - public static Vector4F Zero => default; + public static Vector4D Zero => default; /// Gets the vector (1, 0, 0, 0). - public static Vector4F UnitX => new(T.One, T.Zero, T.Zero, T.Zero); + public static Vector4D UnitX => new(T.One, T.Zero, T.Zero, T.Zero); /// Gets the vector (0, 1, 0, 0). - public static Vector4F UnitY => new(T.Zero, T.One, T.Zero, T.Zero); + public static Vector4D UnitY => new(T.Zero, T.One, T.Zero, T.Zero); /// Gets the vector (0, 0, 1, 0). - public static Vector4F UnitZ => new(T.Zero, T.Zero, T.One, T.Zero); + public static Vector4D UnitZ => new(T.Zero, T.Zero, T.One, T.Zero); /// Gets the vector (0, 0, 0, 1). - public static Vector4F UnitW => new(T.Zero, T.Zero, T.Zero, T.One); + public static Vector4D UnitW => new(T.Zero, T.Zero, T.Zero, T.One); /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => Vector4F.Dot(this, this); + public T LengthSquared => Vector4D.Dot(this, this); /// T IReadOnlyList.this[int index] => this[index]; @@ -157,14 +157,14 @@ public override string ToString() => public string ToString(string? format, IFormatProvider? formatProvider) => $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}, {Z.ToString(format, formatProvider)}, {W.ToString(format, formatProvider)}>"; - /// Parses a string to a instance. - public static Vector4F Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); + /// Parses a string to a instance. + public static Vector4D Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); - /// Parses a span to a instance. - public static Vector4F Parse(ReadOnlySpan s, IFormatProvider? provider) + /// Parses a span to a instance. + public static Vector4D Parse(ReadOnlySpan s, IFormatProvider? provider) { if (!TryParse(s, provider, out var result)) - throw new FormatException("Invalid format for Vector4F."); + throw new FormatException("Invalid format for Vector4D."); return result; } @@ -269,8 +269,8 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan return true; } - /// Tries to parse a span to a instance. - public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4F result) + /// Tries to parse a span to a instance. + public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4D result) { result = default; @@ -306,15 +306,15 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [Ma T.TryParse(zSpan, provider, out var z) && T.TryParse(wSpan, provider, out var w)) { - result = new Vector4F(x, y, z, w); + result = new Vector4D(x, y, z, w); return true; } return false; } - /// Parses a UTF-8 span to a instance. - public static Vector4F Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) + /// Parses a UTF-8 span to a instance. + public static Vector4D Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) { int charCount = Encoding.UTF8.GetCharCount(utf8Text); Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; @@ -322,8 +322,8 @@ public static Vector4F Parse(ReadOnlySpan utf8Text, IFormatProvider? pr return Parse(charBuffer, provider); } - /// Tries to parse a UTF-8 span to a instance. - public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4F result) + /// Tries to parse a UTF-8 span to a instance. + public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4D result) { int charCount = Encoding.UTF8.GetCharCount(utf8Text); Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; @@ -331,31 +331,31 @@ public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provid return TryParse(charBuffer, provider, out result); } - /// Tries to parse a string to a instance. - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4F result) => + /// Tries to parse a string to a instance. + public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4D result) => TryParse(s.AsSpan(), provider, out result); - /// Parses a span to a instance. - static Vector4F ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => + /// Parses a span to a instance. + static Vector4D ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => Parse(s, provider); - /// Parses a string to a instance. - static Vector4F IParsable>.Parse(string s, IFormatProvider? provider) => + /// Parses a string to a instance. + static Vector4D IParsable>.Parse(string s, IFormatProvider? provider) => Parse(s, provider); - /// Tries to parse a span to a instance. - static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4F result) => + /// Tries to parse a span to a instance. + static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4D result) => TryParse(s, provider, out result); - /// Tries to parse a string to a instance. - static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4F result) => + /// Tries to parse a string to a instance. + static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4D result) => TryParse(s, provider, out result); /// Returns a boolean indicating whether the given two vectors are equal. /// The first vector to compare. /// The second vector to compare. /// true if the given vectors are equal; false otherwise. - public static bool operator ==(Vector4F left, Vector4F right) => + public static bool operator ==(Vector4D left, Vector4D right) => left.X == right.X && left.Y == right.Y && left.Z == right.Z && @@ -365,13 +365,13 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm /// The first vector to compare. /// The second vector to compare. /// true if the given vectors are not equal; false otherwise. - public static bool operator !=(Vector4F left, Vector4F right) => !(left == right); + public static bool operator !=(Vector4D left, Vector4D right) => !(left == right); /// - public override bool Equals(object? obj) => obj is Vector4F other && Equals(other); + public override bool Equals(object? obj) => obj is Vector4D other && Equals(other); /// - public bool Equals(Vector4F other) => this == other; + public bool Equals(Vector4D other) => this == other; /// public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); @@ -389,252 +389,263 @@ public void Deconstruct(out T x, out T y, out T z, out T w) w = W; } - /// Implicitly casts a to a . - public static implicit operator Vector4F((T X, T Y, T Z, T W) v) => + /// Converts the components of this vector to another type. + public Vector4D As() + where TOther : INumberBase => + new(TOther.CreateSaturating(X), TOther.CreateSaturating(Y), TOther.CreateSaturating(Z), TOther.CreateSaturating(W)); + + /// Implicitly casts a to a . + public static implicit operator Vector4D((T X, T Y, T Z, T W) v) => new(v.X, v.Y, v.Z, v.W); - /// Implicitly casts a to a . - public static implicit operator (T X, T Y, T Z, T W)(Vector4F v) => + /// Implicitly casts a to a . + public static implicit operator (T X, T Y, T Z, T W)(Vector4D v) => (v.X, v.Y, v.Z, v.W); - public static Vector4F operator +(Vector4F vector) => + public static Vector4D operator +(Vector4D vector) => vector; - public static Vector4F operator -(Vector4F vector) => + public static Vector4D operator -(Vector4D vector) => new(-vector.X, -vector.Y, -vector.Z, -vector.W); - public static Vector4F operator +(Vector4F left, Vector4F right) => + public static Vector4D operator +(Vector4D left, Vector4D right) => new(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); - public static Vector4F operator -(Vector4F left, Vector4F right) => + public static Vector4D operator -(Vector4D left, Vector4D right) => new(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); - public static Vector4F operator *(Vector4F left, Vector4F right) => + public static Vector4D operator *(Vector4D left, Vector4D right) => new(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W); - public static Vector4F operator /(Vector4F left, Vector4F right) => + public static Vector4D operator /(Vector4D left, Vector4D right) => new(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W); - public static Vector4F operator %(Vector4F left, Vector4F right) => - new(left.X % right.X, left.Y % right.Y, left.Z % right.Z, left.W % right.W); - - public static Vector4F operator +(Vector4F vector, T scalar) => + public static Vector4D operator +(Vector4D vector, T scalar) => new(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar); - public static Vector4F operator -(Vector4F vector, T scalar) => + public static Vector4D operator -(Vector4D vector, T scalar) => new(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar); - public static Vector4F operator *(Vector4F vector, T scalar) => + public static Vector4D operator *(Vector4D vector, T scalar) => new(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar); - public static Vector4F operator *(T scalar, Vector4F vector) => + public static Vector4D operator *(T scalar, Vector4D vector) => new(scalar * vector.X, scalar * vector.Y, scalar * vector.Z, scalar * vector.W); - public static Vector4F operator /(Vector4F vector, T scalar) => + public static Vector4D operator /(Vector4D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); - public static Vector4F operator %(Vector4F vector, T scalar) => - new(vector.X % scalar, vector.Y % scalar, vector.Z % scalar, vector.W % scalar); - } - static partial class Vector4F + public static partial class Vector4D { /// Computes the dot product of two vectors. - public static T Dot(this Vector4F left, Vector4F right) - where T : IFloatingPointIeee754 => + public static T Dot(this Vector4D left, Vector4D right) + where T : INumberBase => left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W; /// Reflects a vector over a normal vector. - public static Vector4F Reflect(Vector4F vector, Vector4F normal) - where T : IFloatingPointIeee754 + public static Vector4D Reflect(Vector4D vector, Vector4D normal) + where T : INumberBase { T dot = vector.Dot(normal); return vector - (normal * (dot + dot)); } /// Computes the length of the vector. - public static T GetLength(this Vector4F vector) + public static T GetLength(this Vector4D vector) where T : IFloatingPointIeee754 => T.Sqrt(vector.LengthSquared); /// Normalizes a vector. - public static Vector4F Normalize(this Vector4F vector) + public static Vector4D Normalize(this Vector4D vector) where T : IFloatingPointIeee754 { T length = vector.GetLength(); - return length != T.Zero ? vector / length : Vector4F.Zero; + return length != T.Zero ? vector / length : Vector4D.Zero; } /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4I Sign(this Vector4F value) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Sign(this Vector4D value) + where TSelf : INumber => new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z), TSelf.Sign(value.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F Max(this Vector4F x, Vector4F y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Max(this Vector4D x, Vector4D y) + where TSelf : INumber => new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z), TSelf.Max(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4F Max(this Vector4F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Max(this Vector4D x, TSelf y) + where TSelf : INumber => new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y), TSelf.Max(x.W, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F MaxNumber(this Vector4F x, Vector4F y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D MaxNumber(this Vector4D x, Vector4D y) + where TSelf : INumber => new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z), TSelf.MaxNumber(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4F MaxNumber(this Vector4F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D MaxNumber(this Vector4D x, TSelf y) + where TSelf : INumber => new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y), TSelf.MaxNumber(x.W, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F Min(this Vector4F x, Vector4F y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Min(this Vector4D x, Vector4D y) + where TSelf : INumber => new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z), TSelf.Min(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4F Min(this Vector4F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Min(this Vector4D x, TSelf y) + where TSelf : INumber => new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y), TSelf.Min(x.W, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F MinNumber(this Vector4F x, Vector4F y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D MinNumber(this Vector4D x, Vector4D y) + where TSelf : INumber => new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z), TSelf.MinNumber(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4F MinNumber(this Vector4F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D MinNumber(this Vector4D x, TSelf y) + where TSelf : INumber => new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y), TSelf.MinNumber(x.W, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F Clamp(this Vector4F value, Vector4F min, Vector4F max) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Clamp(this Vector4D value, Vector4D min, Vector4D max) + where TSelf : INumber => new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z), TSelf.Clamp(value.W, min.W, max.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector4F Clamp(this Vector4F value, TSelf min, TSelf max) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Clamp(this Vector4D value, TSelf min, TSelf max) + where TSelf : INumber => new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max), TSelf.Clamp(value.W, min, max)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F CopySign(this Vector4F value, Vector4F sign) - where TSelf : IFloatingPointIeee754 => + public static Vector4D CopySign(this Vector4D value, Vector4D sign) + where TSelf : INumber => new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z), TSelf.CopySign(value.W, sign.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4F CopySign(this Vector4F value, TSelf sign) - where TSelf : IFloatingPointIeee754 => + public static Vector4D CopySign(this Vector4D value, TSelf sign) + where TSelf : INumber => new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign), TSelf.CopySign(value.W, sign)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Abs(this Vector4F value) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Abs(this Vector4D value) + where TSelf : INumberBase => new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z), TSelf.Abs(value.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F MaxMagnitude(this Vector4F x, Vector4F y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D MaxMagnitude(this Vector4D x, Vector4D y) + where TSelf : INumberBase => new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z), TSelf.MaxMagnitude(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F MaxMagnitudeNumber(this Vector4F x, Vector4F y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D MaxMagnitudeNumber(this Vector4D x, Vector4D y) + where TSelf : INumberBase => new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z), TSelf.MaxMagnitudeNumber(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F MinMagnitude(this Vector4F x, Vector4F y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D MinMagnitude(this Vector4D x, Vector4D y) + where TSelf : INumberBase => new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z), TSelf.MinMagnitude(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F MinMagnitudeNumber(this Vector4F x, Vector4F y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D MinMagnitudeNumber(this Vector4D x, Vector4D y) + where TSelf : INumberBase => new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z), TSelf.MinMagnitudeNumber(x.W, y.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D PopCount(this Vector4D value) + where TSelf : IBinaryInteger => + new(TSelf.PopCount(value.X), TSelf.PopCount(value.Y), TSelf.PopCount(value.Z), TSelf.PopCount(value.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D TrailingZeroCount(this Vector4D value) + where TSelf : IBinaryInteger => + new(TSelf.TrailingZeroCount(value.X), TSelf.TrailingZeroCount(value.Y), TSelf.TrailingZeroCount(value.Z), TSelf.TrailingZeroCount(value.W)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Ceiling(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Ceiling(this Vector4D x) + where TSelf : IFloatingPoint => new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y), TSelf.Ceiling(x.Z), TSelf.Ceiling(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Floor(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Floor(this Vector4D x) + where TSelf : IFloatingPoint => new(TSelf.Floor(x.X), TSelf.Floor(x.Y), TSelf.Floor(x.Z), TSelf.Floor(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Round(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Round(this Vector4D x) + where TSelf : IFloatingPoint => new(TSelf.Round(x.X), TSelf.Round(x.Y), TSelf.Round(x.Z), TSelf.Round(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector4F Round(this Vector4F x, int digits, MidpointRounding mode) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Round(this Vector4D x, int digits, MidpointRounding mode) + where TSelf : IFloatingPoint => new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode), TSelf.Round(x.Z, digits, mode), TSelf.Round(x.W, digits, mode)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Truncate(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Truncate(this Vector4D x) + where TSelf : IFloatingPoint => new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y), TSelf.Truncate(x.Z), TSelf.Truncate(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F Atan2(this Vector4F y, Vector4F x) + public static Vector4D Atan2(this Vector4D y, Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y), TSelf.Atan2(y.Z, x.Z), TSelf.Atan2(y.W, x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F Atan2Pi(this Vector4F y, Vector4F x) + public static Vector4D Atan2Pi(this Vector4D y, Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y), TSelf.Atan2Pi(y.Z, x.Z), TSelf.Atan2Pi(y.W, x.W)); @@ -642,19 +653,19 @@ public static Vector4F Atan2Pi(this Vector4F y, Vector4FA vector whose members will be provided for . /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4F Lerp(this Vector4F value1, Vector4F value2, TSelf amount) + public static Vector4D Lerp(this Vector4D value1, Vector4D value2, TSelf amount) where TSelf : IFloatingPointIeee754 => new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount), TSelf.Lerp(value1.Z, value2.Z, amount), TSelf.Lerp(value1.W, value2.W, amount)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F BitDecrement(this Vector4F x) + public static Vector4D BitDecrement(this Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y), TSelf.BitDecrement(x.Z), TSelf.BitDecrement(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F BitIncrement(this Vector4F x) + public static Vector4D BitIncrement(this Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y), TSelf.BitIncrement(x.Z), TSelf.BitIncrement(x.W)); @@ -662,7 +673,7 @@ public static Vector4F BitIncrement(this Vector4F x) /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F FusedMultiplyAdd(this Vector4F left, Vector4F right, Vector4F addend) + public static Vector4D FusedMultiplyAdd(this Vector4D left, Vector4D right, Vector4D addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend.Z), TSelf.FusedMultiplyAdd(left.W, right.W, addend.W)); @@ -670,300 +681,300 @@ public static Vector4F FusedMultiplyAdd(this Vector4F left, /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector4F FusedMultiplyAdd(this Vector4F left, TSelf right, TSelf addend) + public static Vector4D FusedMultiplyAdd(this Vector4D left, TSelf right, TSelf addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend), TSelf.FusedMultiplyAdd(left.Z, right, addend), TSelf.FusedMultiplyAdd(left.W, right, addend)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F Ieee754Remainder(this Vector4F left, Vector4F right) + public static Vector4D Ieee754Remainder(this Vector4D left, Vector4D right) where TSelf : IFloatingPointIeee754 => new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y), TSelf.Ieee754Remainder(left.Z, right.Z), TSelf.Ieee754Remainder(left.W, right.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4F Ieee754Remainder(this Vector4F left, TSelf right) + public static Vector4D Ieee754Remainder(this Vector4D left, TSelf right) where TSelf : IFloatingPointIeee754 => new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right), TSelf.Ieee754Remainder(left.Z, right), TSelf.Ieee754Remainder(left.W, right)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4I ILogB(this Vector4F x) + public static Vector4D ILogB(this Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y), TSelf.ILogB(x.Z), TSelf.ILogB(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F ReciprocalEstimate(this Vector4F x) + public static Vector4D ReciprocalEstimate(this Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y), TSelf.ReciprocalEstimate(x.Z), TSelf.ReciprocalEstimate(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F ReciprocalSqrtEstimate(this Vector4F x) + public static Vector4D ReciprocalSqrtEstimate(this Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y), TSelf.ReciprocalSqrtEstimate(x.Z), TSelf.ReciprocalSqrtEstimate(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F ScaleB(this Vector4F x, Vector4I n) + public static Vector4D ScaleB(this Vector4D x, Vector4D n) where TSelf : IFloatingPointIeee754 => new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y), TSelf.ScaleB(x.Z, n.Z), TSelf.ScaleB(x.W, n.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4F ScaleB(this Vector4F x, int n) + public static Vector4D ScaleB(this Vector4D x, int n) where TSelf : IFloatingPointIeee754 => new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n), TSelf.ScaleB(x.Z, n), TSelf.ScaleB(x.W, n)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F Pow(this Vector4F x, Vector4F y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Pow(this Vector4D x, Vector4D y) + where TSelf : IPowerFunctions => new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y), TSelf.Pow(x.Z, y.Z), TSelf.Pow(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4F Pow(this Vector4F x, TSelf y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Pow(this Vector4D x, TSelf y) + where TSelf : IPowerFunctions => new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y), TSelf.Pow(x.Z, y), TSelf.Pow(x.W, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Cbrt(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Cbrt(this Vector4D x) + where TSelf : IRootFunctions => new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y), TSelf.Cbrt(x.Z), TSelf.Cbrt(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Sqrt(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Sqrt(this Vector4D x) + where TSelf : IRootFunctions => new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y), TSelf.Sqrt(x.Z), TSelf.Sqrt(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4F RootN(this Vector4F x, int n) - where TSelf : IFloatingPointIeee754 => + public static Vector4D RootN(this Vector4D x, int n) + where TSelf : IRootFunctions => new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n), TSelf.RootN(x.Z, n), TSelf.RootN(x.W, n)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F RootN(this Vector4F x, Vector4I n) - where TSelf : IFloatingPointIeee754 => + public static Vector4D RootN(this Vector4D x, Vector4D n) + where TSelf : IRootFunctions => new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y), TSelf.RootN(x.Z, n.Z), TSelf.RootN(x.W, n.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4F Hypot(this Vector4F x, Vector4F y) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Hypot(this Vector4D x, Vector4D y) + where TSelf : IRootFunctions => new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y), TSelf.Hypot(x.Z, y.Z), TSelf.Hypot(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Log(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Log(this Vector4D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z), TSelf.Log(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4F Log(this Vector4F x, TSelf newBase) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Log(this Vector4D x, TSelf newBase) + where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase), TSelf.Log(x.Z, newBase), TSelf.Log(x.W, newBase)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F LogP1(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D LogP1(this Vector4D x) + where TSelf : ILogarithmicFunctions => new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z), TSelf.LogP1(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Log2(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Log2(this Vector4D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z), TSelf.Log2(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Log2P1(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Log2P1(this Vector4D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z), TSelf.Log2P1(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Log10(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Log10(this Vector4D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z), TSelf.Log10(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Log10P1(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Log10P1(this Vector4D x) + where TSelf : ILogarithmicFunctions => new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z), TSelf.Log10P1(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Exp(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Exp(this Vector4D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z), TSelf.Exp(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F ExpM1(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D ExpM1(this Vector4D x) + where TSelf : IExponentialFunctions => new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z), TSelf.ExpM1(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Exp2(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Exp2(this Vector4D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z), TSelf.Exp2(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Exp2M1(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Exp2M1(this Vector4D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z), TSelf.Exp2M1(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Exp10(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Exp10(this Vector4D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z), TSelf.Exp10(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Exp10M1(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Exp10M1(this Vector4D x) + where TSelf : IExponentialFunctions => new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z), TSelf.Exp10M1(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Acos(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Acos(this Vector4D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Acos(x.X), TSelf.Acos(x.Y), TSelf.Acos(x.Z), TSelf.Acos(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F AcosPi(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D AcosPi(this Vector4D x) + where TSelf : ITrigonometricFunctions => new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y), TSelf.AcosPi(x.Z), TSelf.AcosPi(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Asin(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Asin(this Vector4D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Asin(x.X), TSelf.Asin(x.Y), TSelf.Asin(x.Z), TSelf.Asin(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F AsinPi(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D AsinPi(this Vector4D x) + where TSelf : ITrigonometricFunctions => new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y), TSelf.AsinPi(x.Z), TSelf.AsinPi(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Atan(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Atan(this Vector4D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Atan(x.X), TSelf.Atan(x.Y), TSelf.Atan(x.Z), TSelf.Atan(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F AtanPi(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D AtanPi(this Vector4D x) + where TSelf : ITrigonometricFunctions => new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y), TSelf.AtanPi(x.Z), TSelf.AtanPi(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Cos(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Cos(this Vector4D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Cos(x.X), TSelf.Cos(x.Y), TSelf.Cos(x.Z), TSelf.Cos(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F CosPi(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D CosPi(this Vector4D x) + where TSelf : ITrigonometricFunctions => new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y), TSelf.CosPi(x.Z), TSelf.CosPi(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Sin(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Sin(this Vector4D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Sin(x.X), TSelf.Sin(x.Y), TSelf.Sin(x.Z), TSelf.Sin(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F SinPi(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D SinPi(this Vector4D x) + where TSelf : ITrigonometricFunctions => new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y), TSelf.SinPi(x.Z), TSelf.SinPi(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Tan(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Tan(this Vector4D x) + where TSelf : ITrigonometricFunctions => new(TSelf.Tan(x.X), TSelf.Tan(x.Y), TSelf.Tan(x.Z), TSelf.Tan(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F TanPi(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D TanPi(this Vector4D x) + where TSelf : ITrigonometricFunctions => new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y), TSelf.TanPi(x.Z), TSelf.TanPi(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F DegreesToRadians(this Vector4F degrees) - where TSelf : IFloatingPointIeee754 => + public static Vector4D DegreesToRadians(this Vector4D degrees) + where TSelf : ITrigonometricFunctions => new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y), TSelf.DegreesToRadians(degrees.Z), TSelf.DegreesToRadians(degrees.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F RadiansToDegrees(this Vector4F radians) - where TSelf : IFloatingPointIeee754 => + public static Vector4D RadiansToDegrees(this Vector4D radians) + where TSelf : ITrigonometricFunctions => new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y), TSelf.RadiansToDegrees(radians.Z), TSelf.RadiansToDegrees(radians.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Acosh(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Acosh(this Vector4D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y), TSelf.Acosh(x.Z), TSelf.Acosh(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Asinh(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Asinh(this Vector4D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y), TSelf.Asinh(x.Z), TSelf.Asinh(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Atanh(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Atanh(this Vector4D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y), TSelf.Atanh(x.Z), TSelf.Atanh(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Cosh(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Cosh(this Vector4D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y), TSelf.Cosh(x.Z), TSelf.Cosh(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Sinh(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Sinh(this Vector4D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y), TSelf.Sinh(x.Z), TSelf.Sinh(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4F Tanh(this Vector4F x) - where TSelf : IFloatingPointIeee754 => + public static Vector4D Tanh(this Vector4D x) + where TSelf : IHyperbolicFunctions => new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y), TSelf.Tanh(x.Z), TSelf.Tanh(x.W)); } } diff --git a/sources/Maths/Maths/Vector4I.gen.cs b/sources/Maths/Maths/Vector4I.gen.cs deleted file mode 100644 index b87494d968..0000000000 --- a/sources/Maths/Maths/Vector4I.gen.cs +++ /dev/null @@ -1,620 +0,0 @@ -namespace Silk.NET.Maths -{ - using System.Collections; - using System.Diagnostics.CodeAnalysis; - using System.Numerics; - using System.Runtime.InteropServices; - using System.Text; - - partial struct Vector4I : - IEquatable>, - IReadOnlyList, - IFormattable, - IParsable>, - ISpanFormattable, - ISpanParsable>, - IUtf8SpanFormattable, - IUtf8SpanParsable> - where T : IBinaryInteger - { - /// The X component of the vector. - public T X; - - /// The Y component of the vector. - public T Y; - - /// The Z component of the vector. - public T Z; - - /// The W component of the vector. - public T W; - - /// Initializes all components of the vector to the same value. - public Vector4I(T value) => (X, Y, Z, W) = (value, value, value, value); - - /// Initializes the vector with individual component values. - public Vector4I(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); - - /// Initializes the vector using a for the initial elements, and the specified components for the remainder. - public Vector4I(Vector2I other, T z, T w) => (X, Y, Z, W) = (other.X, other.Y, z, w); - - /// Initializes the vector using a for the initial elements, and the specified component for the remainder. - public Vector4I(Vector3I other, T w) => (X, Y, Z, W) = (other.X, other.Y, other.Z, w); - - /// Initializes the vector from a span of 4 values. - public Vector4I(ReadOnlySpan values) - { - if (values.Length != 4) - throw new ArgumentException("Input span must contain exactly 4 elements.", nameof(values)); - - X = values[0]; - Y = values[1]; - Z = values[2]; - W = values[3]; - } - - /// Gets a vector whose 4 elements are equal to one. - public static Vector4I One => new(T.One); - - /// Returns a vector whose 4 elements are equal to zero. - public static Vector4I Zero => default; - - /// Gets the vector (1, 0, 0, 0). - public static Vector4I UnitX => new(T.One, T.Zero, T.Zero, T.Zero); - - /// Gets the vector (0, 1, 0, 0). - public static Vector4I UnitY => new(T.Zero, T.One, T.Zero, T.Zero); - - /// Gets the vector (0, 0, 1, 0). - public static Vector4I UnitZ => new(T.Zero, T.Zero, T.One, T.Zero); - - /// Gets the vector (0, 0, 0, 1). - public static Vector4I UnitW => new(T.Zero, T.Zero, T.Zero, T.One); - - /// Gets a vector with all bits set for each component. - public static Vector4I AllBitsSet => new Vector4I(T.AllBitsSet, T.AllBitsSet, T.AllBitsSet, T.AllBitsSet); - - /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => Vector4I.Dot(this, this); - - /// - T IReadOnlyList.this[int index] => this[index]; - - ///Gets the component at the specified index: 0 = X, 1 = Y, 2 = Z, 3 = W. - [UnscopedRef] - public ref T this[int index] - { - get - { - switch (index) - { - case 0: - return ref X; - case 1: - return ref Y; - case 2: - return ref Z; - case 3: - return ref W; - } - - throw new ArgumentOutOfRangeException(nameof(index)); - } - } - - /// The number of elements in the vector. - public int Count => 4; - - /// - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - - /// Returns an enumerator that iterates through the vector components. - public IEnumerator GetEnumerator() - { - yield return X; - yield return Y; - yield return Z; - yield return W; - } - - /// Copies the components of the vector to the specified array starting at index 0. - public void CopyTo(T[] array) => CopyTo(array, 0); - - /// Copies the components of the vector to the specified array starting at the given index. - public void CopyTo(T[] array, int startIndex) - { - if (array == null) - throw new ArgumentNullException(nameof(array)); - if (startIndex < 0 || startIndex + 4 > array.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - - array[startIndex] = X; - array[startIndex + 1] = Y; - array[startIndex + 2] = Z; - array[startIndex + 3] = W; - } - - /// Copies the components of the vector to the specified span starting at index 0. - public void CopyTo(Span span) => CopyTo(span, 0); - - /// Copies the components of the vector to the specified span starting at the given index. - public void CopyTo(Span span, int startIndex) - { - if (startIndex < 0 || startIndex + 4 > span.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - - span[startIndex] = X; - span[startIndex + 1] = Y; - span[startIndex + 2] = Z; - span[startIndex + 3] = W; - } - - /// Returns a span over the vector components. - public Span AsSpan() => MemoryMarshal.CreateSpan(ref X, 4); - - /// Formats the vector as a string. - public override string ToString() => - $"<{X}, {Y}, {Z}, {W}>"; - - /// Formats the vector as a string using the specified format and format provider. - public string ToString(string? format, IFormatProvider? formatProvider) => - $"<{X.ToString(format, formatProvider)}, {Y.ToString(format, formatProvider)}, {Z.ToString(format, formatProvider)}, {W.ToString(format, formatProvider)}>"; - - /// Parses a string to a instance. - public static Vector4I Parse(string s, IFormatProvider? provider) => Parse(s.AsSpan(), provider); - - /// Parses a span to a instance. - public static Vector4I Parse(ReadOnlySpan s, IFormatProvider? provider) - { - if (!TryParse(s, provider, out var result)) - throw new FormatException("Invalid format for Vector4I."); - - return result; - } - - /// Formats the vector as a UTF-8 string using the specified format and format provider. - public bool TryFormat(Span utf8Destination, out int bytesWritten, ReadOnlySpan format, IFormatProvider? provider) - { - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - Span zBuffer = stackalloc char[64]; - Span wBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider)|| - !Y.TryFormat(yBuffer, out int yChars, format, provider)|| - !Z.TryFormat(zBuffer, out int zChars, format, provider)|| - !W.TryFormat(wBuffer, out int wChars, format, provider)) - { - bytesWritten = 0; - return false; - } - - int estimatedSize = Encoding.UTF8.GetByteCount(xBuffer[..xChars]) + - Encoding.UTF8.GetByteCount(yBuffer[..yChars]) + - Encoding.UTF8.GetByteCount(zBuffer[..zChars]) + - Encoding.UTF8.GetByteCount(wBuffer[..wChars]) + - Encoding.UTF8.GetByteCount("<, >"); - - if (utf8Destination.Length < estimatedSize) - { - bytesWritten = 0; - return false; - } - - int totalBytes = 0; - - totalBytes += Encoding.UTF8.GetBytes("<", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(xBuffer[..xChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(yBuffer[..yChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(zBuffer[..zChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(", ", utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(wBuffer[..wChars], utf8Destination[totalBytes..]); - totalBytes += Encoding.UTF8.GetBytes(">", utf8Destination[totalBytes..]); - - bytesWritten = totalBytes; - return true; - } - - /// Formats the vector as a string using the specified format and format provider. - public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - Span xBuffer = stackalloc char[64]; - Span yBuffer = stackalloc char[64]; - Span zBuffer = stackalloc char[64]; - Span wBuffer = stackalloc char[64]; - - if (!X.TryFormat(xBuffer, out int xChars, format, provider) || - !Y.TryFormat(yBuffer, out int yChars, format, provider) || - !Z.TryFormat(zBuffer, out int zChars, format, provider) || - !W.TryFormat(wBuffer, out int wChars, format, provider)) - { - charsWritten = 0; - return false; - } - - int requiredLength = 1 + xChars + 2 + yChars + 2 + zChars + 2 + wChars + 1; - - if (destination.Length < requiredLength) - { - charsWritten = 0; - return false; - } - - int pos = 0; - destination[pos++] = '<'; - - xBuffer[..xChars].CopyTo(destination[pos..]); - pos += xChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - yBuffer[..yChars].CopyTo(destination[pos..]); - pos += yChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - zBuffer[..zChars].CopyTo(destination[pos..]); - pos += zChars; - - destination[pos++] = ','; - destination[pos++] = ' '; - - wBuffer[..wChars].CopyTo(destination[pos..]); - pos += wChars; - - destination[pos++] = '>'; - - charsWritten = pos; - return true; - } - - /// Tries to parse a span to a instance. - public static bool TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) - { - result = default; - - s = s.Trim(); - if (s.Length < 8 || s[0] != '<' || s[^1] != '>') - return false; - - s = s[1..^1]; // Remove < and > - - int commaX = s.IndexOf(','); - if (commaX < 0) - return false; - - ReadOnlySpan remainder1 = s.Slice(commaX + 1); - int commaYRelative = remainder1.IndexOf(','); - if (commaYRelative < 0) - return false; - int commaY = commaX + 1 + commaYRelative; - - ReadOnlySpan remainder2 = s.Slice(commaY + 1); - int commaZRelative = remainder2.IndexOf(','); - if (commaZRelative < 0) - return false; - int commaZ = commaY + 1 + commaZRelative; - - ReadOnlySpan xSpan = s[..commaX].Trim(); - ReadOnlySpan ySpan = s[(commaX + 1)..commaY].Trim(); - ReadOnlySpan zSpan = s[(commaY + 1)..commaZ].Trim(); - ReadOnlySpan wSpan = s[(commaZ + 1)..].Trim(); - - if (T.TryParse(xSpan, provider, out var x) && - T.TryParse(ySpan, provider, out var y) && - T.TryParse(zSpan, provider, out var z) && - T.TryParse(wSpan, provider, out var w)) - { - result = new Vector4I(x, y, z, w); - return true; - } - - return false; - } - - /// Parses a UTF-8 span to a instance. - public static Vector4I Parse(ReadOnlySpan utf8Text, IFormatProvider? provider) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return Parse(charBuffer, provider); - } - - /// Tries to parse a UTF-8 span to a instance. - public static bool TryParse(ReadOnlySpan utf8Text, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) - { - int charCount = Encoding.UTF8.GetCharCount(utf8Text); - Span charBuffer = charCount <= 128 ? stackalloc char[charCount] : new char[charCount]; - Encoding.UTF8.GetChars(utf8Text, charBuffer); - return TryParse(charBuffer, provider, out result); - } - - /// Tries to parse a string to a instance. - public static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => - TryParse(s.AsSpan(), provider, out result); - - /// Parses a span to a instance. - static Vector4I ISpanParsable>.Parse(ReadOnlySpan s, IFormatProvider? provider) => - Parse(s, provider); - - /// Parses a string to a instance. - static Vector4I IParsable>.Parse(string s, IFormatProvider? provider) => - Parse(s, provider); - - /// Tries to parse a span to a instance. - static bool ISpanParsable>.TryParse(ReadOnlySpan s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => - TryParse(s, provider, out result); - - /// Tries to parse a string to a instance. - static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, [MaybeNullWhen(false)] out Vector4I result) => - TryParse(s, provider, out result); - - /// Returns a boolean indicating whether the given two vectors are equal. - /// The first vector to compare. - /// The second vector to compare. - /// true if the given vectors are equal; false otherwise. - public static bool operator ==(Vector4I left, Vector4I right) => - left.X == right.X && - left.Y == right.Y && - left.Z == right.Z && - left.W == right.W; - - /// Returns a boolean indicating whether the given two vectors are not equal. - /// The first vector to compare. - /// The second vector to compare. - /// true if the given vectors are not equal; false otherwise. - public static bool operator !=(Vector4I left, Vector4I right) => !(left == right); - - /// - public override bool Equals(object? obj) => obj is Vector4I other && Equals(other); - - /// - public bool Equals(Vector4I other) => this == other; - - /// - public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); - - /// Desconstructs a vector into its components. - /// The X component. - /// The Y component. - /// The Z component. - /// The W component. - public void Deconstruct(out T x, out T y, out T z, out T w) - { - x = X; - y = Y; - z = Z; - w = W; - } - - /// Implicitly casts a to a . - public static implicit operator Vector4I((T X, T Y, T Z, T W) v) => - new(v.X, v.Y, v.Z, v.W); - - /// Implicitly casts a to a . - public static implicit operator (T X, T Y, T Z, T W)(Vector4I v) => - (v.X, v.Y, v.Z, v.W); - - public static Vector4I operator +(Vector4I vector) => - vector; - - public static Vector4I operator -(Vector4I vector) => - new(-vector.X, -vector.Y, -vector.Z, -vector.W); - - public static Vector4I operator +(Vector4I left, Vector4I right) => - new(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); - - public static Vector4I operator -(Vector4I left, Vector4I right) => - new(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); - - public static Vector4I operator *(Vector4I left, Vector4I right) => - new(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W); - - public static Vector4I operator /(Vector4I left, Vector4I right) => - new(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W); - - public static Vector4I operator %(Vector4I left, Vector4I right) => - new(left.X % right.X, left.Y % right.Y, left.Z % right.Z, left.W % right.W); - - public static Vector4I operator +(Vector4I vector, T scalar) => - new(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar); - - public static Vector4I operator -(Vector4I vector, T scalar) => - new(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar); - - public static Vector4I operator *(Vector4I vector, T scalar) => - new(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar); - - public static Vector4I operator *(T scalar, Vector4I vector) => - new(scalar * vector.X, scalar * vector.Y, scalar * vector.Z, scalar * vector.W); - - public static Vector4I operator /(Vector4I vector, T scalar) => - new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); - - public static Vector4I operator %(Vector4I vector, T scalar) => - new(vector.X % scalar, vector.Y % scalar, vector.Z % scalar, vector.W % scalar); - - public static Vector4I operator ~(Vector4I vector) => - new Vector4I(~vector.X, ~vector.Y, ~vector.Z, ~vector.W); - - public static Vector4I operator &(Vector4I left, Vector4I right) => - new Vector4I(left.X & right.X, left.Y & right.Y, left.Z & right.Z, left.W & right.W); - - public static Vector4I operator |(Vector4I left, Vector4I right) => - new Vector4I(left.X | right.X, left.Y | right.Y, left.Z | right.Z, left.W | right.W); - - public static Vector4I operator ^(Vector4I left, Vector4I right) => - new Vector4I(left.X ^ right.X, left.Y ^ right.Y, left.Z ^ right.Z, left.W ^ right.W); - - public static Vector4I operator &(Vector4I vector, T scalar) => - new Vector4I(vector.X & scalar, vector.Y & scalar, vector.Z & scalar, vector.W & scalar); - - public static Vector4I operator &(T scalar, Vector4I vector) => - new Vector4I(scalar & vector.X, scalar & vector.Y, scalar & vector.Z, scalar & vector.W); - - public static Vector4I operator |(Vector4I vector, T scalar) => - new Vector4I(vector.X | scalar, vector.Y | scalar, vector.Z | scalar, vector.W | scalar); - - public static Vector4I operator |(T scalar, Vector4I vector) => - new Vector4I(scalar | vector.X, scalar | vector.Y, scalar | vector.Z, scalar | vector.W); - - public static Vector4I operator ^(Vector4I vector, T scalar) => - new Vector4I(vector.X ^ scalar, vector.Y ^ scalar, vector.Z ^ scalar, vector.W ^ scalar); - - public static Vector4I operator ^(T scalar, Vector4I vector) => - new Vector4I(scalar ^ vector.X, scalar ^ vector.Y, scalar ^ vector.Z, scalar ^ vector.W); - } - - static partial class Vector4I - { - /// Computes the dot product of two vectors. - public static T Dot(this Vector4I left, Vector4I right) - where T : IBinaryInteger => - left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W; - - /// Reflects a vector over a normal vector. - public static Vector4I Reflect(Vector4I vector, Vector4I normal) - where T : IBinaryInteger - { - T dot = vector.Dot(normal); - return vector - (normal * (dot + dot)); - } - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4I Sign(this Vector4I value) - where TSelf : IBinaryInteger => - new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z), TSelf.Sign(value.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4I Max(this Vector4I x, Vector4I y) - where TSelf : IBinaryInteger => - new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z), TSelf.Max(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4I Max(this Vector4I x, TSelf y) - where TSelf : IBinaryInteger => - new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y), TSelf.Max(x.W, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4I MaxNumber(this Vector4I x, Vector4I y) - where TSelf : IBinaryInteger => - new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z), TSelf.MaxNumber(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4I MaxNumber(this Vector4I x, TSelf y) - where TSelf : IBinaryInteger => - new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y), TSelf.MaxNumber(x.W, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4I Min(this Vector4I x, Vector4I y) - where TSelf : IBinaryInteger => - new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z), TSelf.Min(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4I Min(this Vector4I x, TSelf y) - where TSelf : IBinaryInteger => - new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y), TSelf.Min(x.W, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4I MinNumber(this Vector4I x, Vector4I y) - where TSelf : IBinaryInteger => - new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z), TSelf.MinNumber(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4I MinNumber(this Vector4I x, TSelf y) - where TSelf : IBinaryInteger => - new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y), TSelf.MinNumber(x.W, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4I Clamp(this Vector4I value, Vector4I min, Vector4I max) - where TSelf : IBinaryInteger => - new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z), TSelf.Clamp(value.W, min.W, max.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A single value provided for . - public static Vector4I Clamp(this Vector4I value, TSelf min, TSelf max) - where TSelf : IBinaryInteger => - new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max), TSelf.Clamp(value.W, min, max)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4I CopySign(this Vector4I value, Vector4I sign) - where TSelf : IBinaryInteger => - new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z), TSelf.CopySign(value.W, sign.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4I CopySign(this Vector4I value, TSelf sign) - where TSelf : IBinaryInteger => - new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign), TSelf.CopySign(value.W, sign)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4I Abs(this Vector4I value) - where TSelf : IBinaryInteger => - new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z), TSelf.Abs(value.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4I MaxMagnitude(this Vector4I x, Vector4I y) - where TSelf : IBinaryInteger => - new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z), TSelf.MaxMagnitude(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4I MaxMagnitudeNumber(this Vector4I x, Vector4I y) - where TSelf : IBinaryInteger => - new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z), TSelf.MaxMagnitudeNumber(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4I MinMagnitude(this Vector4I x, Vector4I y) - where TSelf : IBinaryInteger => - new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z), TSelf.MinMagnitude(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4I MinMagnitudeNumber(this Vector4I x, Vector4I y) - where TSelf : IBinaryInteger => - new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z), TSelf.MinMagnitudeNumber(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4I Log2(this Vector4I value) - where TSelf : IBinaryInteger => - new(TSelf.Log2(value.X), TSelf.Log2(value.Y), TSelf.Log2(value.Z), TSelf.Log2(value.W)); - } -} From aefd7eaf161db8cce54453f9ffb8d84cba64fc11 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Mon, 30 Jun 2025 19:45:07 -0700 Subject: [PATCH 36/67] Merge matrix types. --- sources/Maths/Maths/Matrix2X2.Ops.cs | 50 ++-- sources/Maths/Maths/Matrix2X2.cs | 208 +------------ sources/Maths/Maths/Matrix2X2.gen.cs | 53 +++- sources/Maths/Maths/Matrix2X3.Ops.cs | 41 +-- sources/Maths/Maths/Matrix2X3.cs | 243 +-------------- sources/Maths/Maths/Matrix2X3.gen.cs | 57 +++- sources/Maths/Maths/Matrix2X4.Ops.cs | 32 +- sources/Maths/Maths/Matrix2X4.cs | 277 +----------------- sources/Maths/Maths/Matrix2X4.gen.cs | 63 +++- sources/Maths/Maths/Matrix3X2.Ops.cs | 66 ++--- sources/Maths/Maths/Matrix3X2.cs | 240 +-------------- sources/Maths/Maths/Matrix3X2.gen.cs | 58 +++- sources/Maths/Maths/Matrix3X3.Ops.cs | 72 ++--- sources/Maths/Maths/Matrix3X3.cs | 279 +----------------- sources/Maths/Maths/Matrix3X3.gen.cs | 67 ++++- sources/Maths/Maths/Matrix3X4.Ops.cs | 38 +-- sources/Maths/Maths/Matrix3X4.cs | 319 +------------------- sources/Maths/Maths/Matrix3X4.gen.cs | 72 ++++- sources/Maths/Maths/Matrix4X2.Ops.cs | 45 +-- sources/Maths/Maths/Matrix4X2.cs | 295 +------------------ sources/Maths/Maths/Matrix4X2.gen.cs | 65 +++- sources/Maths/Maths/Matrix4X3.Ops.cs | 39 +-- sources/Maths/Maths/Matrix4X3.cs | 328 +-------------------- sources/Maths/Maths/Matrix4X3.gen.cs | 73 ++++- sources/Maths/Maths/Matrix4X4.Ops.cs | 115 ++++---- sources/Maths/Maths/Matrix4X4.cs | 423 +-------------------------- sources/Maths/Maths/Matrix4X4.gen.cs | 309 +++++++++++++++++++ sources/Maths/Maths/Matrix5X4.Ops.cs | 30 +- sources/Maths/Maths/Matrix5X4.cs | 402 +------------------------ sources/Maths/Maths/Matrix5X4.gen.cs | 74 ++++- 30 files changed, 1075 insertions(+), 3358 deletions(-) create mode 100644 sources/Maths/Maths/Matrix4X4.gen.cs diff --git a/sources/Maths/Maths/Matrix2X2.Ops.cs b/sources/Maths/Maths/Matrix2X2.Ops.cs index 0d768ab0ce..e7f5828da8 100644 --- a/sources/Maths/Maths/Matrix2X2.Ops.cs +++ b/sources/Maths/Maths/Matrix2X2.Ops.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; namespace Silk.NET.Maths @@ -9,14 +10,15 @@ namespace Silk.NET.Maths /// /// Methods for working with /// - public static class Matrix2X2 + public static partial class Matrix2X2 { /// Adds two matrices together. /// The first source matrix. /// The second source matrix. /// The resulting matrix. [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Add(Matrix2X2 value1, Matrix2X2 value2) where T : unmanaged, IFormattable, IEquatable, IComparable + public static Matrix2X2 Add(Matrix2X2 value1, Matrix2X2 value2) + where T : INumberBase { return value1 + value2; } @@ -26,68 +28,54 @@ public static Matrix2X2 Add(Matrix2X2 value1, Matrix2X2 value2) wher /// The second source matrix. /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Multiply(Matrix2X2 value1, Matrix2X2 value2) where T : unmanaged, IFormattable, IEquatable, IComparable => value1 * value2; + public static Matrix2X2 Multiply(Matrix2X2 value1, Matrix2X2 value2) + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X2 Multiply(Matrix3X2 value1, Matrix2X2 value2) where T : unmanaged, IFormattable, IEquatable, IComparable => value1 * value2; + public static Matrix3X2 Multiply(Matrix3X2 value1, Matrix2X2 value2) + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X3 Multiply(Matrix2X2 value1, Matrix2X3 value2) where T : unmanaged, IFormattable, IEquatable, IComparable => value1 * value2; + public static Matrix2X3 Multiply(Matrix2X2 value1, Matrix2X3 value2) + where T : INumberBase => value1 * value2; /// Multiplies a matrix by a scalar value. /// The source matrix. /// The scaling factor. /// The scaled matrix. [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Multiply(Matrix2X2 value1, T value2) where T : unmanaged, IFormattable, IEquatable, IComparable => value1 * value2; + public static Matrix2X2 Multiply(Matrix2X2 value1, T value2) + where T : INumberBase => value1 * value2; /// Multiplies a vector by a matrix. /// The vector. /// The matrix. /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Multiply(Vector2D value1, Matrix2X2 value2) where T : unmanaged, IFormattable, IEquatable, IComparable => value1 * value2; + public static Vector2D Multiply(Vector2D value1, Matrix2X2 value2) + where T : INumberBase => value1 * value2; /// Returns a new matrix with the negated elements of the given matrix. /// The source matrix. /// The negated matrix. [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Negate(Matrix2X2 value) where T : unmanaged, IFormattable, IEquatable, IComparable => -value; + public static Matrix2X2 Negate(Matrix2X2 value) + where T : INumberBase => -value; /// Subtracts the second matrix from the first. /// The first source matrix. /// The second source matrix. /// The result of the subtraction. [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Subtract(Matrix2X2 value1, Matrix2X2 value2) where T : unmanaged, IFormattable, IEquatable, IComparable => value1 - value2; - - - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static unsafe Matrix2X2 Lerp(Matrix2X2 matrix1, Matrix2X2 matrix2, T amount) where T : unmanaged, IFormattable, IEquatable, IComparable - { - Matrix2X2 result = default; - - // First row - result.M11 = Scalar.Add(matrix1.M11, Scalar.Multiply(Scalar.Subtract(matrix2.M11, matrix1.M11), amount)); - result.M12 = Scalar.Add(matrix1.M12, Scalar.Multiply(Scalar.Subtract(matrix2.M12, matrix1.M12), amount)); - - // Second row - result.M21 = Scalar.Add(matrix1.M21, Scalar.Multiply(Scalar.Subtract(matrix2.M21, matrix1.M21), amount)); - result.M22 = Scalar.Add(matrix1.M22, Scalar.Multiply(Scalar.Subtract(matrix2.M22, matrix1.M22), amount)); - - return result; - } + public static Matrix2X2 Subtract(Matrix2X2 value1, Matrix2X2 value2) + where T : INumberBase => value1 - value2; } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix2X2.cs b/sources/Maths/Maths/Matrix2X2.cs index e01fcf288f..50bde7046e 100644 --- a/sources/Maths/Maths/Matrix2X2.cs +++ b/sources/Maths/Maths/Matrix2X2.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -11,117 +12,8 @@ namespace Silk.NET.Maths /// A structure encapsulating a 2x2 matrix. [Serializable] [DataContract] - public struct Matrix2X2 : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + public partial struct Matrix2X2 { - private static readonly Matrix2X2 _identity = new(Scalar.One, Scalar.Zero, Scalar.Zero, - Scalar.One); - - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Row1; - /// - /// Row 2 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Row2; - - /// - /// Column 1 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Column1 => new(M11, M21); - - /// - /// Column 2 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Column2 => new(M12, M22); - - - /// Value at row 1, column 1 of the matrix. - [DataMember] - public T M11 - { - readonly get => Row1.X; - set => Row1.X = value; - } - - /// Value at row 1, column 2 of the matrix. - [DataMember] - public T M12 - { - readonly get => Row1.Y; - set => Row1.Y = value; - } - - /// Value at row 2, column 1 of the matrix. - [DataMember] - public T M21 - { - readonly get => Row2.X; - set => Row2.X = value; - } - - /// Value at row 2, column 2 of the matrix. - [DataMember] - public T M22 - { - readonly get => Row2.Y; - set => Row2.Y = value; - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - public unsafe Vector2D this[int x] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 1 || i < 0) - ThrowHelper(); - } - - VerifyBounds(x); - return Unsafe.Add(ref Row1, x); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - public unsafe T this[int x, int y] - { - get - { - var row = this[x]; - return row[y]; - } - } - - /// Constructs a from the given components. - public Matrix2X2(T m11, T m12, T m21, T m22) - { - Row1 = new(m11, m12); - Row2 = new(m21, m22); - } - - /// Constructs a from the given rows. - public Matrix2X2(Vector2D row1, Vector2D row2) - { - Row1 = row1; - Row2 = row2; - } - /// Constructs a from the given . /// The source . public Matrix2X2(Matrix3X2 value) @@ -162,63 +54,12 @@ public Matrix2X2(Matrix4X2 value) Row2 = new(value.M21, value.M22); } - /// Returns the multiplicative identity matrix. - public static Matrix2X2 Identity => _identity; - /// Returns whether the matrix is the identity matrix. public readonly bool IsIdentity => Scalar.Equal(M11, Scalar.One) && Scalar.Equal(M22, Scalar.One) && // Check diagonal element first for early out. Scalar.Equal(M12, Scalar.Zero) && Scalar.Equal(M21, Scalar.Zero); - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - public static unsafe Matrix2X2 operator +(Matrix2X2 value1, Matrix2X2 value2) - { - Matrix2X2 m; - - m.Row1 = value1.Row1 + value2.Row1; - m.Row2 = value1.Row2 + value2.Row2; - - return m; - } - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are equal; False otherwise. - public static unsafe bool operator ==(Matrix2X2 value1, Matrix2X2 value2) - { - return Scalar.Equal(value1.M11, value2.M11) && Scalar.Equal(value1.M22, value2.M22) && - // Check diagonal elements first for early out. - Scalar.Equal(value1.M12, value2.M12) && Scalar.Equal(value1.M21, value2.M21); - } - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are not equal; False if they are equal. - public static unsafe bool operator !=(Matrix2X2 value1, Matrix2X2 value2) - { - return Scalar.NotEqual(value1.M11, value2.M11) || - Scalar.NotEqual(value1.M22, value2.M22) || // Check diagonal elements first for early out. - Scalar.NotEqual(value1.M12, value2.M12) || Scalar.NotEqual(value1.M21, value2.M21); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix2X2 operator *(Matrix2X2 value1, Matrix2X2 value2) - { - return new - ( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2, value1.M21 * value2.Row1 + value1.M22 * value2.Row2 - ); - } - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -237,23 +78,6 @@ public readonly bool IsIdentity return new(value1.Row1 * value2, value1.Row2 * value2); } - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static unsafe Matrix2X2 operator -(Matrix2X2 value1, Matrix2X2 value2) - { - return new(value1.Row1 - value2.Row1, value1.Row2 - value2.Row2); - } - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static unsafe Matrix2X2 operator -(Matrix2X2 value) - { - return new(-value.Row1, -value.Row2); - } - /// Calculates the determinant of the matrix. /// The determinant of the matrix. public readonly T GetDeterminant() @@ -267,32 +91,6 @@ public readonly T GetDeterminant() return Scalar.Subtract(Scalar.Multiply(a, d), Scalar.Multiply(b, c)); } - /// Returns a boolean indicating whether the given Object is equal to this matrix instance. - /// The Object to compare against. - /// True if the Object is equal to this matrix; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) => (obj is Matrix2X2 other) && Equals(other); - - /// Returns a boolean indicating whether this matrix instance is equal to the other given matrix. - /// The matrix to compare this instance to. - /// True if the matrices are equal; False otherwise. - public readonly bool Equals(Matrix2X2 other) => this == other; - - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - HashCode hash = default; - - hash.Add(M11); - hash.Add(M12); - - hash.Add(M21); - hash.Add(M22); - - return hash.ToHashCode(); - } - /// Returns a String representing this matrix instance. /// The string representation. public override readonly string ToString() @@ -414,7 +212,7 @@ public static explicit operator Matrix2X2(Matrix2X2 from) /// /// The type to cast to /// The casted matrix - public Matrix2X2 As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Matrix2X2 As() where TOther : INumberBase { return new(Row1.As(), Row2.As()); } diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index fb351734b6..d1bffe8d59 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -2,27 +2,55 @@ namespace Silk.NET.Maths { using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.CompilerServices; + using System.Runtime.Serialization; public partial struct Matrix2X2 : IEquatable> where T : INumberBase { /// The multiplicative identity matrix of size 2x2. - public static readonly Matrix2X2 Identity = new( + public static Matrix2X2 Identity { get; } = new( new(T.MultiplicativeIdentity, T.Zero), new(T.Zero, T.MultiplicativeIdentity)); /// The 1st row of the matrix represented as a vector. + [IgnoreDataMember] public Vector2D Row1; /// The 2nd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector2D Row2; + /// The 1st column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector2D Column1 => new(Row1.X, Row2.X); + + /// The 2nd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector2D Column2 => new(Row1.Y, Row2.Y); + /// /// Constructs a from the given rows. /// - public Matrix2X2(Vector2D row1, Vector2D row2) => (Row1, Row2) = (row1, row2); + public Matrix2X2(Vector2D row1, Vector2D row2) => + (Row1, Row2) = (row1, row2); + /// + /// Constructs a from the given components. + /// + public Matrix2X2( + T m11, T m12, + T m21, T m22) + { + Row1 = new(m11, m12); + Row2 = new(m21, m22); + } + + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. [UnscopedRef] public ref Vector2D this[int row] { @@ -36,30 +64,40 @@ public ref Vector2D this[int row] return ref Row2; } - throw new ArgumentOutOfRangeException(nameof(row)); + throw new IndexOutOfRangeException(); } } + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. [UnscopedRef] public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M12 => ref Row1.Y; /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M22 => ref Row2.Y; /// + [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix2X2 other && Equals(other); /// @@ -121,9 +159,14 @@ public Matrix2X2 Transpose() => public static partial class Matrix2X2 { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. public static Matrix2X2 Lerp(Matrix2X2 value1, Matrix2X2 value2, T amount) where T : IFloatingPointIeee754 => - new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount)), - new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount))); + new(Vector2D.Lerp(value1.Row1, value2.Row1, amount), + Vector2D.Lerp(value1.Row2, value2.Row2, amount)); } } diff --git a/sources/Maths/Maths/Matrix2X3.Ops.cs b/sources/Maths/Maths/Matrix2X3.Ops.cs index 6ebb6124ca..cd5d662780 100644 --- a/sources/Maths/Maths/Matrix2X3.Ops.cs +++ b/sources/Maths/Maths/Matrix2X3.Ops.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; namespace Silk.NET.Maths @@ -9,7 +10,7 @@ namespace Silk.NET.Maths /// /// Methods for working with /// - public static class Matrix2X3 + public static partial class Matrix2X3 { private const float BillboardEpsilon = 1e-4f; @@ -19,7 +20,7 @@ public static class Matrix2X3 /// The resulting matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X3 Add(Matrix2X3 value1, Matrix2X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { return value1 + value2; } @@ -31,7 +32,7 @@ public static Matrix2X3 Add(Matrix2X3 value1, Matrix2X3 value2) /// The forward vector of the camera. /// The created billboard matrix public static Matrix2X3 CreateBillboard(Vector3D objectPosition, Vector3D cameraPosition, Vector3D cameraUpVector, Vector3D cameraForwardVector) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Vector3D zaxis = objectPosition - cameraPosition; var norm = zaxis.LengthSquared; @@ -56,7 +57,7 @@ public static Matrix2X3 CreateBillboard(Vector3D objectPosition, Vector /// The angle to rotate around the given axis, in radians. /// The rotation matrix. public static Matrix2X3 CreateFromAxisAngle(Vector3D axis, T angle) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { // a: angle // x, y, z: unit vector for axis. @@ -105,7 +106,7 @@ public static Matrix2X3 CreateFromAxisAngle(Vector3D axis, T angle) /// The source Quaternion. /// The rotation matrix. public static Matrix2X3 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quaternion quaternion) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix2X3 result = Matrix2X3.Identity; @@ -138,7 +139,7 @@ public static Matrix2X3 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quatern /// Angle of rotation, in radians, around the Z-axis. /// The rotation matrix. public static Matrix2X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Legacy.Quaternion q = Legacy.Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(q); @@ -150,7 +151,7 @@ public static Matrix2X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X3 Multiply(Matrix2X3 value1, Matrix3X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; @@ -160,7 +161,7 @@ public static Matrix2X3 Multiply(Matrix2X3 value1, Matrix3X3 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X2 Multiply(Matrix2X3 value1, Matrix3X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -169,7 +170,7 @@ public static Matrix2X2 Multiply(Matrix2X3 value1, Matrix3X2 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X3 Multiply(Matrix2X2 value1, Matrix2X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by a scalar value. @@ -178,7 +179,7 @@ public static Matrix2X3 Multiply(Matrix2X2 value1, Matrix2X3 value2) /// The scaled matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X3 Multiply(Matrix2X3 value1, T value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a vector by a matrix. @@ -187,7 +188,7 @@ public static Matrix2X3 Multiply(Matrix2X3 value1, T value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Vector3D Multiply(Vector2D value1, Matrix2X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Returns a new matrix with the negated elements of the given matrix. @@ -195,7 +196,7 @@ public static Vector3D Multiply(Vector2D value1, Matrix2X3 value2) /// The negated matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X3 Negate(Matrix2X3 value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => -value; /// Subtracts the second matrix from the first. @@ -204,27 +205,15 @@ public static Matrix2X3 Negate(Matrix2X3 value) /// The result of the subtraction. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X3 Subtract(Matrix2X3 value1, Matrix2X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 - value2; - - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static unsafe Matrix2X3 Lerp(Matrix2X3 matrix1, Matrix2X3 matrix2, T amount) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new(Vector3D.Lerp(matrix1.Row1, matrix2.Row2, amount), Vector3D.Lerp(matrix1.Row2, matrix2.Row2, amount)); - } - /// Transforms the given matrix by applying the given Quaternion rotation. /// The source matrix to transform. /// The rotation to apply. /// The transformed matrix. public static Matrix2X3 Transform(Matrix2X3 value, Legacy.Quaternion rotation) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { // Compute rotation matrix. T x2 = Scalar.Add(rotation.X, rotation.X); diff --git a/sources/Maths/Maths/Matrix2X3.cs b/sources/Maths/Maths/Matrix2X3.cs index 87bdfc4701..63e4bc944b 100644 --- a/sources/Maths/Maths/Matrix2X3.cs +++ b/sources/Maths/Maths/Matrix2X3.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -11,8 +12,7 @@ namespace Silk.NET.Maths /// A structure encapsulating a 2x3 matrix. [Serializable] [DataContract] - public struct Matrix2X3 : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + public partial struct Matrix2X3 { private static readonly Matrix2X3 _identity = new ( @@ -20,136 +20,6 @@ public struct Matrix2X3 : IEquatable> Scalar.Zero, Scalar.One, Scalar.Zero ); - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Row1; - - /// - /// Row 2 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Row2; - - /// - /// Column 1 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Column1 => new Vector2D(M11, M21); - - /// - /// Column 2 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Column2 => new Vector2D(M12, M22); - - /// - /// Column 3 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Column3 => new Vector2D(M13, M23); - - /// Value at row 1, column 1 of the matrix. - [DataMember] - public T M11 - { - readonly get => Row1.X; - set => Row1.X = value; - } - - /// Value at row 1, column 2 of the matrix. - [DataMember] - public T M12 - { - readonly get => Row1.Y; - set => Row1.Y = value; - } - - /// Value at row 1, column 3 of the matrix. - [DataMember] - public T M13 - { - readonly get => Row1.Z; - set => Row1.Z = value; - } - - /// Value at row 2, column 1 of the matrix. - [DataMember] - public T M21 - { - readonly get => Row1.X; - set => Row1.X = value; - } - - /// Value at row 2, column 2 of the matrix. - [DataMember] - public T M22 - { - readonly get => Row2.Y; - set => Row2.Y = value; - } - - /// Value at row 2, column 3 of the matrix. - [DataMember] - public T M23 - { - readonly get => Row2.Z; - set => Row2.Z = value; - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - public unsafe Vector3D this[int x] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 1 || i < 0) - ThrowHelper(); - } - - VerifyBounds(x); - return Unsafe.Add(ref Row1, x); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - public unsafe T this[int x, int y] - { - get - { - var row = this[x]; - return row[y]; - } - } - - /// Constructs a from the given components. - public Matrix2X3(T m11, T m12, T m13, - T m21, T m22, T m23) - { - Row1 = new(m11, m12, m13); - Row2 = new(m21, m22, m23); - } - - /// - /// Constructs a from the given rows. - /// - public Matrix2X3(Vector3D row1, Vector3D row2) - { - Row1 = row1; - Row2 = row2; - } - /// Constructs a from the given . /// The source . public Matrix2X3(Matrix3X2 value) @@ -201,48 +71,6 @@ public readonly bool IsIdentity Scalar.Equal(M12, Scalar.Zero) && Scalar.Equal(M13, Scalar.Zero) && Scalar.Equal(M21, Scalar.Zero) && Scalar.Equal(M23, Scalar.Zero); - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - public static unsafe Matrix2X3 operator +(Matrix2X3 value1, Matrix2X3 value2) - { - return new(value1.Row1 + value2.Row1, value1.Row2 + value2.Row2); - } - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are equal; False otherwise. - public static unsafe bool operator ==(Matrix2X3 value1, Matrix2X3 value2) - { - return Scalar.Equal(value1.M11, value2.M11) && Scalar.Equal(value1.M22, value2.M22) && - // Check diagonal elements first for early out. - Scalar.Equal(value1.M12, value2.M12) && Scalar.Equal(value1.M13, value2.M13) && - Scalar.Equal(value1.M21, value2.M21) && Scalar.Equal(value1.M23, value2.M23); - } - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are not equal; False if they are equal. - public static unsafe bool operator !=(Matrix2X3 value1, Matrix2X3 value2) - { - return Scalar.NotEqual(value1.M11, value2.M11) || - Scalar.NotEqual(value1.M22, value2.M22) || // Check diagonal elements first for early out. - Scalar.NotEqual(value1.M12, value2.M12) || Scalar.NotEqual(value1.M13, value2.M13) || - Scalar.NotEqual(value1.M21, value2.M21) || Scalar.NotEqual(value1.M23, value2.M23); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix2X3 operator *(Matrix2X3 value1, Matrix3X3 value2) - { - return new(value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3, value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3); - } - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -252,24 +80,6 @@ public readonly bool IsIdentity return value1.X * value2.Row1 + value1.Y * value2.Row2; } - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix2X3 operator *(Matrix2X2 value1, Matrix2X3 value2) - { - return new(value1.M11 * value2.Row1 + value1.M12 * value2.Row2, value1.M21 * value2.Row1 + value2.M22 * value2.Row2); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix2X2 operator *(Matrix2X3 value1, Matrix3X2 value2) - { - return new(value1.M11 * value2.Row1 + value1.M12 * value2.Row2, value1.M21 * value2.Row1 + value1.M22 * value2.Row2); - } - /// Multiplies a matrix by a scalar value. /// The source matrix. /// The scaling factor. @@ -279,53 +89,6 @@ public readonly bool IsIdentity return new(value1.Row1 * value2, value1.Row2 * value2); } - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static unsafe Matrix2X3 operator -(Matrix2X3 value1, Matrix2X3 value2) - { - return new(value1.Row1 - value2.Row1, value1.Row2 - value2.Row2); - } - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static unsafe Matrix2X3 operator -(Matrix2X3 value) - { - return new(-value.Row1, -value.Row2); - } - - /// Returns a boolean indicating whether the given Object is equal to this matrix instance. - /// The Object to compare against. - /// True if the Object is equal to this matrix; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) - => (obj is Matrix2X3 other) && Equals(other); - - /// Returns a boolean indicating whether this matrix instance is equal to the other given matrix. - /// The matrix to compare this instance to. - /// True if the matrices are equal; False otherwise. - public readonly bool Equals(Matrix2X3 other) - => this == other; - - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - HashCode hash = default; - - hash.Add(M11); - hash.Add(M12); - hash.Add(M13); - - hash.Add(M21); - hash.Add(M22); - hash.Add(M23); - - return hash.ToHashCode(); - } - /// Returns a String representing this matrix instance. /// The string representation. public override readonly string ToString() @@ -454,7 +217,7 @@ public static explicit operator Matrix2X3(Matrix2X3 from) /// /// The type to cast to /// The casted matrix - public Matrix2X3 As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Matrix2X3 As() where TOther : INumberBase { return new(Row1.As(), Row2.As()); } diff --git a/sources/Maths/Maths/Matrix2X3.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs index 2039da3a7d..7447bdd571 100644 --- a/sources/Maths/Maths/Matrix2X3.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -2,22 +2,54 @@ namespace Silk.NET.Maths { using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.CompilerServices; + using System.Runtime.Serialization; public partial struct Matrix2X3 : IEquatable> where T : INumberBase { /// The 1st row of the matrix represented as a vector. + [IgnoreDataMember] public Vector3D Row1; /// The 2nd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector3D Row2; + /// The 1st column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector2D Column1 => new(Row1.X, Row2.X); + + /// The 2nd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector2D Column2 => new(Row1.Y, Row2.Y); + + /// The 3rd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector2D Column3 => new(Row1.Z, Row2.Z); + /// /// Constructs a from the given rows. /// - public Matrix2X3(Vector3D row1, Vector3D row2) => (Row1, Row2) = (row1, row2); + public Matrix2X3(Vector3D row1, Vector3D row2) => + (Row1, Row2) = (row1, row2); + + /// + /// Constructs a from the given components. + /// + public Matrix2X3( + T m11, T m12, T m13, + T m21, T m22, T m23) + { + Row1 = new(m11, m12, m13); + Row2 = new(m21, m22, m23); + } + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. [UnscopedRef] public ref Vector3D this[int row] { @@ -31,38 +63,50 @@ public ref Vector3D this[int row] return ref Row2; } - throw new ArgumentOutOfRangeException(nameof(row)); + throw new IndexOutOfRangeException(); } } + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. [UnscopedRef] public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M13 => ref Row1.Z; /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M23 => ref Row2.Z; /// + [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix2X3 other && Equals(other); /// @@ -133,9 +177,14 @@ public Matrix3X2 Transpose() => public static partial class Matrix2X3 { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. public static Matrix2X3 Lerp(Matrix2X3 value1, Matrix2X3 value2, T amount) where T : IFloatingPointIeee754 => - new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount)), - new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount))); + new(Vector3D.Lerp(value1.Row1, value2.Row1, amount), + Vector3D.Lerp(value1.Row2, value2.Row2, amount)); } } diff --git a/sources/Maths/Maths/Matrix2X4.Ops.cs b/sources/Maths/Maths/Matrix2X4.Ops.cs index b7402f1507..4d0f06cbd4 100644 --- a/sources/Maths/Maths/Matrix2X4.Ops.cs +++ b/sources/Maths/Maths/Matrix2X4.Ops.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; namespace Silk.NET.Maths @@ -9,7 +10,7 @@ namespace Silk.NET.Maths /// /// Methods for working with /// - public static class Matrix2X4 + public static partial class Matrix2X4 { /// Adds two matrices together. /// The first source matrix. @@ -17,7 +18,7 @@ public static class Matrix2X4 /// The resulting matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X4 Add(Matrix2X4 value1, Matrix2X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { return value1 + value2; } @@ -28,7 +29,7 @@ public static Matrix2X4 Add(Matrix2X4 value1, Matrix2X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X4 Multiply(Matrix2X4 value1, Matrix4X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -37,7 +38,7 @@ public static Matrix2X4 Multiply(Matrix2X4 value1, Matrix4X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X3 Multiply(Matrix2X4 value1, Matrix4X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -46,7 +47,7 @@ public static Matrix2X3 Multiply(Matrix2X4 value1, Matrix4X3 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X2 Multiply(Matrix2X4 value1, Matrix4X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -55,7 +56,7 @@ public static Matrix2X2 Multiply(Matrix2X4 value1, Matrix4X2 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X4 Multiply(Matrix4X2 value1, Matrix2X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; @@ -65,7 +66,7 @@ public static Matrix4X4 Multiply(Matrix4X2 value1, Matrix2X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X4 Multiply(Matrix3X2 value1, Matrix2X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; @@ -75,7 +76,7 @@ public static Matrix3X4 Multiply(Matrix3X2 value1, Matrix2X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X4 Multiply(Matrix2X2 value1, Matrix2X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a vector by a matrix. @@ -84,18 +85,7 @@ public static Matrix2X4 Multiply(Matrix2X2 value1, Matrix2X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Vector4D Multiply(Vector2D value1, Matrix2X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; - - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static unsafe Matrix2X4 Lerp(Matrix2X4 matrix1, Matrix2X4 matrix2, T amount) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new(Vector4D.Lerp(matrix1.Row1, matrix2.Row1, amount), Vector4D.Lerp(matrix1.Row2, matrix2.Row2, amount)); - } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix2X4.cs b/sources/Maths/Maths/Matrix2X4.cs index 7e6f38eabf..51d70e9c93 100644 --- a/sources/Maths/Maths/Matrix2X4.cs +++ b/sources/Maths/Maths/Matrix2X4.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -11,8 +12,7 @@ namespace Silk.NET.Maths /// A structure encapsulating a 2x4 matrix. [Serializable] [DataContract] - public struct Matrix2X4 : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + public partial struct Matrix2X4 { private static readonly Matrix2X4 _identity = new ( @@ -20,157 +20,6 @@ public struct Matrix2X4 : IEquatable> Scalar.Zero, Scalar.One, Scalar.Zero, Scalar.Zero ); - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row1; - - /// - /// Row 2 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row2; - - /// - /// Column 1 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Column1 => new(M11, M21); - - /// - /// Column 2 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Column2 => new(M12, M22); - - /// - /// Column 3 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Column3 => new(M13, M23); - - /// - /// Column 4 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Column4 => new(M14, M24); - - /// Value at row 1, column 1 of the matrix. - [DataMember] - public T M11 - { - readonly get => Row1.X; - set => Row1.X = value; - } - - /// Value at row 1, column 2 of the matrix. - [DataMember] - public T M12 - { - readonly get => Row1.Y; - set => Row1.Y = value; - } - - /// Value at row 1, column 3 of the matrix. - [DataMember] - public T M13 - { - readonly get => Row1.Z; - set => Row1.Z = value; - } - - /// Value at row 1, column 4 of the matrix. - [DataMember] - public T M14 - { - readonly get => Row1.W; - set => Row1.W = value; - } - - /// Value at row 2, column 1 of the matrix. - [DataMember] - public T M21 - { - readonly get => Row2.X; - set => Row2.X = value; - } - - /// Value at row 2, column 2 of the matrix. - [DataMember] - public T M22 - { - readonly get => Row2.Y; - set => Row2.Y = value; - } - - /// Value at row 2, column 3 of the matrix. - [DataMember] - public T M23 - { - readonly get => Row2.Z; - set => Row2.Z = value; - } - - /// Value at row 2, column 4 of the matrix. - [DataMember] - public T M24 - { - readonly get => Row2.W; - set => Row2.W = value; - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - public unsafe Vector4D this[int x] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 1 || i < 0) - ThrowHelper(); - } - - VerifyBounds(x); - return Unsafe.Add(ref Row1, x); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - public unsafe T this[int x, int j] - { - get - { - var row = this[x]; - return row[j]; - } - } - - /// - /// Constructs a from the given rows - /// - public Matrix2X4(Vector4D row1, Vector4D row2) - { - Row1 = row1; - Row2 = row2; - } - - /// Constructs a from the given components. - public Matrix2X4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24) - { - Row1 = new(m11, m12, m13, m14); - Row2 = new(m21, m22, m23, m24); - } - /// Constructs a from the given . /// The source . public Matrix2X4(Matrix3X2 value) @@ -223,51 +72,6 @@ public readonly bool IsIdentity Scalar.Equal(M14, Scalar.Zero) && Scalar.Equal(M21, Scalar.Zero) && Scalar.Equal(M23, Scalar.Zero) && Scalar.Equal(M24, Scalar.Zero); - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - public static unsafe Matrix2X4 operator +(Matrix2X4 value1, Matrix2X4 value2) - { - return new(value1.Row1 + value2.Row1, value1.Row2 + value2.Row2); - } - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are equal; False otherwise. - public static unsafe bool operator ==(Matrix2X4 value1, Matrix2X4 value2) - { - return Scalar.Equal(value1.M11, value2.M11) && - Scalar.Equal(value1.M22, value2.M22) && // Check diagonal elements first for early out. - Scalar.Equal(value1.M12, value2.M12) && Scalar.Equal(value1.M13, value2.M13) && - Scalar.Equal(value1.M14, value2.M14) && Scalar.Equal(value1.M21, value2.M21) && - Scalar.Equal(value1.M23, value2.M23) && Scalar.Equal(value1.M24, value2.M24); - } - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are not equal; False if they are equal. - public static unsafe bool operator !=(Matrix2X4 value1, Matrix2X4 value2) - { - return Scalar.NotEqual(value1.M11, value2.M11) || - Scalar.NotEqual(value1.M22, value2.M22) || // Check diagonal elements first for early out. - Scalar.NotEqual(value1.M12, value2.M12) || Scalar.NotEqual(value1.M13, value2.M13) || - Scalar.NotEqual(value1.M14, value2.M14) || Scalar.NotEqual(value1.M21, value2.M21) || - Scalar.NotEqual(value1.M23, value2.M23) || Scalar.NotEqual(value1.M24, value2.M24); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix2X4 operator *(Matrix2X4 value1, Matrix4X4 value2) - { - return new(value1.M11 * value2.Row1 + value1.M12 * value1.Row2 + value1.M13 * value2.Row3 + value1.M14 * value2.Row4, - value1.M21 * value2.Row1 + value1.M22 * value1.Row2 + value1.M23 * value2.Row3 + value1.M24 * value2.Row4); - } - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -287,32 +91,6 @@ public readonly bool IsIdentity value1.M21 * value2.Row1 + value2.M22 * value2.Row2 + value1.M23 * value2.Row3 + value1.M24 * value2.Row4); } - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix3X4 operator *(Matrix3X2 value1, Matrix2X4 value2) - { - return new - ( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2 - ); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix2X4 operator *(Matrix2X2 value1, Matrix2X4 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 - ); - } - /// Multiplies a matrix by a scalar value. /// The source matrix. /// The scaling factor. @@ -322,55 +100,6 @@ public readonly bool IsIdentity return new(value1.Row1 * value2, value1.Row2 * value2); } - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static unsafe Matrix2X4 operator -(Matrix2X4 value1, Matrix2X4 value2) - { - return new(value1.Row1 - value2.Row1, value1.Row2 - value2.Row2); - } - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static unsafe Matrix2X4 operator -(Matrix2X4 value) - { - return new(-value.Row1, -value.Row2); - } - - /// Returns a boolean indicating whether the given Object is equal to this matrix instance. - /// The Object to compare against. - /// True if the Object is equal to this matrix; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) - => (obj is Matrix2X4 other) && Equals(other); - - /// Returns a boolean indicating whether this matrix instance is equal to the other given matrix. - /// The matrix to compare this instance to. - /// True if the matrices are equal; False otherwise. - public readonly bool Equals(Matrix2X4 other) - => this == other; - - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - HashCode hash = default; - - hash.Add(M11); - hash.Add(M12); - hash.Add(M13); - hash.Add(M14); - - hash.Add(M21); - hash.Add(M22); - hash.Add(M23); - hash.Add(M24); - - return hash.ToHashCode(); - } - /// Returns a String representing this matrix instance. /// The string representation. public override readonly string ToString() @@ -553,7 +282,7 @@ public static explicit operator Matrix2X4(Matrix2X4 from) /// /// The type to cast to /// The casted matrix - public Matrix2X4 As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Matrix2X4 As() where TOther : INumberBase { return new(Row1.As(), Row2.As()); } diff --git a/sources/Maths/Maths/Matrix2X4.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs index 10496deda3..970be0f0f5 100644 --- a/sources/Maths/Maths/Matrix2X4.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -2,22 +2,58 @@ namespace Silk.NET.Maths { using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.CompilerServices; + using System.Runtime.Serialization; public partial struct Matrix2X4 : IEquatable> where T : INumberBase { /// The 1st row of the matrix represented as a vector. + [IgnoreDataMember] public Vector4D Row1; /// The 2nd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector4D Row2; + /// The 1st column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector2D Column1 => new(Row1.X, Row2.X); + + /// The 2nd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector2D Column2 => new(Row1.Y, Row2.Y); + + /// The 3rd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector2D Column3 => new(Row1.Z, Row2.Z); + + /// The 4th column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector2D Column4 => new(Row1.W, Row2.W); + /// /// Constructs a from the given rows. /// - public Matrix2X4(Vector4D row1, Vector4D row2) => (Row1, Row2) = (row1, row2); + public Matrix2X4(Vector4D row1, Vector4D row2) => + (Row1, Row2) = (row1, row2); + /// + /// Constructs a from the given components. + /// + public Matrix2X4( + T m11, T m12, T m13, T m14, + T m21, T m22, T m23, T m24) + { + Row1 = new(m11, m12, m13, m14); + Row2 = new(m21, m22, m23, m24); + } + + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. [UnscopedRef] public ref Vector4D this[int row] { @@ -31,46 +67,60 @@ public ref Vector4D this[int row] return ref Row2; } - throw new ArgumentOutOfRangeException(nameof(row)); + throw new IndexOutOfRangeException(); } } + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. [UnscopedRef] public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M13 => ref Row1.Z; /// Gets the element in the 1st row and 4th column of the matrix. + [DataMember] [UnscopedRef] public ref T M14 => ref Row1.W; /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M23 => ref Row2.Z; /// Gets the element in the 2nd row and 4th column of the matrix. + [DataMember] [UnscopedRef] public ref T M24 => ref Row2.W; /// + [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix2X4 other && Equals(other); /// @@ -151,9 +201,14 @@ public Matrix4X2 Transpose() => public static partial class Matrix2X4 { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. public static Matrix2X4 Lerp(Matrix2X4 value1, Matrix2X4 value2, T amount) where T : IFloatingPointIeee754 => - new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount), T.Lerp(value1.M14, value2.M14, amount)), - new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount), T.Lerp(value1.M24, value2.M24, amount))); + new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), + Vector4D.Lerp(value1.Row2, value2.Row2, amount)); } } diff --git a/sources/Maths/Maths/Matrix3X2.Ops.cs b/sources/Maths/Maths/Matrix3X2.Ops.cs index 20d7ff905a..4f5194fe0a 100644 --- a/sources/Maths/Maths/Matrix3X2.Ops.cs +++ b/sources/Maths/Maths/Matrix3X2.Ops.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; namespace Silk.NET.Maths @@ -9,7 +10,7 @@ namespace Silk.NET.Maths /// /// Methods for working with /// - public static class Matrix3X2 + public static partial class Matrix3X2 { #if MATHF private const float RotationEpsilon = 0.001f * MathF.PI / 180f; // 0.1% of a degree @@ -23,14 +24,14 @@ public static class Matrix3X2 /// The matrix containing the summed values. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X2 Add(Matrix3X2 value1, Matrix3X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 + value2; /// Creates a rotation matrix using the given rotation in radians. /// The amount of rotation, in radians. /// A rotation matrix. public static Matrix3X2 CreateRotation(T radians) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { radians = Scalar.IEEERemainder(radians, Scalar.Tau); @@ -121,7 +122,7 @@ public static Matrix3X2 CreateRotation(T radians) /// The center point. /// A rotation matrix. public static Matrix3X2 CreateRotation(T radians, Vector2D centerPoint) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { radians = Scalar.IEEERemainder(radians, Scalar.Tau); @@ -210,7 +211,7 @@ public static Matrix3X2 CreateRotation(T radians, Vector2D centerPoint) /// The scale to use. /// A scaling matrix. public static Matrix3X2 CreateScale(Vector2D scales) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X2 result = Matrix3X2.Identity; @@ -225,7 +226,7 @@ public static Matrix3X2 CreateScale(Vector2D scales) /// Value to scale by on the Y-axis. /// A scaling matrix. public static Matrix3X2 CreateScale(T xScale, T yScale) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X2 result = Matrix3X2.Identity; @@ -241,7 +242,7 @@ public static Matrix3X2 CreateScale(T xScale, T yScale) /// The center point. /// A scaling matrix. public static Matrix3X2 CreateScale(T xScale, T yScale, Vector2D centerPoint) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X2 result = Matrix3X2.Identity; @@ -261,7 +262,7 @@ public static Matrix3X2 CreateScale(T xScale, T yScale, Vector2D center /// The center offset. /// A scaling matrix. public static Matrix3X2 CreateScale(Vector2D scales, Vector2D centerPoint) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X2 result = Matrix3X2.Identity; @@ -280,7 +281,7 @@ public static Matrix3X2 CreateScale(Vector2D scales, Vector2D center /// The uniform scale to use. /// A scaling matrix. public static Matrix3X2 CreateScale(T scale) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X2 result = Matrix3X2.Identity; @@ -295,7 +296,7 @@ public static Matrix3X2 CreateScale(T scale) /// The center offset. /// A scaling matrix. public static Matrix3X2 CreateScale(T scale, Vector2D centerPoint) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X2 result = Matrix3X2.Identity; @@ -315,7 +316,7 @@ public static Matrix3X2 CreateScale(T scale, Vector2D centerPoint) /// The Y angle, in radians. /// A skew matrix. public static Matrix3X2 CreateSkew(T radiansX, T radiansY) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X2 result = Matrix3X2.Identity; @@ -334,7 +335,7 @@ public static Matrix3X2 CreateSkew(T radiansX, T radiansY) /// The center point. /// A skew matrix. public static Matrix3X2 CreateSkew(T radiansX, T radiansY, Vector2D centerPoint) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X2 result = Matrix3X2.Identity; @@ -354,10 +355,10 @@ public static Matrix3X2 CreateSkew(T radiansX, T radiansY, Vector2D cen } /// Creates a translation matrix from the given vector. - /// The translation position. ` + /// The translation position. /// A translation matrix. public static Matrix3X2 CreateTranslation(Vector2D position) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X2 result = Matrix3X2.Identity; @@ -372,7 +373,7 @@ public static Matrix3X2 CreateTranslation(Vector2D position) /// The Y position. /// A translation matrix. public static Matrix3X2 CreateTranslation(T xPosition, T yPosition) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X2 result = Matrix3X2.Identity; @@ -387,11 +388,11 @@ public static Matrix3X2 CreateTranslation(T xPosition, T yPosition) /// The output matrix. /// True if the operation succeeded, False otherwise. public static bool Invert(Matrix3X2 matrix, out Matrix3X2 result) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : IFloatingPointIeee754 { T det = Scalar.Subtract(Scalar.Multiply(matrix.M11, matrix.M22), Scalar.Multiply(matrix.M21, matrix.M12)); - if (!Scalar.GreaterThanOrEqual(Scalar.Abs(det), Scalar.Epsilon)) + if (!(T.Abs(det) >= T.Epsilon)) { result = new(Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN); return false; @@ -413,26 +414,13 @@ public static bool Invert(Matrix3X2 matrix, out Matrix3X2 result) return true; } - /// Linearly interpolates from matrix1 to matrix2, based on the third parameter. - /// The first source matrix. - /// The second source matrix. - /// The relative weighting of matrix2. - /// The interpolated matrix. - public static Matrix3X2 Lerp(Matrix3X2 matrix1, Matrix3X2 matrix2, T amount) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new(Vector2D.Lerp(matrix1.Row1, matrix2.Row1, amount), - Vector2D.Lerp(matrix1.Row2, matrix2.Row2, amount), - Vector2D.Lerp(matrix1.Row3, matrix2.Row3, amount)); - } - /// Multiplies two matrices together and returns the resulting matrix. /// The first source matrix. /// The second source matrix. /// The product matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X2 Multiply(Matrix3X2 value1, Matrix2X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a vector by a matrix. @@ -441,7 +429,7 @@ public static Matrix3X2 Multiply(Matrix3X2 value1, Matrix2X2 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Vector2D Multiply(Vector3D value1, Matrix3X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies two matrices together and returns the resulting matrix. @@ -450,7 +438,7 @@ public static Vector2D Multiply(Vector3D value1, Matrix3X2 value2) /// The product matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X3 Multiply(Matrix3X2 value1, Matrix2X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies two matrices together and returns the resulting matrix. @@ -459,7 +447,7 @@ public static Matrix3X3 Multiply(Matrix3X2 value1, Matrix2X3 value2) /// The product matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X2 Multiply(Matrix2X3 value1, Matrix3X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies two matrices together and returns the resulting matrix. @@ -468,7 +456,7 @@ public static Matrix2X2 Multiply(Matrix2X3 value1, Matrix3X2 value2) /// The product matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X3 Multiply(Matrix2X3 value1, Matrix3X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Scales all elements in a matrix by the given scalar factor. @@ -477,7 +465,7 @@ public static Matrix2X3 Multiply(Matrix2X3 value1, Matrix3X3 value2) /// The resulting matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X2 Multiply(Matrix3X2 value1, T value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Negates the given matrix by multiplying all values by -1. @@ -485,7 +473,7 @@ public static Matrix3X2 Multiply(Matrix3X2 value1, T value2) /// The negated matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X2 Negate(Matrix3X2 value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => -value; /// Subtracts each matrix element in value2 from its corresponding element in value1. @@ -494,7 +482,7 @@ public static Matrix3X2 Negate(Matrix3X2 value) /// The matrix containing the resulting values. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X2 Subtract(Matrix3X2 value1, Matrix3X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 - value2; } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix3X2.cs b/sources/Maths/Maths/Matrix3X2.cs index 8d80e72d79..7f3224660c 100644 --- a/sources/Maths/Maths/Matrix3X2.cs +++ b/sources/Maths/Maths/Matrix3X2.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -11,9 +12,7 @@ namespace Silk.NET.Maths /// A structure encapsulating a 3x2 matrix. [Serializable] [DataContract] - public struct Matrix3X2 - : IEquatable> - where T : unmanaged, IFormattable, IComparable, IEquatable + public partial struct Matrix3X2 { private static readonly Matrix3X2 _identity = new( Scalar.One, Scalar.Zero, @@ -21,139 +20,6 @@ public struct Matrix3X2 Scalar.Zero, Scalar.Zero ); - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Row1; - - /// - /// Row 2 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Row2; - - /// - /// Row 3 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Row3; - - /// - /// Column 1 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Column1 => new(Row1.X, Row2.X, Row3.X); - - /// - /// Column 2 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Column2 => new(Row1.Y, Row2.Y, Row3.Y); - - /// The first element of the first row - [DataMember] - public T M11 - { - readonly get => Row1.X; - set => Row1.X = value; - } - - /// The second element of the first row - [DataMember] - public T M12 - { - readonly get => Row1.Y; - set => Row1.Y = value; - } - - /// The first element of the second row - [DataMember] - public T M21 - { - readonly get => Row2.X; - set => Row2.X = value; - } - - /// The second element of the second row - [DataMember] - public T M22 - { - readonly get => Row2.Y; - set => Row2.Y = value; - } - - /// The first element of the third row - [DataMember] - public T M31 - { - readonly get => Row3.X; - set => Row3.X = value; - } - - /// The second element of the third row - [DataMember] - public T M32 - { - readonly get => Row3.Y; - set => Row3.Y = value; - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - public unsafe Vector2D this[int x] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 2 || i < 0) - ThrowHelper(); - } - - VerifyBounds(x); - return Unsafe.Add(ref Row1, x); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - public unsafe T this[int x, int y] - { - get - { - var row = this[x]; - return row[y]; - } - } - - /// Constructs a from the given components. - public Matrix3X2(T m11, T m12, - T m21, T m22, - T m31, T m32) - { - Row1 = new(m11, m12); - Row2 = new(m21, m22); - Row3 = new(m31, m32); - } - - /// - /// Constructs a from the given rows. - /// - public Matrix3X2(Vector2D row1, Vector2D row2, Vector2D row3) - { - Row1 = row1; - Row2 = row2; - Row3 = row3; - } - /// Constructs a from the given Matrix4x3. /// The source Matrix4x3. public Matrix3X2(Matrix4X3 value) @@ -206,54 +72,6 @@ public Matrix3X2(Matrix4X2 value) [IgnoreDataMember] public readonly bool IsIdentity => this == Identity; - /// Adds each matrix element in value1 with its corresponding element in value2. - /// The first source matrix. - /// The second source matrix. - /// The matrix containing the summed values. - public static Matrix3X2 operator +(Matrix3X2 value1, Matrix3X2 value2) - { - return new(value1.Row1 + value2.Row1, value1.Row2 + value2.Row2, value1.Row3 + value2.Row3); - } - - /// Returns a boolean indicating whether the given matrices are equal. - /// The first source matrix. - /// The second source matrix. - /// True if the matrices are equal; False otherwise. - public static bool operator ==(Matrix3X2 value1, Matrix3X2 value2) - { - return (Scalar.Equal(value1.M11, value2.M11) - && Scalar.Equal(value1.M22, value2.M22) // Check diagonal element first for early out - && Scalar.Equal(value1.M12, value2.M12) - && Scalar.Equal(value1.M21, value2.M21) - && Scalar.Equal(value1.M31, value2.M31) - && Scalar.Equal(value1.M32, value2.M32)); - } - - /// Returns a boolean indicating whether the given matrices are not equal. - /// The first source matrix. - /// The second source matrix. - /// True if the matrices are not equal; False if they are equal. - public static bool operator !=(Matrix3X2 value1, Matrix3X2 value2) - { - return (Scalar.NotEqual(value1.M11, value2.M11) - || Scalar.NotEqual(value1.M22, value2.M22) // Check diagonal element first for early out - || Scalar.NotEqual(value1.M12, value2.M12) - || Scalar.NotEqual(value1.M21, value2.M21) - || Scalar.NotEqual(value1.M31, value2.M31) - || Scalar.NotEqual(value1.M32, value2.M32)); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix3X3 operator *(Matrix3X2 value1, Matrix2X3 value2) - { - return new(value1.M11 * value2.Row1 * value1.M12 * value2.Row2, - value1.M21 * value2.Row1 * value1.M22 * value2.Row2, - value1.M31 * value2.Row1 * value1.M32 * value2.Row2); - } - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -263,19 +81,6 @@ public Matrix3X2(Matrix4X2 value) return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3; } - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix3X2 operator *(Matrix3X2 value1, Matrix2X2 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2 - ); - } - /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -298,38 +103,6 @@ public Matrix3X2(Matrix4X2 value) return new(value1.Row1 * value2, value1.Row2 * value2, value1.Row3 * value2); } - /// Subtracts each matrix element in value2 from its corresponding element in value1. - /// The first source matrix. - /// The second source matrix. - /// The matrix containing the resulting values. - public static Matrix3X2 operator -(Matrix3X2 value1, Matrix3X2 value2) - { - return new(value1.Row1 - value2.Row1, value1.Row2 - value2.Row2, value1.Row3 - value2.Row3); - } - - /// Negates the given matrix by multiplying all values by -1. - /// The source matrix. - /// The negated matrix. - public static Matrix3X2 operator -(Matrix3X2 value) - { - return new(-value.Row1, -value.Row2, -value.Row3); - } - - /// Returns a boolean indicating whether the given Object is equal to this matrix instance. - /// The Object to compare against. - /// True if the Object is equal to this matrix; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) - => (obj is Matrix3X2 other) && Equals(other); - - /// Returns a boolean indicating whether the matrix is equal to the other given matrix. - /// The other matrix to test equality against. - /// True if this matrix is equal to other; False otherwise. - public readonly bool Equals(Matrix3X2 other) - { - return this == other; - } - /// Calculates the determinant for this matrix. /// The determinant is calculated by expanding the matrix with a third column whose values are (0,0,1). /// The determinant. @@ -354,13 +127,6 @@ public readonly T GetDeterminant() return Scalar.Subtract(Scalar.Multiply(M11, M22), Scalar.Multiply(M21, M12)); } - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - return HashCode.Combine(M11, M12, M21, M22, M31, M32); - } - /// Returns a String representing this matrix instance. /// The string representation. public override readonly string ToString() @@ -532,7 +298,7 @@ public static explicit operator Matrix3X2(Matrix3X2 from) /// /// The type to cast to /// The casted matrix - public Matrix3X2 As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Matrix3X2 As() where TOther : INumberBase { return new(Row1.As(), Row2.As(), Row3.As()); } diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index bde0ebf4e0..1caf6ea066 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -2,25 +2,56 @@ namespace Silk.NET.Maths { using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.CompilerServices; + using System.Runtime.Serialization; public partial struct Matrix3X2 : IEquatable> where T : INumberBase { /// The 1st row of the matrix represented as a vector. + [IgnoreDataMember] public Vector2D Row1; /// The 2nd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector2D Row2; /// The 3rd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector2D Row3; + /// The 1st column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector3D Column1 => new(Row1.X, Row2.X, Row3.X); + + /// The 2nd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector3D Column2 => new(Row1.Y, Row2.Y, Row3.Y); + /// /// Constructs a from the given rows. /// - public Matrix3X2(Vector2D row1, Vector2D row2, Vector2D row3) => (Row1, Row2, Row3) = (row1, row2, row3); + public Matrix3X2(Vector2D row1, Vector2D row2, Vector2D row3) => + (Row1, Row2, Row3) = (row1, row2, row3); + /// + /// Constructs a from the given components. + /// + public Matrix3X2( + T m11, T m12, + T m21, T m22, + T m31, T m32) + { + Row1 = new(m11, m12); + Row2 = new(m21, m22); + Row3 = new(m31, m32); + } + + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. [UnscopedRef] public ref Vector2D this[int row] { @@ -36,38 +67,50 @@ public ref Vector2D this[int row] return ref Row3; } - throw new ArgumentOutOfRangeException(nameof(row)); + throw new IndexOutOfRangeException(); } } + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. [UnscopedRef] public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M12 => ref Row1.Y; /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M22 => ref Row2.Y; /// Gets the element in the 3rd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M32 => ref Row3.Y; /// + [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix3X2 other && Equals(other); /// @@ -143,10 +186,15 @@ public Matrix2X3 Transpose() => public static partial class Matrix3X2 { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. public static Matrix3X2 Lerp(Matrix3X2 value1, Matrix3X2 value2, T amount) where T : IFloatingPointIeee754 => - new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount)), - new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount)), - new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount))); + new(Vector2D.Lerp(value1.Row1, value2.Row1, amount), + Vector2D.Lerp(value1.Row2, value2.Row2, amount), + Vector2D.Lerp(value1.Row3, value2.Row3, amount)); } } diff --git a/sources/Maths/Maths/Matrix3X3.Ops.cs b/sources/Maths/Maths/Matrix3X3.Ops.cs index aa3905c23a..5a77409ea4 100644 --- a/sources/Maths/Maths/Matrix3X3.Ops.cs +++ b/sources/Maths/Maths/Matrix3X3.Ops.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; namespace Silk.NET.Maths @@ -9,21 +10,22 @@ namespace Silk.NET.Maths /// /// Methods for working with /// - public static class Matrix3X3 + public static partial class Matrix3X3 { private const float BillboardEpsilon = 1e-4f; private const float DecomposeEpsilon = 0.0001f; private struct CanonicalBasis - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { public Vector3D Row0; public Vector3D Row1; public Vector3D Row2; }; + /* private struct VectorBasis - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { #pragma warning disable 649 public unsafe Vector3D* Element0; @@ -31,6 +33,7 @@ private struct VectorBasis public unsafe Vector3D* Element2; #pragma warning restore 649 } + */ /// Adds two matrices together. /// The first source matrix. @@ -38,7 +41,7 @@ private struct VectorBasis /// The resulting matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X3 Add(Matrix3X3 value1, Matrix3X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { return value1 + value2; } @@ -50,7 +53,7 @@ public static Matrix3X3 Add(Matrix3X3 value1, Matrix3X3 value2) /// The forward vector of the camera. /// The created billboard matrix public static Matrix3X3 CreateBillboard(Vector3D objectPosition, Vector3D cameraPosition, Vector3D cameraUpVector, Vector3D cameraForwardVector) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Vector3D zaxis = objectPosition - cameraPosition; var norm = zaxis.LengthSquared; @@ -75,7 +78,7 @@ public static Matrix3X3 CreateBillboard(Vector3D objectPosition, Vector /// The angle to rotate around the given axis, in radians. /// The rotation matrix. public static Matrix3X3 CreateFromAxisAngle(Vector3D axis, T angle) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { // a: angle // x, y, z: unit vector for axis. @@ -128,7 +131,7 @@ public static Matrix3X3 CreateFromAxisAngle(Vector3D axis, T angle) /// The source Quaternion. /// The rotation matrix. public static Matrix3X3 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quaternion quaternion) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X3 result = Matrix3X3.Identity; @@ -165,7 +168,7 @@ public static Matrix3X3 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quatern /// Angle of rotation, in radians, around the Z-axis. /// The rotation matrix. public static Matrix3X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Legacy.Quaternion q = Legacy.Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(q); @@ -175,7 +178,7 @@ public static Matrix3X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) /// The amount, in radians, by which to rotate around the X-axis. /// The rotation matrix. public static Matrix3X3 CreateRotationX(T radians) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X3 result = Matrix3X3.Identity; @@ -199,7 +202,7 @@ public static Matrix3X3 CreateRotationX(T radians) /// The amount, in radians, by which to rotate around the Y-axis. /// The rotation matrix. public static Matrix3X3 CreateRotationY(T radians) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X3 result = Matrix3X3.Identity; @@ -222,7 +225,7 @@ public static Matrix3X3 CreateRotationY(T radians) /// The amount, in radians, by which to rotate around the Z-axis. /// The rotation matrix. public static Matrix3X3 CreateRotationZ(T radians) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X3 result = Matrix3X3.Identity; @@ -247,7 +250,7 @@ public static Matrix3X3 CreateRotationZ(T radians) /// Value to scale by on the Z-axis. /// The scaling matrix. public static Matrix3X3 CreateScale(T xScale, T yScale, T zScale) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X3 result = Matrix3X3.Identity; result.M11 = xScale; @@ -260,7 +263,7 @@ public static Matrix3X3 CreateScale(T xScale, T yScale, T zScale) /// The vector containing the amount to scale by on each axis. /// The scaling matrix. public static Matrix3X3 CreateScale(Vector3D scales) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X3 result = Matrix3X3.Identity; result.M11 = scales.X; @@ -273,7 +276,7 @@ public static Matrix3X3 CreateScale(Vector3D scales) /// The uniform scaling factor. /// The scaling matrix. public static Matrix3X3 CreateScale(T scale) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix3X3 result = Matrix3X3.Identity; @@ -290,7 +293,7 @@ public static Matrix3X3 CreateScale(T scale) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X3 Multiply(Matrix3X3 value1, Matrix3X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -299,7 +302,7 @@ public static Matrix3X3 Multiply(Matrix3X3 value1, Matrix3X3 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X3 Multiply(Matrix2X3 value1, Matrix3X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; @@ -309,7 +312,7 @@ public static Matrix2X3 Multiply(Matrix2X3 value1, Matrix3X3 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X2 Multiply(Matrix3X3 value1, Matrix3X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; @@ -319,7 +322,7 @@ public static Matrix3X2 Multiply(Matrix3X3 value1, Matrix3X2 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X3 Multiply(Matrix4X3 value1, Matrix3X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; @@ -329,7 +332,7 @@ public static Matrix4X3 Multiply(Matrix4X3 value1, Matrix3X3 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X4 Multiply(Matrix3X3 value1, Matrix3X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by a scalar value. @@ -338,7 +341,7 @@ public static Matrix3X4 Multiply(Matrix3X3 value1, Matrix3X4 value2) /// The scaled matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X3 Multiply(Matrix3X3 value1, T value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a vector by a matrix. @@ -347,7 +350,7 @@ public static Matrix3X3 Multiply(Matrix3X3 value1, T value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Vector3D Multiply(Vector3D value1, Matrix3X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Returns a new matrix with the negated elements of the given matrix. @@ -355,7 +358,7 @@ public static Vector3D Multiply(Vector3D value1, Matrix3X3 value2) /// The negated matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X3 Negate(Matrix3X3 value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => -value; /// Subtracts the second matrix from the first. @@ -364,9 +367,10 @@ public static Matrix3X3 Negate(Matrix3X3 value) /// The result of the subtraction. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X3 Subtract(Matrix3X3 value1, Matrix3X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 - value2; + /* /// Attempts to extract the scale, translation, and rotation components from the given scale/rotation/translation matrix. /// If successful, the out parameters will contained the extracted values. /// The source matrix. @@ -374,7 +378,7 @@ public static Matrix3X3 Subtract(Matrix3X3 value1, Matrix3X3 value2) /// The rotation component of the transformation matrix. /// True if the source matrix was successfully decomposed; False otherwise. public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out Silk.NET.Maths.Legacy.Quaternion rotation) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { bool result = true; @@ -559,28 +563,14 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out return result; } - - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static unsafe Matrix3X3 Lerp(Matrix3X3 matrix1, Matrix3X3 matrix2, T amount) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Vector3D.Lerp(matrix1.Row1, matrix2.Row1, amount), - Vector3D.Lerp(matrix1.Row2, matrix2.Row2, amount), - Vector3D.Lerp(matrix1.Row3, matrix2.Row3, amount) - ); - } + */ /// Transforms the given matrix by applying the given Quaternion rotation. /// The source matrix to transform. /// The rotation to apply. /// The transformed matrix. public static Matrix3X3 Transform(Matrix3X3 value, Legacy.Quaternion rotation) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { // Compute rotation matrix. T x2 = Scalar.Add(rotation.X, rotation.X); @@ -620,7 +610,7 @@ public static Matrix3X3 Transform(Matrix3X3 value, Legacy.Quaternion /// The source matrix. /// The transposed matrix. public static unsafe Matrix3X3 Transpose(Matrix3X3 matrix) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { return new(matrix.Column1, matrix.Column2, matrix.Column3); } diff --git a/sources/Maths/Maths/Matrix3X3.cs b/sources/Maths/Maths/Matrix3X3.cs index 755697a772..b5161c146d 100644 --- a/sources/Maths/Maths/Matrix3X3.cs +++ b/sources/Maths/Maths/Matrix3X3.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -11,179 +12,8 @@ namespace Silk.NET.Maths /// A structure encapsulating a 3x3 matrix. [Serializable] [DataContract] - public struct Matrix3X3 : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + public partial struct Matrix3X3 { - private static readonly Matrix3X3 _identity = new - ( - Scalar.One, Scalar.Zero, Scalar.Zero, - Scalar.Zero, Scalar.One, Scalar.Zero, - Scalar.Zero, Scalar.Zero, Scalar.One - ); - - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Row1; - - /// - /// Row 2 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Row2; - - /// - /// Row 3 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Row3; - - /// - /// Column 1 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Column1 => new(Row1.X, Row2.X, Row3.X); - - - /// - /// Column 2 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Column2 => new(Row1.Y, Row2.Y, Row3.Y); - - - /// - /// Column 3 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Column3 => new(Row1.Z, Row2.Z, Row3.Z); - - /// Value at row 1, column 1 of the matrix. - [DataMember] - public T M11 - { - readonly get => Row1.X; - set => Row1.X = value; - } - - /// Value at row 1, column 2 of the matrix. - [DataMember] - public T M12 - { - readonly get => Row1.Y; - set => Row1.Y = value; - } - - /// Value at row 1, column 3 of the matrix. - [DataMember] - public T M13 - { - readonly get => Row1.Z; - set => Row1.Z = value; - } - - /// Value at row 2, column 1 of the matrix. - [DataMember] - public T M21 - { - readonly get => Row2.X; - set => Row2.X = value; - } - - /// Value at row 2, column 2 of the matrix. - [DataMember] - public T M22 - { - readonly get => Row2.Y; - set => Row2.Y = value; - } - - /// Value at row 2, column 3 of the matrix. - [DataMember] - public T M23 - { - readonly get => Row2.Z; - set => Row2.Z = value; - } - - /// Value at row 3, column 1 of the matrix. - [DataMember] - public T M31 - { - readonly get => Row3.X; - set => Row3.X = value; - } - - /// Value at row 3, column 2 of the matrix. - [DataMember] - public T M32 - { - readonly get => Row3.Y; - set => Row3.Y = value; - } - - /// Value at row 3, column 3 of the matrix. - [DataMember] - public T M33 - { - readonly get => Row3.Z; - set => Row3.Z = value; - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - public unsafe Vector3D this[int x] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 2 || i < 0) - ThrowHelper(); - } - - VerifyBounds(x); - return Unsafe.Add(ref Row1, x); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - public unsafe T this[int x, int i] - { - get - { - var row = this[x]; - return row[i]; - } - } - - /// - /// Constructs a from the given rows. - /// - public Matrix3X3(Vector3D row1, Vector3D row2, Vector3D row3) - { - Row1 = row1; - Row2 = row2; - Row3 = row3; - } - - /// Constructs a from the given components. - public Matrix3X3(T m11, T m12, T m13, T m21, T m22, T m23, T m31, T m32, T m33) - { - Row1 = new(m11, m12, m13); - Row2 = new(m21, m22, m23); - Row3 = new(m31, m32, m33); - } - /// Constructs a from the given . /// The source . public Matrix3X3(Matrix3X2 value) @@ -247,9 +77,6 @@ public Matrix3X3(Matrix4X4 value) Row3 = new(value.M31, value.M32, value.M33); } - /// Returns the multiplicative identity matrix. - public static Matrix3X3 Identity => _identity; - /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] public readonly bool IsIdentity @@ -259,55 +86,6 @@ public readonly bool IsIdentity Scalar.Equal(M21, Scalar.Zero) && Scalar.Equal(M23, Scalar.Zero) && Scalar.Equal(M31, Scalar.Zero) && Scalar.Equal(M32, Scalar.Zero); - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - public static unsafe Matrix3X3 operator +(Matrix3X3 value1, Matrix3X3 value2) - { - return new(value1.Row1 + value2.Row1, value1.Row2 + value2.Row2, value1.Row3 + value2.Row3); - } - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are equal; False otherwise. - public static unsafe bool operator ==(Matrix3X3 value1, Matrix3X3 value2) - { - return Scalar.Equal(value1.M11, value2.M11) && Scalar.Equal(value1.M22, value2.M22) && - Scalar.Equal(value1.M33, value2.M33) && - // Check diagonal elements first for early out. - Scalar.Equal(value1.M12, value2.M12) && Scalar.Equal(value1.M13, value2.M13) && - Scalar.Equal(value1.M21, value2.M21) && Scalar.Equal(value1.M23, value2.M23) && - Scalar.Equal(value1.M31, value2.M31) && Scalar.Equal(value1.M32, value2.M32); - } - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are not equal; False if they are equal. - public static unsafe bool operator !=(Matrix3X3 value1, Matrix3X3 value2) - { - return Scalar.NotEqual(value1.M11, value2.M11) || Scalar.NotEqual(value1.M22, value2.M22) || - Scalar.NotEqual(value1.M33, value2.M33) || // Check diagonal elements first for early out. - Scalar.NotEqual(value1.M12, value2.M12) || Scalar.NotEqual(value1.M13, value2.M13) || - Scalar.NotEqual(value1.M21, value2.M21) || Scalar.NotEqual(value1.M23, value2.M23) || - Scalar.NotEqual(value1.M31, value2.M31) || Scalar.NotEqual(value1.M32, value2.M32); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix3X3 operator *(Matrix3X3 value1, Matrix3X3 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2 + value1.M33 * value2.Row3 - ); - } - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -326,36 +104,6 @@ public readonly bool IsIdentity return new(value1.Row1 * value2, value1.Row2 * value2, value1.Row3 * value2); } - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static unsafe Matrix3X3 operator -(Matrix3X3 value1, Matrix3X3 value2) - { - return new(value1.Row1 - value2.Row1, value1.Row2 - value2.Row2, value1.Row3 - value2.Row3); - } - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static unsafe Matrix3X3 operator -(Matrix3X3 value) - { - return new(-value.Row1, -value.Row2, -value.Row3); - } - - /// Returns a boolean indicating whether the given Object is equal to this matrix instance. - /// The Object to compare against. - /// True if the Object is equal to this matrix; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) - => (obj is Matrix3X3 other) && Equals(other); - - /// Returns a boolean indicating whether this matrix instance is equal to the other given matrix. - /// The matrix to compare this instance to. - /// True if the matrices are equal; False otherwise. - public readonly bool Equals(Matrix3X3 other) - => this == other; - /// Calculates the determinant of the matrix. /// The determinant of the matrix. public readonly T GetDeterminant() @@ -375,27 +123,6 @@ public readonly T GetDeterminant() Scalar.Multiply(c, Scalar.Subtract(Scalar.Multiply(d, h), Scalar.Multiply(e, g)))); } - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - HashCode hash = default; - - hash.Add(M11); - hash.Add(M12); - hash.Add(M13); - - hash.Add(M21); - hash.Add(M22); - hash.Add(M23); - - hash.Add(M31); - hash.Add(M32); - hash.Add(M33); - - return hash.ToHashCode(); - } - /// Returns a String representing this matrix instance. /// The string representation. public override readonly string ToString() @@ -541,7 +268,7 @@ public static explicit operator Matrix3X3(Matrix3X3 from) /// /// The type to cast to /// The casted matrix - public Matrix3X3 As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Matrix3X3 As() where TOther : INumberBase { return new(Row1.As(), Row2.As(), Row3.As()); } diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index df79a5c810..ad3c0b5b2a 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -2,31 +2,66 @@ namespace Silk.NET.Maths { using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.CompilerServices; + using System.Runtime.Serialization; public partial struct Matrix3X3 : IEquatable> where T : INumberBase { /// The multiplicative identity matrix of size 3x3. - public static readonly Matrix3X3 Identity = new( + public static Matrix3X3 Identity { get; } = new( new(T.MultiplicativeIdentity, T.Zero, T.Zero), new(T.Zero, T.MultiplicativeIdentity, T.Zero), new(T.Zero, T.Zero, T.MultiplicativeIdentity)); /// The 1st row of the matrix represented as a vector. + [IgnoreDataMember] public Vector3D Row1; /// The 2nd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector3D Row2; /// The 3rd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector3D Row3; + /// The 1st column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector3D Column1 => new(Row1.X, Row2.X, Row3.X); + + /// The 2nd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector3D Column2 => new(Row1.Y, Row2.Y, Row3.Y); + + /// The 3rd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector3D Column3 => new(Row1.Z, Row2.Z, Row3.Z); + /// /// Constructs a from the given rows. /// - public Matrix3X3(Vector3D row1, Vector3D row2, Vector3D row3) => (Row1, Row2, Row3) = (row1, row2, row3); + public Matrix3X3(Vector3D row1, Vector3D row2, Vector3D row3) => + (Row1, Row2, Row3) = (row1, row2, row3); + + /// + /// Constructs a from the given components. + /// + public Matrix3X3( + T m11, T m12, T m13, + T m21, T m22, T m23, + T m31, T m32, T m33) + { + Row1 = new(m11, m12, m13); + Row2 = new(m21, m22, m23); + Row3 = new(m31, m32, m33); + } + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. [UnscopedRef] public ref Vector3D this[int row] { @@ -42,50 +77,65 @@ public ref Vector3D this[int row] return ref Row3; } - throw new ArgumentOutOfRangeException(nameof(row)); + throw new IndexOutOfRangeException(); } } + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. [UnscopedRef] public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M13 => ref Row1.Z; /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M23 => ref Row2.Z; /// Gets the element in the 3rd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M33 => ref Row3.Z; /// + [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix3X3 other && Equals(other); /// @@ -170,10 +220,15 @@ public Matrix3X3 Transpose() => public static partial class Matrix3X3 { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. public static Matrix3X3 Lerp(Matrix3X3 value1, Matrix3X3 value2, T amount) where T : IFloatingPointIeee754 => - new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount)), - new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount)), - new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount), T.Lerp(value1.M33, value2.M33, amount))); + new(Vector3D.Lerp(value1.Row1, value2.Row1, amount), + Vector3D.Lerp(value1.Row2, value2.Row2, amount), + Vector3D.Lerp(value1.Row3, value2.Row3, amount)); } } diff --git a/sources/Maths/Maths/Matrix3X4.Ops.cs b/sources/Maths/Maths/Matrix3X4.Ops.cs index 3c9c07af8a..ae25df3fb3 100644 --- a/sources/Maths/Maths/Matrix3X4.Ops.cs +++ b/sources/Maths/Maths/Matrix3X4.Ops.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; namespace Silk.NET.Maths @@ -9,7 +10,7 @@ namespace Silk.NET.Maths /// /// Methods for working with /// - public static class Matrix3X4 + public static partial class Matrix3X4 { /// Adds two matrices together. /// The first source matrix. @@ -17,7 +18,7 @@ public static class Matrix3X4 /// The resulting matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X4 Add(Matrix3X4 value1, Matrix3X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { return value1 + value2; } @@ -28,7 +29,7 @@ public static Matrix3X4 Add(Matrix3X4 value1, Matrix3X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X3 Multiply(Matrix3X4 value1, Matrix4X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -37,7 +38,7 @@ public static Matrix3X3 Multiply(Matrix3X4 value1, Matrix4X3 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X4 Multiply(Matrix3X4 value1, Matrix4X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -46,7 +47,7 @@ public static Matrix3X4 Multiply(Matrix3X4 value1, Matrix4X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X4 Multiply(Matrix3X3 value1, Matrix3X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; @@ -56,7 +57,7 @@ public static Matrix3X4 Multiply(Matrix3X3 value1, Matrix3X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X4 Multiply(Matrix4X3 value1, Matrix3X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by a scalar value. @@ -65,7 +66,7 @@ public static Matrix4X4 Multiply(Matrix4X3 value1, Matrix3X4 value2) /// The scaled matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X4 Multiply(Matrix3X4 value1, T value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a vector by a matrix. @@ -74,7 +75,7 @@ public static Matrix3X4 Multiply(Matrix3X4 value1, T value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Vector4D Multiply(Vector3D value1, Matrix3X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Returns a new matrix with the negated elements of the given matrix. @@ -82,7 +83,7 @@ public static Vector4D Multiply(Vector3D value1, Matrix3X4 value2) /// The negated matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X4 Negate(Matrix3X4 value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => -value; /// Subtracts the second matrix from the first. @@ -91,22 +92,7 @@ public static Matrix3X4 Negate(Matrix3X4 value) /// The result of the subtraction. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X4 Subtract(Matrix3X4 value1, Matrix3X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 - value2; - - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static unsafe Matrix3X4 Lerp(Matrix3X4 matrix1, Matrix3X4 matrix2, T amount) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Vector4D.Lerp(matrix1.Row1, matrix2.Row1, amount), - Vector4D.Lerp(matrix1.Row2, matrix2.Row2, amount), - Vector4D.Lerp(matrix1.Row3, matrix2.Row3, amount) - ); - } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix3X4.cs b/sources/Maths/Maths/Matrix3X4.cs index ee466c0958..966669f93b 100644 --- a/sources/Maths/Maths/Matrix3X4.cs +++ b/sources/Maths/Maths/Matrix3X4.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -11,8 +12,7 @@ namespace Silk.NET.Maths /// A structure encapsulating a 3x4 matrix. [Serializable] [DataContract] - public struct Matrix3X4 : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + public partial struct Matrix3X4 { private static readonly Matrix3X4 _identity = new ( @@ -21,200 +21,6 @@ public struct Matrix3X4 : IEquatable> Scalar.Zero, Scalar.Zero, Scalar.One, Scalar.Zero ); - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row1; - - /// - /// Row 2 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row2; - - /// - /// Row 3 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row3; - - /// - /// Column 1 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Column1 => new(Row1.X, Row2.X, Row3.X); - - /// - /// Column 2 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Column2 => new(Row1.Y, Row2.Y, Row3.Y); - - /// - /// Column 3 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Column3 => new(Row1.Z, Row2.Z, Row3.Z); - - /// - /// Column 4 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Column4 => new(Row1.W, Row2.W, Row3.W); - - /// Value at row 1, column 1 of the matrix. - [DataMember] - public T M11 - { - readonly get => Row1.X; - set => Row1.X = value; - } - - /// Value at row 1, column 2 of the matrix. - [DataMember] - public T M12 - { - readonly get => Row1.Y; - set => Row1.Y = value; - } - - /// Value at row 1, column 3 of the matrix. - [DataMember] - public T M13 - { - readonly get => Row1.Z; - set => Row1.Z = value; - } - - /// Value at row 1, column 4 of the matrix. - [DataMember] - public T M14 - { - readonly get => Row1.W; - set => Row1.W = value; - } - - /// Value at row 2, column 1 of the matrix. - [DataMember] - public T M21 - { - readonly get => Row2.X; - set => Row2.X = value; - } - - /// Value at row 2, column 2 of the matrix. - [DataMember] - public T M22 - { - readonly get => Row2.Y; - set => Row2.Y = value; - } - - /// Value at row 2, column 3 of the matrix. - [DataMember] - public T M23 - { - readonly get => Row2.Z; - set => Row2.Z = value; - } - - /// Value at row 2, column 4 of the matrix. - [DataMember] - public T M24 - { - readonly get => Row2.W; - set => Row2.W = value; - } - - /// Value at row 3, column 1 of the matrix. - [DataMember] - public T M31 - { - readonly get => Row3.X; - set => Row3.X = value; - } - - /// Value at row 3, column 2 of the matrix. - [DataMember] - public T M32 - { - readonly get => Row3.Y; - set => Row3.Y = value; - } - - /// Value at row 3, column 3 of the matrix. - [DataMember] - public T M33 - { - readonly get => Row3.Z; - set => Row3.Z = value; - } - - /// Value at row 3, column 4 of the matrix. - [DataMember] - public T M34 - { - readonly get => Row3.W; - set => Row3.W = value; - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - public unsafe Vector4D this[int x] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 2 || i < 0) - ThrowHelper(); - } - - VerifyBounds(x); - return Unsafe.Add(ref Row1, x); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - public unsafe T this[int x, int y] - { - get - { - var row = this[x]; - return row[y]; - } - } - - /// - /// Constructs a from the given rows. - /// - /// - /// - /// - public Matrix3X4(Vector4D row1, Vector4D row2, Vector4D row3) - { - Row1 = row1; - Row2 = row2; - Row3 = row3; - } - - /// Constructs a from the given components. - public Matrix3X4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24, T m31, T m32, T m33, T m34) - { - Row1 = new(m11, m12, m13, m14); - Row2 = new(m21, m22, m23, m24); - Row3 = new(m31, m32, m33, m34); - } - /// Constructs a from the given . /// The source . public Matrix3X4(Matrix3X2 value) @@ -283,58 +89,6 @@ public readonly bool IsIdentity Scalar.Equal(M31, Scalar.Zero) && Scalar.Equal(M32, Scalar.Zero) && Scalar.Equal(M34, Scalar.Zero); - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - public static unsafe Matrix3X4 operator +(Matrix3X4 value1, Matrix3X4 value2) - { - return new(value1.Row1 + value2.Row1, value1.Row2 + value2.Row2, value1.Row3 + value2.Row3); - } - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are equal; False otherwise. - public static unsafe bool operator ==(Matrix3X4 value1, Matrix3X4 value2) - { - return Scalar.Equal(value1.M11, value2.M11) && Scalar.Equal(value1.M22, value2.M22) && - Scalar.Equal(value1.M33, value2.M33) && // Check diagonal elements first for early out. - Scalar.Equal(value1.M12, value2.M12) && Scalar.Equal(value1.M13, value2.M13) && - Scalar.Equal(value1.M14, value2.M14) && Scalar.Equal(value1.M21, value2.M21) && - Scalar.Equal(value1.M23, value2.M23) && Scalar.Equal(value1.M24, value2.M24) && - Scalar.Equal(value1.M31, value2.M31) && Scalar.Equal(value1.M32, value2.M32) && - Scalar.Equal(value1.M34, value2.M34); - } - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are not equal; False if they are equal. - public static unsafe bool operator !=(Matrix3X4 value1, Matrix3X4 value2) - { - return Scalar.NotEqual(value1.M11, value2.M11) || Scalar.NotEqual(value1.M22, value2.M22) || - Scalar.NotEqual(value1.M33, value2.M33) || // Check diagonal elements first for early out. - Scalar.NotEqual(value1.M12, value2.M12) || Scalar.NotEqual(value1.M13, value2.M13) || - Scalar.NotEqual(value1.M14, value2.M14) || Scalar.NotEqual(value1.M21, value2.M21) || - Scalar.NotEqual(value1.M23, value2.M23) || Scalar.NotEqual(value1.M24, value2.M24) || - Scalar.NotEqual(value1.M31, value2.M31) || Scalar.NotEqual(value1.M32, value2.M32) || - Scalar.NotEqual(value1.M34, value2.M34); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix3X3 operator *(Matrix3X4 value1, Matrix4X3 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3 + value1.M14 * value2.Row4, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3 + value1.M24 * value2.Row4, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2 + value1.M33 * value2.Row3 + value1.M34 * value2.Row4 - ); - } - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -344,19 +98,6 @@ public readonly bool IsIdentity return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3; } - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix3X4 operator *(Matrix3X3 value1, Matrix3X4 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2 + value1.M33 * value2.Row3 - ); - } - /// Multiplies a matrix by a scalar value. /// The source matrix. /// The scaling factor. @@ -366,60 +107,6 @@ public readonly bool IsIdentity return new(value1.Row1 * value2, value1.Row2 * value2, value1.Row3 * value2); } - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static unsafe Matrix3X4 operator -(Matrix3X4 value1, Matrix3X4 value2) - { - return new(value1.Row1 - value2.Row1, value1.Row2 - value2.Row2, value1.Row3 - value2.Row3); - } - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static unsafe Matrix3X4 operator -(Matrix3X4 value) - { - return new(-value.Row1, -value.Row2, -value.Row3); - } - - /// Returns a boolean indicating whether the given Object is equal to this matrix instance. - /// The Object to compare against. - /// True if the Object is equal to this matrix; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) - => (obj is Matrix3X4 other) && Equals(other); - - /// Returns a boolean indicating whether this matrix instance is equal to the other given matrix. - /// The matrix to compare this instance to. - /// True if the matrices are equal; False otherwise. - public readonly bool Equals(Matrix3X4 other) - => this == other; - - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - HashCode hash = default; - - hash.Add(M11); - hash.Add(M12); - hash.Add(M13); - hash.Add(M14); - - hash.Add(M21); - hash.Add(M22); - hash.Add(M23); - hash.Add(M24); - - hash.Add(M31); - hash.Add(M32); - hash.Add(M33); - hash.Add(M34); - - return hash.ToHashCode(); - } - /// Returns a String representing this matrix instance. /// The string representation. public override readonly string ToString() @@ -627,7 +314,7 @@ public static explicit operator Matrix3X4(Matrix3X4 from) /// /// The type to cast to /// The casted matrix - public Matrix3X4 As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Matrix3X4 As() where TOther : INumberBase { return new(Row1.As(), Row2.As(), Row3.As()); } diff --git a/sources/Maths/Maths/Matrix3X4.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs index 72a40e990d..fa2463be59 100644 --- a/sources/Maths/Maths/Matrix3X4.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -2,25 +2,64 @@ namespace Silk.NET.Maths { using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.CompilerServices; + using System.Runtime.Serialization; public partial struct Matrix3X4 : IEquatable> where T : INumberBase { /// The 1st row of the matrix represented as a vector. + [IgnoreDataMember] public Vector4D Row1; /// The 2nd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector4D Row2; /// The 3rd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector4D Row3; + /// The 1st column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector3D Column1 => new(Row1.X, Row2.X, Row3.X); + + /// The 2nd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector3D Column2 => new(Row1.Y, Row2.Y, Row3.Y); + + /// The 3rd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector3D Column3 => new(Row1.Z, Row2.Z, Row3.Z); + + /// The 4th column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector3D Column4 => new(Row1.W, Row2.W, Row3.W); + /// /// Constructs a from the given rows. /// - public Matrix3X4(Vector4D row1, Vector4D row2, Vector4D row3) => (Row1, Row2, Row3) = (row1, row2, row3); + public Matrix3X4(Vector4D row1, Vector4D row2, Vector4D row3) => + (Row1, Row2, Row3) = (row1, row2, row3); + /// + /// Constructs a from the given components. + /// + public Matrix3X4( + T m11, T m12, T m13, T m14, + T m21, T m22, T m23, T m24, + T m31, T m32, T m33, T m34) + { + Row1 = new(m11, m12, m13, m14); + Row2 = new(m21, m22, m23, m24); + Row3 = new(m31, m32, m33, m34); + } + + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. [UnscopedRef] public ref Vector4D this[int row] { @@ -36,62 +75,80 @@ public ref Vector4D this[int row] return ref Row3; } - throw new ArgumentOutOfRangeException(nameof(row)); + throw new IndexOutOfRangeException(); } } + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. [UnscopedRef] public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M13 => ref Row1.Z; /// Gets the element in the 1st row and 4th column of the matrix. + [DataMember] [UnscopedRef] public ref T M14 => ref Row1.W; /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M23 => ref Row2.Z; /// Gets the element in the 2nd row and 4th column of the matrix. + [DataMember] [UnscopedRef] public ref T M24 => ref Row2.W; /// Gets the element in the 3rd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M33 => ref Row3.Z; /// Gets the element in the 3rd row and 4th column of the matrix. + [DataMember] [UnscopedRef] public ref T M34 => ref Row3.W; /// + [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix3X4 other && Equals(other); /// @@ -186,10 +243,15 @@ public Matrix4X3 Transpose() => public static partial class Matrix3X4 { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. public static Matrix3X4 Lerp(Matrix3X4 value1, Matrix3X4 value2, T amount) where T : IFloatingPointIeee754 => - new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount), T.Lerp(value1.M14, value2.M14, amount)), - new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount), T.Lerp(value1.M24, value2.M24, amount)), - new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount), T.Lerp(value1.M33, value2.M33, amount), T.Lerp(value1.M34, value2.M34, amount))); + new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), + Vector4D.Lerp(value1.Row2, value2.Row2, amount), + Vector4D.Lerp(value1.Row3, value2.Row3, amount)); } } diff --git a/sources/Maths/Maths/Matrix4X2.Ops.cs b/sources/Maths/Maths/Matrix4X2.Ops.cs index 3fa4c29020..697280fe63 100644 --- a/sources/Maths/Maths/Matrix4X2.Ops.cs +++ b/sources/Maths/Maths/Matrix4X2.Ops.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; namespace Silk.NET.Maths @@ -9,7 +10,7 @@ namespace Silk.NET.Maths /// /// Methods for working with /// - public static class Matrix4X2 + public static partial class Matrix4X2 { /// Adds two matrices together. /// The first source matrix. @@ -17,7 +18,7 @@ public static class Matrix4X2 /// The resulting matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X2 Add(Matrix4X2 value1, Matrix4X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { return value1 + value2; } @@ -28,7 +29,7 @@ public static Matrix4X2 Add(Matrix4X2 value1, Matrix4X2 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X2 Multiply(Matrix4X2 value1, Matrix2X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -37,7 +38,7 @@ public static Matrix4X2 Multiply(Matrix4X2 value1, Matrix2X2 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X3 Multiply(Matrix4X2 value1, Matrix2X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -46,7 +47,7 @@ public static Matrix4X3 Multiply(Matrix4X2 value1, Matrix2X3 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X4 Multiply(Matrix4X2 value1, Matrix2X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -55,7 +56,7 @@ public static Matrix4X4 Multiply(Matrix4X2 value1, Matrix2X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X2 Multiply(Matrix2X4 value1, Matrix4X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -64,7 +65,7 @@ public static Matrix2X2 Multiply(Matrix2X4 value1, Matrix4X2 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X2 Multiply(Matrix3X4 value1, Matrix4X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a vector by a matrix. @@ -73,7 +74,7 @@ public static Matrix3X2 Multiply(Matrix3X4 value1, Matrix4X2 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Vector2D Multiply(Vector4D value1, Matrix4X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -82,7 +83,7 @@ public static Vector2D Multiply(Vector4D value1, Matrix4X2 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X2 Multiply(Matrix4X4 value1, Matrix4X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Returns a new matrix with the negated elements of the given matrix. @@ -90,7 +91,7 @@ public static Matrix4X2 Multiply(Matrix4X4 value1, Matrix4X2 value2) /// The negated matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X2 Negate(Matrix4X2 value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => -value; /// Subtracts the second matrix from the first. @@ -99,12 +100,12 @@ public static Matrix4X2 Negate(Matrix4X2 value) /// The result of the subtraction. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X2 Subtract(Matrix4X2 value1, Matrix4X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 - value2; /*[MethodImpl((MethodImplOptions)768)] private static Vector128 Permute(Vector128 value, byte control) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { if (Avx.IsSupported) { @@ -120,23 +121,5 @@ private static Vector128 Permute(Vector128 value, byte control) throw new PlatformNotSupportedException(); } }*/ - - - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static unsafe Matrix4X2 Lerp(Matrix4X2 matrix1, Matrix4X2 matrix2, T amount) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new - ( - Vector2D.Lerp(matrix1.Row1, matrix2.Row1, amount), - Vector2D.Lerp(matrix1.Row2, matrix2.Row2, amount), - Vector2D.Lerp(matrix1.Row3, matrix2.Row3, amount), - Vector2D.Lerp(matrix1.Row4, matrix2.Row4, amount) - ); - } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix4X2.cs b/sources/Maths/Maths/Matrix4X2.cs index ca60eb79d5..45d2b8c231 100644 --- a/sources/Maths/Maths/Matrix4X2.cs +++ b/sources/Maths/Maths/Matrix4X2.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; using System.Globalization; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -12,8 +13,7 @@ namespace Silk.NET.Maths /// A structure encapsulating a 4x2 matrix. [Serializable] [DataContract] - public struct Matrix4X2 : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + public partial struct Matrix4X2 { private static readonly Matrix4X2 _identity = new ( @@ -23,163 +23,6 @@ public struct Matrix4X2 : IEquatable> Scalar.Zero, Scalar.Zero ); - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector2D Row1; - - /// - /// Row 2 of the matrix - /// - [IgnoreDataMember] - public Vector2D Row2; - - /// - /// Row 3 of the matrix - /// - [IgnoreDataMember] - public Vector2D Row3; - - /// - /// Row 4 of the matrix - /// - [IgnoreDataMember] - public Vector2D Row4; - - - - /// - /// Column 1 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Column1 => new(Row1.X, Row2.X, Row3.X, Row4.X); - - /// - /// Column 2 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Column2 => new(Row1.Y, Row2.Y, Row3.X, Row4.X); - - /// Value at row 1, column 1 of the matrix. - [DataMember] - public T M11 - { - readonly get => Row1.X; - set => Row1.X = value; - } - - /// Value at row 1, column 2 of the matrix. - [DataMember] - public T M12 - { - readonly get => Row1.Y; - set => Row1.Y = value; - } - - /// Value at row 2, column 1 of the matrix. - [DataMember] - public T M21 - { - readonly get => Row2.X; - set => Row2.X = value; - } - - /// Value at row 2, column 2 of the matrix. - [DataMember] - public T M22 - { - readonly get => Row2.Y; - set => Row2.Y = value; - } - - /// Value at row 3, column 1 of the matrix. - [DataMember] - public T M31 - { - readonly get => Row3.X; - set => Row3.X = value; - } - - /// Value at row 3, column 2 of the matrix. - [DataMember] - public T M32 - { - readonly get => Row3.Y; - set => Row3.Y = value; - } - - /// Value at row 4, column 1 of the matrix. - [DataMember] - public T M41 - { - readonly get => Row4.X; - set => Row4.X = value; - } - - /// Value at row 4, column 2 of the matrix. - [DataMember] - public T M42 - { - readonly get => Row4.Y; - set => Row4.Y = value; - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - public unsafe Vector2D this[int x] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 3 || i < 0) - ThrowHelper(); - } - - VerifyBounds(x); - return Unsafe.Add(ref Row1, x); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - public unsafe T this[int x, int y] - { - get - { - var row = this[x]; - return row[y]; - } - } - - /// - /// Constructs a from the given rows. - /// - public Matrix4X2(Vector2D row1, Vector2D row2, Vector2D row3, Vector2D row4) - { - Row1 = row1; - Row2 = row2; - Row3 = row3; - Row4 = row4; - } - - /// Constructs a from the given components. - public Matrix4X2(T m11, T m12, T m21, T m22, T m31, T m32, T m41, T m42) - { - Row1 = new(m11, m12); - Row2 = new(m21, m22); - Row3 = new(m31, m32); - Row4 = new(m41, m42); - } - /// Constructs a from the given . /// The source . public Matrix4X2(Matrix3X2 value) @@ -242,87 +85,6 @@ public readonly bool IsIdentity Scalar.Equal(M31, Scalar.Zero) && Scalar.Equal(M32, Scalar.Zero) && Scalar.Equal(M41, Scalar.Zero) && Scalar.Equal(M42, Scalar.Zero); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - public static unsafe Matrix4X2 operator +(Matrix4X2 value1, Matrix4X2 value2) - { - return new - ( - value1.Row1 + value2.Row1, value1.Row2 + value2.Row2, value1.Row3 + value2.Row3, - value1.Row4 + value2.Row4 - ); - } - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are equal; False otherwise. - public static unsafe bool operator ==(Matrix4X2 value1, Matrix4X2 value2) - { - return Scalar.Equal(value1.M11, value2.M11) && Scalar.Equal(value1.M22, value2.M22) && - // Check diagonal elements first for early out. - Scalar.Equal(value1.M12, value2.M12) && Scalar.Equal(value1.M21, value2.M21) && - Scalar.Equal(value1.M31, value2.M31) && Scalar.Equal(value1.M32, value2.M32) && - Scalar.Equal(value1.M41, value2.M41) && Scalar.Equal(value1.M42, value2.M42); - } - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are not equal; False if they are equal. - public static unsafe bool operator !=(Matrix4X2 value1, Matrix4X2 value2) - { - return Scalar.NotEqual(value1.M11, value2.M11) || Scalar.NotEqual(value1.M22, value2.M22) || // Check diagonal elements first for early out. - Scalar.NotEqual(value1.M12, value2.M12) || Scalar.NotEqual(value1.M21, value2.M21) || - Scalar.NotEqual(value1.M31, value2.M31) || Scalar.NotEqual(value1.M32, value2.M32) || - Scalar.NotEqual(value1.M41, value2.M41) || Scalar.NotEqual(value1.M42, value2.M42); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix4X2 operator *(Matrix4X2 value1, Matrix2X2 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2, - value1.M41 * value2.Row1 + value1.M42 * value2.Row2 - ); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix4X3 operator *(Matrix4X2 value1, Matrix2X3 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2, - value1.M41 * value2.Row1 + value1.M42 * value2.Row2 - ); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix4X4 operator *(Matrix4X2 value1, Matrix2X4 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2, - value1.M41 * value2.Row1 + value1.M42 * value2.Row2 - ); - } - /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -380,57 +142,6 @@ public readonly bool IsIdentity return new(value1.Row1 * value2, value1.Row2 * value2, value1.Row3 * value2, value1.Row4 * value2); } - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static unsafe Matrix4X2 operator -(Matrix4X2 value1, Matrix4X2 value2) - { - return new(value1.Row1 - value2.Row1, value1.Row2 - value2.Row2, value1.Row3 - value2.Row3, value1.Row4 - value2.Row4); - } - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static unsafe Matrix4X2 operator -(Matrix4X2 value) - { - return new(-value.Row1, -value.Row2, -value.Row3, -value.Row4); - } - - /// Returns a boolean indicating whether the given Object is equal to this matrix instance. - /// The Object to compare against. - /// True if the Object is equal to this matrix; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) - => (obj is Matrix4X2 other) && Equals(other); - - /// Returns a boolean indicating whether this matrix instance is equal to the other given matrix. - /// The matrix to compare this instance to. - /// True if the matrices are equal; False otherwise. - public readonly bool Equals(Matrix4X2 other) - => this == other; - - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - HashCode hash = default; - - hash.Add(M11); - hash.Add(M12); - - hash.Add(M21); - hash.Add(M22); - - hash.Add(M31); - hash.Add(M32); - - hash.Add(M41); - hash.Add(M42); - - return hash.ToHashCode(); - } - /// Returns a String representing this matrix instance. /// The string representation. public override readonly string ToString() @@ -615,7 +326,7 @@ public static explicit operator Matrix4X2(Matrix4X2 from) /// /// The type to cast to /// The casted matrix - public Matrix4X2 As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Matrix4X2 As() where TOther : INumberBase { return new(Row1.As(), Row2.As(), Row3.As(), Row4.As()); } diff --git a/sources/Maths/Maths/Matrix4X2.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs index 36b257c507..8bd1df9859 100644 --- a/sources/Maths/Maths/Matrix4X2.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -2,28 +2,62 @@ namespace Silk.NET.Maths { using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.CompilerServices; + using System.Runtime.Serialization; public partial struct Matrix4X2 : IEquatable> where T : INumberBase { /// The 1st row of the matrix represented as a vector. + [IgnoreDataMember] public Vector2D Row1; /// The 2nd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector2D Row2; /// The 3rd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector2D Row3; /// The 4th row of the matrix represented as a vector. + [IgnoreDataMember] public Vector2D Row4; + /// The 1st column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Column1 => new(Row1.X, Row2.X, Row3.X, Row4.X); + + /// The 2nd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Column2 => new(Row1.Y, Row2.Y, Row3.Y, Row4.Y); + /// /// Constructs a from the given rows. /// - public Matrix4X2(Vector2D row1, Vector2D row2, Vector2D row3, Vector2D row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + public Matrix4X2(Vector2D row1, Vector2D row2, Vector2D row3, Vector2D row4) => + (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + /// + /// Constructs a from the given components. + /// + public Matrix4X2( + T m11, T m12, + T m21, T m22, + T m31, T m32, + T m41, T m42) + { + Row1 = new(m11, m12); + Row2 = new(m21, m22); + Row3 = new(m31, m32); + Row4 = new(m41, m42); + } + + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. [UnscopedRef] public ref Vector2D this[int row] { @@ -41,46 +75,60 @@ public ref Vector2D this[int row] return ref Row4; } - throw new ArgumentOutOfRangeException(nameof(row)); + throw new IndexOutOfRangeException(); } } + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. [UnscopedRef] public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M12 => ref Row1.Y; /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M22 => ref Row2.Y; /// Gets the element in the 3rd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M32 => ref Row3.Y; /// Gets the element in the 4th row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M41 => ref Row4.X; /// Gets the element in the 4th row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M42 => ref Row4.Y; /// + [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix4X2 other && Equals(other); /// @@ -172,11 +220,16 @@ public Matrix2X4 Transpose() => public static partial class Matrix4X2 { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. public static Matrix4X2 Lerp(Matrix4X2 value1, Matrix4X2 value2, T amount) where T : IFloatingPointIeee754 => - new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount)), - new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount)), - new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount)), - new(T.Lerp(value1.M41, value2.M41, amount), T.Lerp(value1.M42, value2.M42, amount))); + new(Vector2D.Lerp(value1.Row1, value2.Row1, amount), + Vector2D.Lerp(value1.Row2, value2.Row2, amount), + Vector2D.Lerp(value1.Row3, value2.Row3, amount), + Vector2D.Lerp(value1.Row4, value2.Row4, amount)); } } diff --git a/sources/Maths/Maths/Matrix4X3.Ops.cs b/sources/Maths/Maths/Matrix4X3.Ops.cs index 09407f0f98..807192cc85 100644 --- a/sources/Maths/Maths/Matrix4X3.Ops.cs +++ b/sources/Maths/Maths/Matrix4X3.Ops.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; namespace Silk.NET.Maths @@ -9,7 +10,7 @@ namespace Silk.NET.Maths /// /// Methods for working with /// - public static class Matrix4X3 + public static partial class Matrix4X3 { /// Adds two matrices together. /// The first source matrix. @@ -17,7 +18,7 @@ public static class Matrix4X3 /// The resulting matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X3 Add(Matrix4X3 value1, Matrix4X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { return value1 + value2; } @@ -28,7 +29,7 @@ public static Matrix4X3 Add(Matrix4X3 value1, Matrix4X3 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X3 Multiply(Matrix4X3 value1, Matrix3X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -37,7 +38,7 @@ public static Matrix4X3 Multiply(Matrix4X3 value1, Matrix3X3 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X4 Multiply(Matrix4X3 value1, Matrix3X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -46,7 +47,7 @@ public static Matrix4X4 Multiply(Matrix4X3 value1, Matrix3X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X3 Multiply(Matrix4X4 value1, Matrix4X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -55,7 +56,7 @@ public static Matrix4X3 Multiply(Matrix4X4 value1, Matrix4X3 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix3X3 Multiply(Matrix3X4 value1, Matrix4X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by a scalar value. @@ -64,7 +65,7 @@ public static Matrix3X3 Multiply(Matrix3X4 value1, Matrix4X3 value2) /// The scaled matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X3 Multiply(Matrix4X3 value1, T value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a vector by a matrix. @@ -73,7 +74,7 @@ public static Matrix4X3 Multiply(Matrix4X3 value1, T value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Vector3D Multiply(Vector4D value1, Matrix4X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Returns a new matrix with the negated elements of the given matrix. @@ -81,7 +82,7 @@ public static Vector3D Multiply(Vector4D value1, Matrix4X3 value2) /// The negated matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X3 Negate(Matrix4X3 value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => -value; /// Subtracts the second matrix from the first. @@ -90,23 +91,7 @@ public static Matrix4X3 Negate(Matrix4X3 value) /// The result of the subtraction. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X3 Subtract(Matrix4X3 value1, Matrix4X3 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 - value2; - - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static unsafe Matrix4X3 Lerp(Matrix4X3 matrix1, Matrix4X3 matrix2, T amount) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Vector3D.Lerp(matrix1.Row1, matrix2.Row1, amount), - Vector3D.Lerp(matrix1.Row2, matrix2.Row2, amount), - Vector3D.Lerp(matrix1.Row3, matrix2.Row3, amount), - Vector3D.Lerp(matrix1.Row4, matrix2.Row4, amount) - ); - } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Matrix4X3.cs b/sources/Maths/Maths/Matrix4X3.cs index 57088ec556..3cfd7e313a 100644 --- a/sources/Maths/Maths/Matrix4X3.cs +++ b/sources/Maths/Maths/Matrix4X3.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -11,8 +12,9 @@ namespace Silk.NET.Maths /// A structure encapsulating a 4x3 matrix. [Serializable] [DataContract] - public struct Matrix4X3 : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + public partial struct Matrix4X3 + : IEquatable> + where T : INumberBase { private static readonly Matrix4X3 _identity = new ( @@ -22,199 +24,6 @@ public struct Matrix4X3 : IEquatable> Scalar.Zero, Scalar.Zero, Scalar.Zero ); - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Row1; - - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Row2; - - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Row3; - - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector3D Row4; - - /// - /// Column 1 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Column1 => new(Row1.X, Row2.X, Row3.X, Row4.X); - - /// - /// Column 2 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Column2 => new(Row1.Y, Row2.Y, Row3.Y, Row4.Y); - - /// - /// Column 3 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Column3 => new(Row1.Z, Row2.Z, Row3.Z, Row4.Z); - - /// Value at row 1, column 1 of the matrix. - [DataMember] - public T M11 - { - readonly get => Row1.X; - set => Row1.X = value; - } - - /// Value at row 1, column 2 of the matrix. - [DataMember] - public T M12 - { - readonly get => Row1.Y; - set => Row1.Y = value; - } - - /// Value at row 1, column 3 of the matrix. - [DataMember] - public T M13 - { - readonly get => Row1.Z; - set => Row1.Z = value; - } - - /// Value at row 2, column 1 of the matrix. - [DataMember] - public T M21 - { - readonly get => Row2.X; - set => Row2.X = value; - } - - /// Value at row 2, column 2 of the matrix. - [DataMember] - public T M22 - { - readonly get => Row2.Y; - set => Row2.Y = value; - } - - /// Value at row 2, column 3 of the matrix. - [DataMember] - public T M23 - { - readonly get => Row2.Z; - set => Row2.Z = value; - } - - /// Value at row 3, column 1 of the matrix. - [DataMember] - public T M31 - { - readonly get => Row3.X; - set => Row3.X = value; - } - - /// Value at row 3, column 2 of the matrix. - [DataMember] - public T M32 - { - readonly get => Row3.Y; - set => Row3.Y = value; - } - - /// Value at row 3, column 3 of the matrix. - [DataMember] - public T M33 - { - readonly get => Row3.Z; - set => Row3.Z = value; - } - - /// Value at row 4, column 1 of the matrix. - [DataMember] - public T M41 - { - readonly get => Row4.X; - set => Row4.X = value; - } - - /// Value at row 4, column 2 of the matrix. - [DataMember] - public T M42 - { - readonly get => Row4.Y; - set => Row4.Y = value; - } - - /// Value at row 4, column 3 of the matrix. - [DataMember] - public T M43 - { - readonly get => Row4.Z; - set => Row4.Z = value; - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - public unsafe Vector3D this[int x] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 3 || i < 0) - ThrowHelper(); - } - - VerifyBounds(x); - return Unsafe.Add(ref Row1, x); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - public unsafe T this[int x, int i] - { - get - { - var row = this[x]; - return row[i]; - } - } - - /// - /// Constructs a from the given rows. - /// - public Matrix4X3(Vector3D row1, Vector3D row2, Vector3D row3, Vector3D row4) - { - Row1 = row1; - Row2 = row2; - Row3 = row3; - Row4 = row4; - } - - /// Constructs a from the given components. - public Matrix4X3(T m11, T m12, T m13, T m21, T m22, T m23, T m31, T m32, T m33, T m41, T m42, T m43) - { - Row1 = new(m11, m12, m13); - Row2 = new(m21, m22, m23); - Row3 = new(m31, m32, m33); - Row4 = new(m41, m42, m43); - } - /// Constructs a from the given . /// The source . public Matrix4X3(Matrix3X2 value) @@ -299,73 +108,6 @@ public readonly bool IsIdentity Scalar.Equal(M41, Scalar.Zero) && Scalar.Equal(M42, Scalar.Zero) && Scalar.Equal(M43, Scalar.Zero); - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - public static unsafe Matrix4X3 operator +(Matrix4X3 value1, Matrix4X3 value2) - { - return new(value1.Row1 + value2.Row1, value1.Row2 + value2.Row2, value1.Row3 + value2.Row3, value1.Row4 + value2.Row4); - } - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are equal; False otherwise. - public static unsafe bool operator ==(Matrix4X3 value1, Matrix4X3 value2) - { - return Scalar.Equal(value1.M11, value2.M11) && Scalar.Equal(value1.M22, value2.M22) && - Scalar.Equal(value1.M33, value2.M33) && // Check diagonal elements first for early out. - Scalar.Equal(value1.M12, value2.M12) && Scalar.Equal(value1.M13, value2.M13) && - Scalar.Equal(value1.M21, value2.M21) && Scalar.Equal(value1.M23, value2.M23) && - Scalar.Equal(value1.M31, value2.M31) && Scalar.Equal(value1.M32, value2.M32) && - Scalar.Equal(value1.M41, value2.M41) && Scalar.Equal(value1.M42, value2.M42) && - Scalar.Equal(value1.M43, value2.M43); - } - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are not equal; False if they are equal. - public static unsafe bool operator !=(Matrix4X3 value1, Matrix4X3 value2) - { - return Scalar.NotEqual(value1.M11, value2.M11) || Scalar.NotEqual(value1.M22, value2.M22) || - Scalar.NotEqual(value1.M33, value2.M33) || // Check diagonal elements first for early out. - Scalar.NotEqual(value1.M12, value2.M12) || Scalar.NotEqual(value1.M13, value2.M13) || - Scalar.NotEqual(value1.M21, value2.M21) || Scalar.NotEqual(value1.M23, value2.M23) || - Scalar.NotEqual(value1.M31, value2.M31) || Scalar.NotEqual(value1.M32, value2.M32) || - Scalar.NotEqual(value1.M41, value2.M41) || Scalar.NotEqual(value1.M42, value2.M42) || - Scalar.NotEqual(value1.M43, value2.M43); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix4X4 operator *(Matrix4X3 value1, Matrix3X4 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2 + value1.M33 * value2.Row3, - value1.M41 * value2.Row1 + value1.M42 * value2.Row2 + value1.M43 * value2.Row3 - ); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix4X3 operator *(Matrix4X3 value1, Matrix3X3 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2 + value1.M33 * value2.Row3, - value1.M41 * value2.Row1 + value1.M42 * value2.Row2 + value1.M43 * value2.Row3 - ); - } - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -384,66 +126,6 @@ public readonly bool IsIdentity return new(value1.Row1 * value2, value1.Row2 * value2, value1.Row3 * value2, value1.Row4 * value2); } - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static unsafe Matrix4X3 operator -(Matrix4X3 value1, Matrix4X3 value2) - { - return new( - value1.Row1 - value2.Row1, - value1.Row2 - value2.Row2, - value1.Row3 - value2.Row3, - value1.Row4 - value2.Row4 - ); - } - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static unsafe Matrix4X3 operator -(Matrix4X3 value) - { - return new(-value.Row1, -value.Row2, -value.Row3, -value.Row4); - } - - /// Returns a boolean indicating whether the given Object is equal to this matrix instance. - /// The Object to compare against. - /// True if the Object is equal to this matrix; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) - => (obj is Matrix4X3 other) && Equals(other); - - /// Returns a boolean indicating whether this matrix instance is equal to the other given matrix. - /// The matrix to compare this instance to. - /// True if the matrices are equal; False otherwise. - public readonly bool Equals(Matrix4X3 other) - => this == other; - - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - HashCode hash = default; - - hash.Add(M11); - hash.Add(M12); - hash.Add(M13); - - hash.Add(M21); - hash.Add(M22); - hash.Add(M23); - - hash.Add(M31); - hash.Add(M32); - hash.Add(M33); - - hash.Add(M41); - hash.Add(M42); - hash.Add(M43); - - return hash.ToHashCode(); - } - /// Returns a String representing this matrix instance. /// The string representation. public override readonly string ToString() @@ -676,7 +358,7 @@ public static explicit operator Matrix4X3(Matrix4X3 from) /// /// The type to cast to /// The casted matrix - public Matrix4X3 As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Matrix4X3 As() where TOther : INumberBase { return new(Row1.As(), Row2.As(), Row3.As(), Row4.As()); } diff --git a/sources/Maths/Maths/Matrix4X3.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs index ba7647e55a..7fcb883410 100644 --- a/sources/Maths/Maths/Matrix4X3.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -2,28 +2,66 @@ namespace Silk.NET.Maths { using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.CompilerServices; + using System.Runtime.Serialization; public partial struct Matrix4X3 : IEquatable> where T : INumberBase { /// The 1st row of the matrix represented as a vector. + [IgnoreDataMember] public Vector3D Row1; /// The 2nd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector3D Row2; /// The 3rd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector3D Row3; /// The 4th row of the matrix represented as a vector. + [IgnoreDataMember] public Vector3D Row4; + /// The 1st column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Column1 => new(Row1.X, Row2.X, Row3.X, Row4.X); + + /// The 2nd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Column2 => new(Row1.Y, Row2.Y, Row3.Y, Row4.Y); + + /// The 3rd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Column3 => new(Row1.Z, Row2.Z, Row3.Z, Row4.Z); + /// /// Constructs a from the given rows. /// - public Matrix4X3(Vector3D row1, Vector3D row2, Vector3D row3, Vector3D row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + public Matrix4X3(Vector3D row1, Vector3D row2, Vector3D row3, Vector3D row4) => + (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + + /// + /// Constructs a from the given components. + /// + public Matrix4X3( + T m11, T m12, T m13, + T m21, T m22, T m23, + T m31, T m32, T m33, + T m41, T m42, T m43) + { + Row1 = new(m11, m12, m13); + Row2 = new(m21, m22, m23); + Row3 = new(m31, m32, m33); + Row4 = new(m41, m42, m43); + } + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. [UnscopedRef] public ref Vector3D this[int row] { @@ -41,62 +79,80 @@ public ref Vector3D this[int row] return ref Row4; } - throw new ArgumentOutOfRangeException(nameof(row)); + throw new IndexOutOfRangeException(); } } + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. [UnscopedRef] public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M13 => ref Row1.Z; /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M23 => ref Row2.Z; /// Gets the element in the 3rd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M33 => ref Row3.Z; /// Gets the element in the 4th row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M41 => ref Row4.X; /// Gets the element in the 4th row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M42 => ref Row4.Y; /// Gets the element in the 4th row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M43 => ref Row4.Z; /// + [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix4X3 other && Equals(other); /// @@ -197,11 +253,16 @@ public Matrix3X4 Transpose() => public static partial class Matrix4X3 { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. public static Matrix4X3 Lerp(Matrix4X3 value1, Matrix4X3 value2, T amount) where T : IFloatingPointIeee754 => - new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount)), - new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount)), - new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount), T.Lerp(value1.M33, value2.M33, amount)), - new(T.Lerp(value1.M41, value2.M41, amount), T.Lerp(value1.M42, value2.M42, amount), T.Lerp(value1.M43, value2.M43, amount))); + new(Vector3D.Lerp(value1.Row1, value2.Row1, amount), + Vector3D.Lerp(value1.Row2, value2.Row2, amount), + Vector3D.Lerp(value1.Row3, value2.Row3, amount), + Vector3D.Lerp(value1.Row4, value2.Row4, amount)); } } diff --git a/sources/Maths/Maths/Matrix4X4.Ops.cs b/sources/Maths/Maths/Matrix4X4.Ops.cs index fb74c4345a..5bc49c3d06 100644 --- a/sources/Maths/Maths/Matrix4X4.Ops.cs +++ b/sources/Maths/Maths/Matrix4X4.Ops.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; namespace Silk.NET.Maths @@ -9,7 +10,7 @@ namespace Silk.NET.Maths /// /// Methods for working with /// - public static class Matrix4X4 + public static partial class Matrix4X4 { private const float BillboardEpsilon = 1e-4f; #if MATHF @@ -20,15 +21,16 @@ public static class Matrix4X4 private const float DecomposeEpsilon = 0.0001f; private struct CanonicalBasis - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { public Vector3D Row0; public Vector3D Row1; public Vector3D Row2; }; + /* private struct VectorBasis - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { #pragma warning disable 649 public unsafe Vector3D* Element0; @@ -36,6 +38,7 @@ private struct VectorBasis public unsafe Vector3D* Element2; #pragma warning restore 649 } + */ /// Adds two matrices together. /// The first source matrix. @@ -43,7 +46,7 @@ private struct VectorBasis /// The resulting matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X4 Add(Matrix4X4 value1, Matrix4X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { return value1 + value2; } @@ -55,7 +58,7 @@ public static Matrix4X4 Add(Matrix4X4 value1, Matrix4X4 value2) /// The forward vector of the camera. /// The created billboard matrix public static Matrix4X4 CreateBillboard(Vector3D objectPosition, Vector3D cameraPosition, Vector3D cameraUpVector, Vector3D cameraForwardVector) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Vector3D zaxis = objectPosition - cameraPosition; var norm = zaxis.LengthSquared; @@ -87,7 +90,7 @@ public static Matrix4X4 CreateBillboard(Vector3D objectPosition, Vector /// Forward vector of the object. /// The created billboard matrix. public static Matrix4X4 CreateConstrainedBillboard(Vector3D objectPosition, Vector3D cameraPosition, Vector3D rotateAxis, Vector3D cameraForwardVector, Vector3D objectForwardVector) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { // Treat the case when object and camera positions are too close. Vector3D faceDir = objectPosition - cameraPosition; @@ -109,17 +112,17 @@ public static Matrix4X4 CreateConstrainedBillboard(Vector3D objectPosit // Treat the case when angle between faceDir and rotateAxis is too close to 0. T dot = Vector3D.Dot(rotateAxis, faceDir); - if (Scalar.GreaterThan(Scalar.Abs(dot), Scalar.As(BillboardMinAngle))) + if (Scalar.GreaterThan(T.Abs(dot), Scalar.As(BillboardMinAngle))) { zaxis = objectForwardVector; // Make sure passed values are useful for compute. dot = Vector3D.Dot(rotateAxis, zaxis); - if (Scalar.GreaterThan(Scalar.Abs(dot), Scalar.As(BillboardMinAngle))) + if (Scalar.GreaterThan(T.Abs(dot), Scalar.As(BillboardMinAngle))) { zaxis = - Scalar.GreaterThan(Scalar.Abs(rotateAxis.Z), Scalar.As(BillboardMinAngle)) + Scalar.GreaterThan(T.Abs(rotateAxis.Z), Scalar.As(BillboardMinAngle)) ? new Vector3D(Scalar.One, Scalar.Zero, Scalar.Zero) : new Vector3D(Scalar.Zero, Scalar.Zero, Scalar.MinusOne); } @@ -145,7 +148,7 @@ public static Matrix4X4 CreateConstrainedBillboard(Vector3D objectPosit /// The angle to rotate around the given axis, in radians. /// The rotation matrix. public static Matrix4X4 CreateFromAxisAngle(Vector3D axis, T angle) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { // a: angle // x, y, z: unit vector for axis. @@ -198,7 +201,7 @@ public static Matrix4X4 CreateFromAxisAngle(Vector3D axis, T angle) /// The source Quaternion. /// The rotation matrix. public static Matrix4X4 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quaternion quaternion) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -235,7 +238,7 @@ public static Matrix4X4 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quatern /// Angle of rotation, in radians, around the Z-axis. /// The rotation matrix. public static Matrix4X4 CreateFromYawPitchRoll(T yaw, T pitch, T roll) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Legacy.Quaternion q = Legacy.Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(q); @@ -247,7 +250,7 @@ public static Matrix4X4 CreateFromYawPitchRoll(T yaw, T pitch, T roll) /// The direction that is "up" from the camera's point of view. /// The view matrix. public static Matrix4X4 CreateLookAt(Vector3D cameraPosition, Vector3D cameraTarget, Vector3D cameraUpVector) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Vector3D zaxis = Vector3D.Normalize(cameraPosition - cameraTarget); Vector3D xaxis = Vector3D.Normalize(Vector3D.Cross(cameraUpVector, zaxis)); @@ -281,7 +284,7 @@ public static Matrix4X4 CreateLookAt(Vector3D cameraPosition, Vector3D< /// Maximum Z-value of the view volume. /// The orthographic projection matrix. public static Matrix4X4 CreateOrthographic(T width, T height, T zNearPlane, T zFarPlane) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -302,7 +305,7 @@ public static Matrix4X4 CreateOrthographic(T width, T height, T zNearPlane /// Maximum Z-value of the view volume. /// The orthographic projection matrix. public static Matrix4X4 CreateOrthographicOffCenter(T left, T right, T bottom, T top, T zNearPlane, T zFarPlane) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -326,7 +329,7 @@ public static Matrix4X4 CreateOrthographicOffCenter(T left, T right, T bot /// Distance to the far view plane. /// The perspective projection matrix. public static Matrix4X4 CreatePerspective(T width, T height, T nearPlaneDistance, T farPlaneDistance) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { if (!Scalar.GreaterThan(nearPlaneDistance, Scalar.Zero)) throw new ArgumentOutOfRangeException(nameof(nearPlaneDistance)); @@ -362,7 +365,7 @@ public static Matrix4X4 CreatePerspective(T width, T height, T nearPlaneDi /// Distance to the far view plane. /// The perspective projection matrix. public static Matrix4X4 CreatePerspectiveFieldOfView(T fieldOfView, T aspectRatio, T nearPlaneDistance, T farPlaneDistance) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { if (!Scalar.GreaterThan(fieldOfView, Scalar.Zero) || Scalar.GreaterThanOrEqual(fieldOfView, Scalar.Pi)) throw new ArgumentOutOfRangeException(nameof(fieldOfView)); @@ -404,7 +407,7 @@ public static Matrix4X4 CreatePerspectiveFieldOfView(T fieldOfView, T aspe /// Distance to of the far view plane. /// The perspective projection matrix. public static Matrix4X4 CreatePerspectiveOffCenter(T left, T right, T bottom, T top, T nearPlaneDistance, T farPlaneDistance) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { if (!Scalar.GreaterThan(nearPlaneDistance, Scalar.Zero)) throw new ArgumentOutOfRangeException(nameof(nearPlaneDistance)); @@ -436,7 +439,7 @@ public static Matrix4X4 CreatePerspectiveOffCenter(T left, T right, T bott /// The Plane about which to create a reflection. /// A new matrix expressing the reflection. public static Matrix4X4 CreateReflection(Plane value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { value = Plane.Normalize(value); @@ -473,7 +476,7 @@ public static Matrix4X4 CreateReflection(Plane value) /// The amount, in radians, by which to rotate around the X-axis. /// The rotation matrix. public static Matrix4X4 CreateRotationX(T radians) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -498,7 +501,7 @@ public static Matrix4X4 CreateRotationX(T radians) /// The center point. /// The rotation matrix. public static Matrix4X4 CreateRotationX(T radians, Vector3D centerPoint) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -527,7 +530,7 @@ public static Matrix4X4 CreateRotationX(T radians, Vector3D centerPoint /// The amount, in radians, by which to rotate around the Y-axis. /// The rotation matrix. public static Matrix4X4 CreateRotationY(T radians) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -551,7 +554,7 @@ public static Matrix4X4 CreateRotationY(T radians) /// The center point. /// The rotation matrix. public static Matrix4X4 CreateRotationY(T radians, Vector3D centerPoint) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -579,7 +582,7 @@ public static Matrix4X4 CreateRotationY(T radians, Vector3D centerPoint /// The amount, in radians, by which to rotate around the Z-axis. /// The rotation matrix. public static Matrix4X4 CreateRotationZ(T radians) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -603,7 +606,7 @@ public static Matrix4X4 CreateRotationZ(T radians) /// The center point. /// The rotation matrix. public static Matrix4X4 CreateRotationZ(T radians, Vector3D centerPoint) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -633,7 +636,7 @@ public static Matrix4X4 CreateRotationZ(T radians, Vector3D centerPoint /// Value to scale by on the Z-axis. /// The scaling matrix. public static Matrix4X4 CreateScale(T xScale, T yScale, T zScale) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; result.M11 = xScale; @@ -649,7 +652,7 @@ public static Matrix4X4 CreateScale(T xScale, T yScale, T zScale) /// The center point. /// The scaling matrix. public static Matrix4X4 CreateScale(T xScale, T yScale, T zScale, Vector3D centerPoint) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -670,7 +673,7 @@ public static Matrix4X4 CreateScale(T xScale, T yScale, T zScale, Vector3D /// The vector containing the amount to scale by on each axis. /// The scaling matrix. public static Matrix4X4 CreateScale(Vector3D scales) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; result.M11 = scales.X; @@ -684,7 +687,7 @@ public static Matrix4X4 CreateScale(Vector3D scales) /// The center point. /// The scaling matrix. public static Matrix4X4 CreateScale(Vector3D scales, Vector3D centerPoint) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -705,7 +708,7 @@ public static Matrix4X4 CreateScale(Vector3D scales, Vector3D center /// The uniform scaling factor. /// The scaling matrix. public static Matrix4X4 CreateScale(T scale) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -721,7 +724,7 @@ public static Matrix4X4 CreateScale(T scale) /// The center point. /// The scaling matrix. public static Matrix4X4 CreateScale(T scale, Vector3D centerPoint) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; @@ -745,7 +748,7 @@ public static Matrix4X4 CreateScale(T scale, Vector3D centerPoint) /// The Plane onto which the new matrix should flatten geometry so as to cast a shadow. /// A new Matrix that can be used to flatten geometry onto the specified plane from the specified direction. public static Matrix4X4 CreateShadow(Vector3D lightDirection, Plane plane) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Plane p = Plane.Normalize(plane); @@ -781,7 +784,7 @@ public static Matrix4X4 CreateShadow(Vector3D lightDirection, Plane /// The amount to translate in each axis. /// The translation matrix. public static Matrix4X4 CreateTranslation(Vector3D position) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; result.M41 = position.X; @@ -796,7 +799,7 @@ public static Matrix4X4 CreateTranslation(Vector3D position) /// The amount to translate on the Z-axis. /// The translation matrix. public static Matrix4X4 CreateTranslation(T xPosition, T yPosition, T zPosition) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4 result = Matrix4X4.Identity; ; result.M41 = xPosition; @@ -811,7 +814,7 @@ public static Matrix4X4 CreateTranslation(T xPosition, T yPosition, T zPos /// Upward direction of the object; usually [0, 1, 0]. /// The world matrix. public static Matrix4X4 CreateWorld(Vector3D position, Vector3D forward, Vector3D up) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Vector3D zaxis = Vector3D.Normalize(-forward); Vector3D xaxis = Vector3D.Normalize(Vector3D.Cross(up, zaxis)); @@ -845,7 +848,7 @@ public static Matrix4X4 CreateWorld(Vector3D position, Vector3D forw /// [MethodImpl((MethodImplOptions) 768)] public static unsafe bool Invert(Matrix4X4 matrix, out Matrix4X4 result) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { // This implementation is based on the DirectX Math Library XMMatrixInverse method // https://github.com/microsoft/DirectXMath/blob/master/Inc/DirectXMathMatrix.inl @@ -1137,7 +1140,7 @@ static bool SoftwareFallback(Matrix4X4 matrix, out Matrix4X4 result) T det = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(a, a11), Scalar.Multiply(b, a12)), Scalar.Multiply(c, a13)), Scalar.Multiply(d, a14)); - if (!Scalar.GreaterThanOrEqual(Scalar.Abs(det), Scalar.Epsilon)) + if (!Scalar.GreaterThanOrEqual(T.Abs(det), Scalar.Epsilon)) { result = new Matrix4X4(Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN, @@ -1195,7 +1198,7 @@ static bool SoftwareFallback(Matrix4X4 matrix, out Matrix4X4 result) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X4 Multiply(Matrix4X4 value1, Matrix4X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a vector by a matrix. @@ -1204,7 +1207,7 @@ public static Matrix4X4 Multiply(Matrix4X4 value1, Matrix4X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Vector4D Multiply(Vector4D value1, Matrix4X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -1213,7 +1216,7 @@ public static Vector4D Multiply(Vector4D value1, Matrix4X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix2X4 Multiply(Matrix2X4 value1, Matrix4X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by another matrix. @@ -1222,7 +1225,7 @@ public static Matrix2X4 Multiply(Matrix2X4 value1, Matrix4X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X2 Multiply(Matrix4X4 value1, Matrix4X2 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by a scalar value. @@ -1231,7 +1234,7 @@ public static Matrix4X2 Multiply(Matrix4X4 value1, Matrix4X2 value2) /// The scaled matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X4 Multiply(Matrix4X4 value1, T value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Returns a new matrix with the negated elements of the given matrix. @@ -1239,7 +1242,7 @@ public static Matrix4X4 Multiply(Matrix4X4 value1, T value2) /// The negated matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X4 Negate(Matrix4X4 value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => -value; /// Subtracts the second matrix from the first. @@ -1248,7 +1251,7 @@ public static Matrix4X4 Negate(Matrix4X4 value) /// The result of the subtraction. [MethodImpl((MethodImplOptions) 768)] public static Matrix4X4 Subtract(Matrix4X4 value1, Matrix4X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 - value2; /*[MethodImpl((MethodImplOptions)768)] @@ -1269,6 +1272,7 @@ private static Vector128 Permute(Vector128 value, byte control) } }*/ + /* /// Attempts to extract the scale, translation, and rotation components from the given scale/rotation/translation matrix. /// If successful, the out parameters will contained the extracted values. /// The source matrix. @@ -1277,7 +1281,7 @@ private static Vector128 Permute(Vector128 value, byte control) /// The translation component of the transformation matrix /// True if the source matrix was successfully decomposed; False otherwise. public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out Silk.NET.Maths.Legacy.Quaternion rotation, out Vector3D translation) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { bool result = true; @@ -1467,29 +1471,14 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out return result; } - - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static unsafe Matrix4X4 Lerp(Matrix4X4 matrix1, Matrix4X4 matrix2, T amount) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Vector4D.Lerp(matrix1.Row1, matrix2.Row1, amount), - Vector4D.Lerp(matrix1.Row2, matrix2.Row2, amount), - Vector4D.Lerp(matrix1.Row3, matrix2.Row3, amount), - Vector4D.Lerp(matrix1.Row4, matrix2.Row4, amount) - ); - } + */ /// Transforms the given matrix by applying the given Quaternion rotation. /// The source matrix to transform. /// The rotation to apply. /// The transformed matrix. public static Matrix4X4 Transform(Matrix4X4 value, Legacy.Quaternion rotation) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { // Compute rotation matrix. T x2 = Scalar.Add(rotation.X, rotation.X); @@ -1534,7 +1523,7 @@ public static Matrix4X4 Transform(Matrix4X4 value, Legacy.Quaternion /// The source matrix. /// The transposed matrix. public static unsafe Matrix4X4 Transpose(Matrix4X4 matrix) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { return new(matrix.Column1, matrix.Column2, matrix.Column3, matrix.Column4); } diff --git a/sources/Maths/Maths/Matrix4X4.cs b/sources/Maths/Maths/Matrix4X4.cs index 1bc8c0553a..700a86cdb5 100644 --- a/sources/Maths/Maths/Matrix4X4.cs +++ b/sources/Maths/Maths/Matrix4X4.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -11,266 +12,8 @@ namespace Silk.NET.Maths /// A structure encapsulating a 4x4 matrix. [Serializable] [DataContract] - public struct Matrix4X4 : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + public partial struct Matrix4X4 { - private static readonly Matrix4X4 _identity = new - ( - Scalar.One, Scalar.Zero, Scalar.Zero, Scalar.Zero, - Scalar.Zero, Scalar.One, Scalar.Zero, Scalar.Zero, - Scalar.Zero, Scalar.Zero, Scalar.One, Scalar.Zero, - Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One - ); - - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row1; - - /// - /// Row 2 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row2; - - /// - /// Row 3 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row3; - - /// - /// Row 4 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row4; - - /// - /// Column 1 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Column1 => new(Row1.X, Row2.X, Row3.X, Row4.X); - - /// - /// Column 2 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Column2 => new(Row1.Y, Row2.Y, Row3.Y, Row4.Y); - - /// - /// Column 3 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Column3 => new(Row1.Z, Row2.Z, Row3.Z, Row4.Z); - - /// - /// Column 4 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Column4 => new(Row1.W, Row2.W, Row3.W, Row4.W); - - /// Value at row 1, column 1 of the matrix. - [DataMember] - public T M11 - { - readonly get => Row1.X; - set => Row1.X = value; - } - - /// Value at row 1, column 2 of the matrix. - [DataMember] - public T M12 - { - readonly get => Row1.Y; - set => Row1.Y = value; - } - - /// Value at row 1, column 3 of the matrix. - [DataMember] - public T M13 - { - readonly get => Row1.Z; - set => Row1.Z = value; - } - - /// Value at row 1, column 4 of the matrix. - [DataMember] - public T M14 - { - readonly get => Row1.W; - set => Row1.W = value; - } - - /// Value at row 2, column 1 of the matrix. - [DataMember] - public T M21 - { - readonly get => Row2.X; - set => Row2.X = value; - } - - /// Value at row 2, column 2 of the matrix. - [DataMember] - public T M22 - { - readonly get => Row2.Y; - set => Row2.Y = value; - } - - /// Value at row 2, column 3 of the matrix. - [DataMember] - public T M23 - { - readonly get => Row2.Z; - set => Row2.Z = value; - } - - /// Value at row 2, column 4 of the matrix. - [DataMember] - public T M24 - { - readonly get => Row2.W; - set => Row2.W = value; - } - - /// Value at row 3, column 1 of the matrix. - [DataMember] - public T M31 - { - readonly get => Row3.X; - set => Row3.X = value; - } - - /// Value at row 3, column 2 of the matrix. - [DataMember] - public T M32 - { - readonly get => Row3.Y; - set => Row3.Y = value; - } - - /// Value at row 3, column 3 of the matrix. - [DataMember] - public T M33 - { - readonly get => Row3.Z; - set => Row3.Z = value; - } - - /// Value at row 3, column 4 of the matrix. - [DataMember] - public T M34 - { - readonly get => Row3.W; - set => Row3.W = value; - } - - /// Value at row 4, column 1 of the matrix. - [DataMember] - public T M41 - { - readonly get => Row4.X; - set => Row4.X = value; - } - - /// Value at row 4, column 2 of the matrix. - [DataMember] - public T M42 - { - readonly get => Row4.Y; - set => Row4.Y = value; - } - - /// Value at row 4, column 3 of the matrix. - [DataMember] - public T M43 - { - readonly get => Row4.Z; - set => Row4.Z = value; - } - - /// Value at row 4, column 4 of the matrix. - [DataMember] - public T M44 - { - readonly get => Row4.W; - set => Row4.W = value; - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - public unsafe Vector4D this[int x] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 3 || i < 0) - ThrowHelper(); - } - - VerifyBounds(x); - return Unsafe.Add(ref Row1, x); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - public unsafe T this[int x, int y] - { - get - { - var row = this[x]; - return row[y]; - } - } - - /// - /// Constructs a from the given rows - /// - public Matrix4X4(Vector4D row1, Vector4D row2, Vector4D row3, Vector4D row4) - { - Row1 = row1; - Row2 = row2; - Row3 = row3; - Row4 = row4; - } - - /// Constructs a from the given components. - public Matrix4X4 - ( - T m11, - T m12, - T m13, - T m14, - T m21, - T m22, - T m23, - T m24, - T m31, - T m32, - T m33, - T m34, - T m41, - T m42, - T m43, - T m44 - ) - { - Row1 = new(m11, m12, m13, m14); - Row2 = new(m21, m22, m23, m24); - Row3 = new(m31, m32, m33, m34); - Row4 = new(m41, m42, m43, m44); - } - /// Constructs a from the given . /// The source . public Matrix4X4(Matrix3X2 value) @@ -331,9 +74,6 @@ public Matrix4X4(Matrix4X2 value) Row4 = new(value.M41, value.M42, default, Scalar.One); } - /// Returns the multiplicative identity matrix. - public static Matrix4X4 Identity => _identity; - /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] public readonly bool IsIdentity @@ -347,67 +87,6 @@ public readonly bool IsIdentity Scalar.Equal(M34, Scalar.Zero) && Scalar.Equal(M41, Scalar.Zero) && Scalar.Equal(M42, Scalar.Zero) && Scalar.Equal(M43, Scalar.Zero); - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - public static unsafe Matrix4X4 operator +(Matrix4X4 value1, Matrix4X4 value2) - { - return new - ( - value1.Row1 + value2.Row1, value1.Row2 + value2.Row2, value1.Row3 + value2.Row3, - value1.Row4 + value2.Row4 - ); - } - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are equal; False otherwise. - public static unsafe bool operator ==(Matrix4X4 value1, Matrix4X4 value2) - { - return Scalar.Equal(value1.M11, value2.M11) && Scalar.Equal(value1.M22, value2.M22) && - Scalar.Equal(value1.M33, value2.M33) && - Scalar.Equal(value1.M44, value2.M44) && // Check diagonal elements first for early out. - Scalar.Equal(value1.M12, value2.M12) && Scalar.Equal(value1.M13, value2.M13) && - Scalar.Equal(value1.M14, value2.M14) && Scalar.Equal(value1.M21, value2.M21) && - Scalar.Equal(value1.M23, value2.M23) && Scalar.Equal(value1.M24, value2.M24) && - Scalar.Equal(value1.M31, value2.M31) && Scalar.Equal(value1.M32, value2.M32) && - Scalar.Equal(value1.M34, value2.M34) && Scalar.Equal(value1.M41, value2.M41) && - Scalar.Equal(value1.M42, value2.M42) && Scalar.Equal(value1.M43, value2.M43); - } - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are not equal; False if they are equal. - public static unsafe bool operator !=(Matrix4X4 value1, Matrix4X4 value2) - { - return Scalar.NotEqual(value1.M11, value2.M11) || Scalar.NotEqual(value1.M22, value2.M22) || - Scalar.NotEqual(value1.M33, value2.M33) || - Scalar.NotEqual(value1.M44, value2.M44) || // Check diagonal elements first for early out. - Scalar.NotEqual(value1.M12, value2.M12) || Scalar.NotEqual(value1.M13, value2.M13) || - Scalar.NotEqual(value1.M14, value2.M14) || Scalar.NotEqual(value1.M21, value2.M21) || - Scalar.NotEqual(value1.M23, value2.M23) || Scalar.NotEqual(value1.M24, value2.M24) || - Scalar.NotEqual(value1.M31, value2.M31) || Scalar.NotEqual(value1.M32, value2.M32) || - Scalar.NotEqual(value1.M34, value2.M34) || Scalar.NotEqual(value1.M41, value2.M41) || - Scalar.NotEqual(value1.M42, value2.M42) || Scalar.NotEqual(value1.M43, value2.M43); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix4X4 operator *(Matrix4X4 value1, Matrix4X4 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3 + value1.M14 * value2.Row4, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3 + value1.M24 * value2.Row4, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2 + value1.M33 * value2.Row3 + value1.M34 * value2.Row4, - value1.M41 * value2.Row1 + value1.M42 * value2.Row2 + value1.M43 * value2.Row3 + value1.M44 * value2.Row4 - ); - } - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -418,33 +97,6 @@ public readonly bool IsIdentity value1.W * value2.Row4; } - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix3X4 operator *(Matrix3X4 value1, Matrix4X4 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3 + value1.M14 * value2.Row4, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3 + value1.M24 * value2.Row4, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2 + value1.M33 * value2.Row3 + value1.M34 * value2.Row4 - ); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix4X3 operator *(Matrix4X4 value1, Matrix4X3 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3 + value1.M14 * value2.Row4, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3 + value1.M24 * value2.Row4, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2 + value1.M33 * value2.Row3 + value1.M34 * value2.Row4, - value1.M41 * value2.Row1 + value1.M42 * value2.Row2 + value1.M43 * value2.Row3 + value1.M44 * value2.Row4 - ); - } - /// Multiplies a matrix by a scalar value. /// The source matrix. /// The scaling factor. @@ -459,46 +111,6 @@ public readonly bool IsIdentity ); } - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static unsafe Matrix4X4 operator -(Matrix4X4 value1, Matrix4X4 value2) - { - return new( - value1.Row1 - value2.Row1, - value1.Row2 - value2.Row2, - value1.Row3 - value2.Row3, - value1.Row4 - value2.Row4 - ); - } - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static unsafe Matrix4X4 operator -(Matrix4X4 value) - { - return new( - -value.Row1, - -value.Row2, - -value.Row3, - -value.Row4 - ); - } - - /// Returns a boolean indicating whether the given Object is equal to this matrix instance. - /// The Object to compare against. - /// True if the Object is equal to this matrix; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) - => (obj is Matrix4X4 other) && Equals(other); - - /// Returns a boolean indicating whether this matrix instance is equal to the other given matrix. - /// The matrix to compare this instance to. - /// True if the matrices are equal; False otherwise. - public readonly bool Equals(Matrix4X4 other) - => this == other; - /// Calculates the determinant of the matrix. /// The determinant of the matrix. public readonly T GetDeterminant() @@ -563,35 +175,6 @@ public readonly T GetDeterminant() Scalar.Multiply(g, in_jm))))); } - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - HashCode hash = default; - - hash.Add(M11); - hash.Add(M12); - hash.Add(M13); - hash.Add(M14); - - hash.Add(M21); - hash.Add(M22); - hash.Add(M23); - hash.Add(M24); - - hash.Add(M31); - hash.Add(M32); - hash.Add(M33); - hash.Add(M34); - - hash.Add(M41); - hash.Add(M42); - hash.Add(M43); - hash.Add(M44); - - return hash.ToHashCode(); - } - /// Returns a String representing this matrix instance. /// The string representation. public override readonly string ToString() @@ -824,7 +407,7 @@ public static explicit operator Matrix4X4(Matrix4X4 from) /// /// The type to cast to /// The casted matrix - public Matrix4X4 As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Matrix4X4 As() where TOther : INumberBase { return new(Row1.As(), Row2.As(), Row3.As(), Row4.As()); } diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs new file mode 100644 index 0000000000..7fe91550bb --- /dev/null +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -0,0 +1,309 @@ +namespace Silk.NET.Maths +{ + using System.Diagnostics.CodeAnalysis; + using System.Numerics; + using System.Runtime.CompilerServices; + using System.Runtime.Serialization; + + public partial struct Matrix4X4 : + IEquatable> + where T : INumberBase + { + /// The multiplicative identity matrix of size 4x4. + public static Matrix4X4 Identity { get; } = new( + new(T.MultiplicativeIdentity, T.Zero, T.Zero, T.Zero), + new(T.Zero, T.MultiplicativeIdentity, T.Zero, T.Zero), + new(T.Zero, T.Zero, T.MultiplicativeIdentity, T.Zero), + new(T.Zero, T.Zero, T.Zero, T.MultiplicativeIdentity)); + + /// The 1st row of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Row1; + + /// The 2nd row of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Row2; + + /// The 3rd row of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Row3; + + /// The 4th row of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Row4; + + /// The 1st column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Column1 => new(Row1.X, Row2.X, Row3.X, Row4.X); + + /// The 2nd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Column2 => new(Row1.Y, Row2.Y, Row3.Y, Row4.Y); + + /// The 3rd column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Column3 => new(Row1.Z, Row2.Z, Row3.Z, Row4.Z); + + /// The 4th column of the matrix represented as a vector. + [IgnoreDataMember] + public Vector4D Column4 => new(Row1.W, Row2.W, Row3.W, Row4.W); + + /// + /// Constructs a from the given rows. + /// + public Matrix4X4(Vector4D row1, Vector4D row2, Vector4D row3, Vector4D row4) => + (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + + /// + /// Constructs a from the given components. + /// + public Matrix4X4( + T m11, T m12, T m13, T m14, + T m21, T m22, T m23, T m24, + T m31, T m32, T m33, T m34, + T m41, T m42, T m43, T m44) + { + Row1 = new(m11, m12, m13, m14); + Row2 = new(m21, m22, m23, m24); + Row3 = new(m31, m32, m33, m34); + Row4 = new(m41, m42, m43, m44); + } + + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. + [UnscopedRef] + public ref Vector4D this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + } + + throw new IndexOutOfRangeException(); + } + } + + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. + [UnscopedRef] + public ref T this[int row, int column] => ref this[row][column]; + + /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M11 => ref Row1.X; + + /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M12 => ref Row1.Y; + + /// Gets the element in the 1st row and 3rd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M13 => ref Row1.Z; + + /// Gets the element in the 1st row and 4th column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M14 => ref Row1.W; + + /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M21 => ref Row2.X; + + /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M22 => ref Row2.Y; + + /// Gets the element in the 2nd row and 3rd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M23 => ref Row2.Z; + + /// Gets the element in the 2nd row and 4th column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M24 => ref Row2.W; + + /// Gets the element in the 3rd row and 1st column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M31 => ref Row3.X; + + /// Gets the element in the 3rd row and 2nd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M32 => ref Row3.Y; + + /// Gets the element in the 3rd row and 3rd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M33 => ref Row3.Z; + + /// Gets the element in the 3rd row and 4th column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M34 => ref Row3.W; + + /// Gets the element in the 4th row and 1st column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M41 => ref Row4.X; + + /// Gets the element in the 4th row and 2nd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M42 => ref Row4.Y; + + /// Gets the element in the 4th row and 3rd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M43 => ref Row4.Z; + + /// Gets the element in the 4th row and 4th column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M44 => ref Row4.W; + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] + public override bool Equals(object? obj) => obj is Matrix4X4 other && Equals(other); + + /// + public bool Equals(Matrix4X4 other) => this == other; + + /// + public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + + /// Computes the transpose of the matrix. + public Matrix4X4 Transpose() => + new(new(M11, M21, M31, M41), + new(M12, M22, M32, M42), + new(M13, M23, M33, M43), + new(M14, M24, M34, M44)); + + /// Returns a boolean indicating whether the given two matrices are equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are equal; false otherwise. + public static bool operator ==(Matrix4X4 left, Matrix4X4 right) => + left.Row1 == right.Row1 && + left.Row2 == right.Row2 && + left.Row3 == right.Row3 && + left.Row4 == right.Row4; + + /// Returns a boolean indicating whether the given two matrices are not equal. + /// The first matrix to compare. + /// The second matrix to compare. + /// true if the given matrices are not equal; false otherwise. + public static bool operator !=(Matrix4X4 left, Matrix4X4 right) => !(left == right); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4X4 operator +(Matrix4X4 left, Matrix4X4 right) => + new(left.Row1 + right.Row1, + left.Row2 + right.Row2, + left.Row3 + right.Row3, + left.Row4 + right.Row4); + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4X4 operator -(Matrix4X4 left, Matrix4X4 right) => + new(left.Row1 - right.Row1, + left.Row2 - right.Row2, + left.Row3 - right.Row3, + left.Row4 - right.Row4); + + /// Returns a new matrix with the negated elements of the given matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4X4 operator -(Matrix4X4 value) => + new(-value.Row1, + -value.Row2, + -value.Row3, + -value.Row4); + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 operator *(Matrix2X4 left, Matrix4X4 right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4); + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 operator *(Matrix3X4 left, Matrix4X4 right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 operator *(Matrix4X4 left, Matrix4X2 right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 operator *(Matrix4X4 left, Matrix4X3 right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X4 operator *(Matrix4X4 left, Matrix4X4 right) => + new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, + left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, + left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, + left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + } + + public static partial class Matrix4X4 + { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. + public static Matrix4X4 Lerp(Matrix4X4 value1, Matrix4X4 value2, T amount) + where T : IFloatingPointIeee754 => + new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), + Vector4D.Lerp(value1.Row2, value2.Row2, amount), + Vector4D.Lerp(value1.Row3, value2.Row3, amount), + Vector4D.Lerp(value1.Row4, value2.Row4, amount)); + } +} diff --git a/sources/Maths/Maths/Matrix5X4.Ops.cs b/sources/Maths/Maths/Matrix5X4.Ops.cs index 18fe708f4e..032181692f 100644 --- a/sources/Maths/Maths/Matrix5X4.Ops.cs +++ b/sources/Maths/Maths/Matrix5X4.Ops.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; namespace Silk.NET.Maths @@ -9,7 +10,7 @@ namespace Silk.NET.Maths /// /// Methods for working with /// - public static class Matrix5X4 + public static partial class Matrix5X4 { /// Adds two matrices together. /// The first source matrix. @@ -17,7 +18,7 @@ public static class Matrix5X4 /// The resulting matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix5X4 Add(Matrix5X4 value1, Matrix5X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { return value1 + value2; } @@ -28,7 +29,7 @@ public static Matrix5X4 Add(Matrix5X4 value1, Matrix5X4 value2) /// The result of the multiplication. [MethodImpl((MethodImplOptions) 768)] public static Vector4D Multiply(Vector4D value1, Matrix5X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Multiplies a matrix by a scalar value. @@ -37,7 +38,7 @@ public static Vector4D Multiply(Vector4D value1, Matrix5X4 value2) /// The scaled matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix5X4 Multiply(Matrix5X4 value1, T value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 * value2; /// Returns a new matrix with the negated elements of the given matrix. @@ -45,7 +46,7 @@ public static Matrix5X4 Multiply(Matrix5X4 value1, T value2) /// The negated matrix. [MethodImpl((MethodImplOptions) 768)] public static Matrix5X4 Negate(Matrix5X4 value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => -value; /// Subtracts the second matrix from the first. @@ -54,24 +55,7 @@ public static Matrix5X4 Negate(Matrix5X4 value) /// The result of the subtraction. [MethodImpl((MethodImplOptions) 768)] public static Matrix5X4 Subtract(Matrix5X4 value1, Matrix5X4 value2) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => value1 - value2; - - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static unsafe Matrix5X4 Lerp(Matrix5X4 matrix1, Matrix5X4 matrix2, T amount) - where T : unmanaged, IFormattable, IEquatable, IComparable - { - return new( - Vector4D.Lerp(matrix1.Row1, matrix2.Row1, amount), - Vector4D.Lerp(matrix1.Row2, matrix2.Row2, amount), - Vector4D.Lerp(matrix1.Row3, matrix2.Row3, amount), - Vector4D.Lerp(matrix1.Row4, matrix2.Row4, amount), - Vector4D.Lerp(matrix1.Row5, matrix2.Row5, amount) - ); - } } } diff --git a/sources/Maths/Maths/Matrix5X4.cs b/sources/Maths/Maths/Matrix5X4.cs index 348ba77941..b9c85c3f89 100644 --- a/sources/Maths/Maths/Matrix5X4.cs +++ b/sources/Maths/Maths/Matrix5X4.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -11,8 +12,7 @@ namespace Silk.NET.Maths /// A structure encapsulating a 4x4 matrix. [Serializable] [DataContract] - public struct Matrix5X4 : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + public partial struct Matrix5X4 { private static readonly Matrix5X4 _identity = new ( @@ -23,275 +23,6 @@ public struct Matrix5X4 : IEquatable> Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.Zero ); - /// - /// Row 1 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row1; - - /// - /// Row 2 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row2; - - /// - /// Row 3 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row3; - - /// - /// Row 4 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row4; - - /// - /// Row 5 of the matrix. - /// - [IgnoreDataMember] - public Vector4D Row5; - - /// Value at row 1, column 1 of the matrix. - [DataMember] - public T M11 - { - readonly get => Row1.X; - set => Row1.X = value; - } - - /// Value at row 1, column 2 of the matrix. - [DataMember] - public T M12 - { - readonly get => Row1.Y; - set => Row1.Y = value; - } - - /// Value at row 1, column 3 of the matrix. - [DataMember] - public T M13 - { - readonly get => Row1.Z; - set => Row1.Z = value; - } - - /// Value at row 1, column 4 of the matrix. - [DataMember] - public T M14 - { - readonly get => Row1.W; - set => Row1.W = value; - } - - /// Value at row 2, column 1 of the matrix. - [DataMember] - public T M21 - { - readonly get => Row2.X; - set => Row2.X = value; - } - - /// Value at row 2, column 2 of the matrix. - [DataMember] - public T M22 - { - readonly get => Row2.Y; - set => Row2.Y = value; - } - - /// Value at row 2, column 3 of the matrix. - [DataMember] - public T M23 - { - readonly get => Row2.Z; - set => Row2.Z = value; - } - - /// Value at row 2, column 4 of the matrix. - [DataMember] - public T M24 - { - readonly get => Row2.W; - set => Row2.W = value; - } - - /// Value at row 3, column 1 of the matrix. - [DataMember] - public T M31 - { - readonly get => Row3.X; - set => Row3.X = value; - } - - /// Value at row 3, column 2 of the matrix. - [DataMember] - public T M32 - { - readonly get => Row3.Y; - set => Row3.Y = value; - } - - /// Value at row 3, column 3 of the matrix. - [DataMember] - public T M33 - { - readonly get => Row3.Z; - set => Row3.Z = value; - } - - /// Value at row 3, column 4 of the matrix. - [DataMember] - public T M34 - { - readonly get => Row3.W; - set => Row3.W = value; - } - - /// Value at row 4, column 1 of the matrix. - [DataMember] - public T M41 - { - readonly get => Row4.X; - set => Row4.X = value; - } - - /// Value at row 4, column 2 of the matrix. - [DataMember] - public T M42 - { - readonly get => Row4.Y; - set => Row4.Y = value; - } - - /// Value at row 4, column 3 of the matrix. - [DataMember] - public T M43 - { - readonly get => Row4.Z; - set => Row4.Z = value; - } - - /// Value at row 4, column 4 of the matrix. - [DataMember] - public T M44 - { - readonly get => Row4.W; - set => Row4.W = value; - } - - /// Value at row 5, column 1 of the matrix. - [DataMember] - public T M51 - { - readonly get => Row5.X; - set => Row5.X = value; - } - - /// Value at row 5, column 2 of the matrix. - [DataMember] - public T M52 - { - readonly get => Row5.Y; - set => Row5.Y = value; - } - - /// Value at row 5, column 3 of the matrix. - [DataMember] - public T M53 - { - readonly get => Row5.Z; - set => Row5.Z = value; - } - - /// Value at row 5, column 4 of the matrix. - [DataMember] - public T M54 - { - readonly get => Row5.W; - set => Row5.W = value; - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - public unsafe Vector4D this[int x] - { - get - { - static void VerifyBounds(int i) - { - static void ThrowHelper() => throw new IndexOutOfRangeException(); - - if (i > 4 || i < 0) - ThrowHelper(); - } - - VerifyBounds(x); - return Unsafe.Add(ref Row1, x); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - public unsafe T this[int x, int y] - { - get - { - var row = this[x]; - return row[y]; - } - } - - /// - /// Constructs a from the given rows - /// - public Matrix5X4(Vector4D row1, Vector4D row2, Vector4D row3, Vector4D row4, Vector4D row5) - { - Row1 = row1; - Row2 = row2; - Row3 = row3; - Row4 = row4; - Row5 = row5; - } - - /// Constructs a from the given components. - public Matrix5X4 - ( - T m11, - T m12, - T m13, - T m14, - T m21, - T m22, - T m23, - T m24, - T m31, - T m32, - T m33, - T m34, - T m41, - T m42, - T m43, - T m44, - T m51, - T m52, - T m53, - T m54 - ) - { - Row1 = new(m11, m12, m13, m14); - Row2 = new(m21, m22, m23, m24); - Row3 = new(m31, m32, m33, m34); - Row4 = new(m41, m42, m43, m44); - Row5 = new(m51, m52, m53, m54); - } - /// Constructs a from the given . /// The source . public Matrix5X4(Matrix3X2 value) @@ -387,57 +118,6 @@ public readonly bool IsIdentity Scalar.Equal(M51, Scalar.Zero) && Scalar.Equal(M52, Scalar.Zero) && Scalar.Equal(M53, Scalar.Zero) && Scalar.Equal(M54, Scalar.Zero); - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - public static unsafe Matrix5X4 operator +(Matrix5X4 value1, Matrix5X4 value2) - { - return new - ( - value1.Row1 + value2.Row1, value1.Row2 + value2.Row2, value1.Row3 + value2.Row3, - value1.Row4 + value2.Row4, value1.Row5 + value2.Row5 - ); - } - - /// Returns a boolean indicating whether the given two matrices are equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are equal; False otherwise. - public static unsafe bool operator ==(Matrix5X4 value1, Matrix5X4 value2) - { - return Scalar.Equal(value1.M11, value2.M11) && Scalar.Equal(value1.M22, value2.M22) && - Scalar.Equal(value1.M33, value2.M33) && - Scalar.Equal(value1.M44, value2.M44) && // Check diagonal elements first for early out. - Scalar.Equal(value1.M12, value2.M12) && Scalar.Equal(value1.M13, value2.M13) && - Scalar.Equal(value1.M14, value2.M14) && Scalar.Equal(value1.M21, value2.M21) && - Scalar.Equal(value1.M23, value2.M23) && Scalar.Equal(value1.M24, value2.M24) && - Scalar.Equal(value1.M31, value2.M31) && Scalar.Equal(value1.M32, value2.M32) && - Scalar.Equal(value1.M34, value2.M34) && Scalar.Equal(value1.M41, value2.M41) && - Scalar.Equal(value1.M42, value2.M42) && Scalar.Equal(value1.M43, value2.M43) && - Scalar.Equal(value1.M51, value2.M51) && Scalar.Equal(value1.M52, value2.M52) && - Scalar.Equal(value1.M53, value2.M53) && Scalar.Equal(value1.M54, value2.M54); - } - - /// Returns a boolean indicating whether the given two matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// True if the given matrices are not equal; False if they are equal. - public static unsafe bool operator !=(Matrix5X4 value1, Matrix5X4 value2) - { - return Scalar.NotEqual(value1.M11, value2.M11) || Scalar.NotEqual(value1.M22, value2.M22) || - Scalar.NotEqual(value1.M33, value2.M33) || - Scalar.NotEqual(value1.M44, value2.M44) || // Check diagonal elements first for early out. - Scalar.NotEqual(value1.M12, value2.M12) || Scalar.NotEqual(value1.M13, value2.M13) || - Scalar.NotEqual(value1.M14, value2.M14) || Scalar.NotEqual(value1.M21, value2.M21) || - Scalar.NotEqual(value1.M23, value2.M23) || Scalar.NotEqual(value1.M24, value2.M24) || - Scalar.NotEqual(value1.M31, value2.M31) || Scalar.NotEqual(value1.M32, value2.M32) || - Scalar.NotEqual(value1.M34, value2.M34) || Scalar.NotEqual(value1.M41, value2.M41) || - Scalar.NotEqual(value1.M42, value2.M42) || Scalar.NotEqual(value1.M43, value2.M43) || - Scalar.NotEqual(value1.M51, value2.M51) || Scalar.NotEqual(value1.M52, value2.M52) || - Scalar.NotEqual(value1.M53, value2.M53) || Scalar.NotEqual(value1.M54, value2.M54); - } - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -463,82 +143,6 @@ public readonly bool IsIdentity ); } - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static unsafe Matrix5X4 operator -(Matrix5X4 value1, Matrix5X4 value2) - { - return new( - value1.Row1 - value2.Row1, - value1.Row2 - value2.Row2, - value1.Row3 - value2.Row3, - value1.Row4 - value2.Row4, - value1.Row5 - value2.Row5 - ); - } - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - public static unsafe Matrix5X4 operator -(Matrix5X4 value) - { - return new( - -value.Row1, - -value.Row2, - -value.Row3, - -value.Row4, - -value.Row5 - ); - } - - /// Returns a boolean indicating whether the given Object is equal to this matrix instance. - /// The Object to compare against. - /// True if the Object is equal to this matrix; False otherwise. - [MethodImpl((MethodImplOptions) 768)] - public override readonly bool Equals(object? obj) - => (obj is Matrix5X4 other) && Equals(other); - - /// Returns a boolean indicating whether this matrix instance is equal to the other given matrix. - /// The matrix to compare this instance to. - /// True if the matrices are equal; False otherwise. - public readonly bool Equals(Matrix5X4 other) - => this == other; - - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - HashCode hash = default; - - hash.Add(M11); - hash.Add(M12); - hash.Add(M13); - hash.Add(M14); - - hash.Add(M21); - hash.Add(M22); - hash.Add(M23); - hash.Add(M24); - - hash.Add(M31); - hash.Add(M32); - hash.Add(M33); - hash.Add(M34); - - hash.Add(M41); - hash.Add(M42); - hash.Add(M43); - hash.Add(M44); - - hash.Add(M51); - hash.Add(M52); - hash.Add(M53); - hash.Add(M54); - - return hash.ToHashCode(); - } - /// Returns a String representing this matrix instance. /// The string representation. public override readonly string ToString() @@ -796,7 +400,7 @@ public static explicit operator Matrix5X4(Matrix5X4 from) /// /// The type to cast to /// The casted matrix - public Matrix5X4 As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Matrix5X4 As() where TOther : INumberBase { return new(Row1.As(), Row2.As(), Row3.As(), Row4.As(), Row5.As()); } diff --git a/sources/Maths/Maths/Matrix5X4.gen.cs b/sources/Maths/Maths/Matrix5X4.gen.cs index f2eeff2e38..c4da23f556 100644 --- a/sources/Maths/Maths/Matrix5X4.gen.cs +++ b/sources/Maths/Maths/Matrix5X4.gen.cs @@ -2,31 +2,60 @@ namespace Silk.NET.Maths { using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.CompilerServices; + using System.Runtime.Serialization; public partial struct Matrix5X4 : IEquatable> where T : INumberBase { /// The 1st row of the matrix represented as a vector. + [IgnoreDataMember] public Vector4D Row1; /// The 2nd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector4D Row2; /// The 3rd row of the matrix represented as a vector. + [IgnoreDataMember] public Vector4D Row3; /// The 4th row of the matrix represented as a vector. + [IgnoreDataMember] public Vector4D Row4; /// The 5th row of the matrix represented as a vector. + [IgnoreDataMember] public Vector4D Row5; /// /// Constructs a from the given rows. /// - public Matrix5X4(Vector4D row1, Vector4D row2, Vector4D row3, Vector4D row4, Vector4D row5) => (Row1, Row2, Row3, Row4, Row5) = (row1, row2, row3, row4, row5); + public Matrix5X4(Vector4D row1, Vector4D row2, Vector4D row3, Vector4D row4, Vector4D row5) => + (Row1, Row2, Row3, Row4, Row5) = (row1, row2, row3, row4, row5); + /// + /// Constructs a from the given components. + /// + public Matrix5X4( + T m11, T m12, T m13, T m14, + T m21, T m22, T m23, T m24, + T m31, T m32, T m33, T m34, + T m41, T m42, T m43, T m44, + T m51, T m52, T m53, T m54) + { + Row1 = new(m11, m12, m13, m14); + Row2 = new(m21, m22, m23, m24); + Row3 = new(m31, m32, m33, m34); + Row4 = new(m41, m42, m43, m44); + Row5 = new(m51, m52, m53, m54); + } + + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. [UnscopedRef] public ref Vector4D this[int row] { @@ -46,94 +75,120 @@ public ref Vector4D this[int row] return ref Row5; } - throw new ArgumentOutOfRangeException(nameof(row)); + throw new IndexOutOfRangeException(); } } + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. [UnscopedRef] public ref T this[int row, int column] => ref this[row][column]; /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M11 => ref Row1.X; /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M12 => ref Row1.Y; /// Gets the element in the 1st row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M13 => ref Row1.Z; /// Gets the element in the 1st row and 4th column of the matrix. + [DataMember] [UnscopedRef] public ref T M14 => ref Row1.W; /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M21 => ref Row2.X; /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M22 => ref Row2.Y; /// Gets the element in the 2nd row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M23 => ref Row2.Z; /// Gets the element in the 2nd row and 4th column of the matrix. + [DataMember] [UnscopedRef] public ref T M24 => ref Row2.W; /// Gets the element in the 3rd row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M31 => ref Row3.X; /// Gets the element in the 3rd row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M32 => ref Row3.Y; /// Gets the element in the 3rd row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M33 => ref Row3.Z; /// Gets the element in the 3rd row and 4th column of the matrix. + [DataMember] [UnscopedRef] public ref T M34 => ref Row3.W; /// Gets the element in the 4th row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M41 => ref Row4.X; /// Gets the element in the 4th row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M42 => ref Row4.Y; /// Gets the element in the 4th row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M43 => ref Row4.Z; /// Gets the element in the 4th row and 4th column of the matrix. + [DataMember] [UnscopedRef] public ref T M44 => ref Row4.W; /// Gets the element in the 5th row and 1st column of the matrix. + [DataMember] [UnscopedRef] public ref T M51 => ref Row5.X; /// Gets the element in the 5th row and 2nd column of the matrix. + [DataMember] [UnscopedRef] public ref T M52 => ref Row5.Y; /// Gets the element in the 5th row and 3rd column of the matrix. + [DataMember] [UnscopedRef] public ref T M53 => ref Row5.Z; /// Gets the element in the 5th row and 4th column of the matrix. + [DataMember] [UnscopedRef] public ref T M54 => ref Row5.W; /// + [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix5X4 other && Equals(other); /// @@ -205,12 +260,17 @@ public ref Vector4D this[int row] public static partial class Matrix5X4 { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. public static Matrix5X4 Lerp(Matrix5X4 value1, Matrix5X4 value2, T amount) where T : IFloatingPointIeee754 => - new(new(T.Lerp(value1.M11, value2.M11, amount), T.Lerp(value1.M12, value2.M12, amount), T.Lerp(value1.M13, value2.M13, amount), T.Lerp(value1.M14, value2.M14, amount)), - new(T.Lerp(value1.M21, value2.M21, amount), T.Lerp(value1.M22, value2.M22, amount), T.Lerp(value1.M23, value2.M23, amount), T.Lerp(value1.M24, value2.M24, amount)), - new(T.Lerp(value1.M31, value2.M31, amount), T.Lerp(value1.M32, value2.M32, amount), T.Lerp(value1.M33, value2.M33, amount), T.Lerp(value1.M34, value2.M34, amount)), - new(T.Lerp(value1.M41, value2.M41, amount), T.Lerp(value1.M42, value2.M42, amount), T.Lerp(value1.M43, value2.M43, amount), T.Lerp(value1.M44, value2.M44, amount)), - new(T.Lerp(value1.M51, value2.M51, amount), T.Lerp(value1.M52, value2.M52, amount), T.Lerp(value1.M53, value2.M53, amount), T.Lerp(value1.M54, value2.M54, amount))); + new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), + Vector4D.Lerp(value1.Row2, value2.Row2, amount), + Vector4D.Lerp(value1.Row3, value2.Row3, amount), + Vector4D.Lerp(value1.Row4, value2.Row4, amount), + Vector4D.Lerp(value1.Row5, value2.Row5, amount)); } } From acaf6b4b28d4311d929cd402a1dcc31320de4510 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Mon, 30 Jun 2025 19:45:25 -0700 Subject: [PATCH 37/67] Update existing types to use INumberBase. --- sources/Maths/Maths/Box2D.cs | 9 +++++---- sources/Maths/Maths/Box3D.cs | 4 ++-- sources/Maths/Maths/Circle.cs | 8 +++++--- sources/Maths/Maths/Cube.cs | 9 +++++---- sources/Maths/Maths/Legacy/Quaternion.cs | 6 ++++-- sources/Maths/Maths/Plane.Ops.cs | 17 +++++++++-------- sources/Maths/Maths/Plane.cs | 10 ++++++---- sources/Maths/Maths/Ray2D.cs | 8 +++++--- sources/Maths/Maths/Ray3D.cs | 7 ++++--- sources/Maths/Maths/Rectangle.Ops.cs | 5 +++-- sources/Maths/Maths/Rectangle.cs | 9 +++++---- sources/Maths/Maths/Sphere.cs | 7 ++++--- 12 files changed, 57 insertions(+), 42 deletions(-) diff --git a/sources/Maths/Maths/Box2D.cs b/sources/Maths/Maths/Box2D.cs index c9b4945be4..a5536faf6e 100644 --- a/sources/Maths/Maths/Box2D.cs +++ b/sources/Maths/Maths/Box2D.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -14,7 +15,7 @@ namespace Silk.NET.Maths [DataContract] public struct Box2D : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { /// /// The min. @@ -148,7 +149,7 @@ public Box2D GetScaled(Vector2D scale, Vector2D anchor) /// The type of the scale. /// The calculated box. public Box2D GetScaled(Vector2D scale, Vector2D anchor) - where TScale : unmanaged, IFormattable, IEquatable, IComparable + where TScale : INumberBase { return this.As().GetScaled(scale, anchor.As()).As(); } @@ -209,9 +210,9 @@ public override int GetHashCode() /// /// The type to cast to /// The casted box - public Box2D As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Box2D As() where TOther : INumberBase { return new(Min.As(), Max.As()); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Box3D.cs b/sources/Maths/Maths/Box3D.cs index 48812a2039..f32a0afd1f 100644 --- a/sources/Maths/Maths/Box3D.cs +++ b/sources/Maths/Maths/Box3D.cs @@ -15,7 +15,7 @@ namespace Silk.NET.Maths [DataContract] public struct Box3D : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { /// /// The min. @@ -222,7 +222,7 @@ public override int GetHashCode() /// /// The type to cast to /// The casted box - public Box3D As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Box3D As() where TOther : INumberBase { return new(Min.As(), Max.As()); } diff --git a/sources/Maths/Maths/Circle.cs b/sources/Maths/Maths/Circle.cs index fafcc12f4d..fd0a4ff342 100644 --- a/sources/Maths/Maths/Circle.cs +++ b/sources/Maths/Maths/Circle.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.Serialization; namespace Silk.NET.Maths @@ -12,7 +13,8 @@ namespace Silk.NET.Maths [Serializable] [DataContract] public struct Circle - : IEquatable> where T : unmanaged, IFormattable, IEquatable, IComparable + : IEquatable> + where T : INumberBase { /// /// The center. @@ -172,9 +174,9 @@ public override int GetHashCode() /// /// The type to cast to /// The casted circle - public Circle As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Circle As() where TOther : INumberBase { return new(Center.As(), Scalar.As(Radius)); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Cube.cs b/sources/Maths/Maths/Cube.cs index c5ef00cca7..b0a2e2a3c2 100644 --- a/sources/Maths/Maths/Cube.cs +++ b/sources/Maths/Maths/Cube.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -14,7 +15,7 @@ namespace Silk.NET.Maths [DataContract] public struct Cube : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { /// /// The origin. @@ -169,7 +170,7 @@ public Cube GetScaled(Vector3D scale, Vector3D anchor) /// The anchor. /// The calculated cube. public Cube GetScaled(Vector3D scale, Vector3D anchor) - where TScale : unmanaged, IFormattable, IEquatable, IComparable + where TScale : INumberBase { var convertedAnchor = anchor.As(); var min = (scale * (Origin.As() - convertedAnchor)) + convertedAnchor; @@ -235,9 +236,9 @@ public override int GetHashCode() /// /// The type to cast to /// The casted cube - public Cube As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Cube As() where TOther : INumberBase { return new(Origin.As(), Max.As()); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Legacy/Quaternion.cs b/sources/Maths/Maths/Legacy/Quaternion.cs index b0c46916b9..2694588fca 100644 --- a/sources/Maths/Maths/Legacy/Quaternion.cs +++ b/sources/Maths/Maths/Legacy/Quaternion.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using Silk.NET.Maths; @@ -16,7 +17,8 @@ namespace Silk.NET.Maths.Legacy [Serializable] [DataContract] public struct Quaternion - : IEquatable> where T : unmanaged, IFormattable, IEquatable, IComparable + : IEquatable> + where T : INumberBase { private const float SlerpEpsilon = 1e-6f; @@ -786,7 +788,7 @@ public static explicit operator Quaternion(Quaternion from) /// /// The type to cast to /// The casted quaternion - public Quaternion As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Quaternion As() where TOther : INumberBase { return new(Scalar.As(X), Scalar.As(Y), Scalar.As(Z), Scalar.As(W)); } diff --git a/sources/Maths/Maths/Plane.Ops.cs b/sources/Maths/Maths/Plane.Ops.cs index 24879072fb..fff64125ca 100644 --- a/sources/Maths/Maths/Plane.Ops.cs +++ b/sources/Maths/Maths/Plane.Ops.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.CompilerServices; namespace Silk.NET.Maths @@ -18,7 +19,7 @@ public static class Plane /// The Plane containing the three points. [MethodImpl((MethodImplOptions) 768)] public static Plane CreateFromVertices(Vector3D point1, Vector3D point2, Vector3D point3) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { var a = point1; var b = point2; @@ -86,7 +87,7 @@ public static Plane CreateFromVertices(Vector3D point1, Vector3D poi /// The dot product. [MethodImpl((MethodImplOptions) 768)] public static T Dot(Plane plane, Vector4D value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => Scalar.Add( Scalar.Add( Scalar.Add(Scalar.Multiply(plane.Normal.X, value.X), @@ -99,7 +100,7 @@ public static T Dot(Plane plane, Vector4D value) /// The resulting value. [MethodImpl((MethodImplOptions) 768)] public static T DotCoordinate(Plane plane, Vector3D value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => Scalar.Add(Vector3D.Dot(plane.Normal, value), plane.Distance); /// Returns the dot product of a specified Vector3D and the Normal vector of this Plane. @@ -108,7 +109,7 @@ public static T DotCoordinate(Plane plane, Vector3D value) /// The resulting dot product. [MethodImpl((MethodImplOptions) 768)] public static T DotNormal(Plane plane, Vector3D value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase => Vector3D.Dot(plane.Normal, value); private const float NormalizeEpsilon = 1.192092896e-07f; // smallest such that 1.0+NormalizeEpsilon != 1.0 @@ -118,7 +119,7 @@ public static T DotNormal(Plane plane, Vector3D value) /// The normalized Plane. [MethodImpl((MethodImplOptions) 768)] public static Plane Normalize(Plane value) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { /*if (Vector.IsHardwareAccelerated) { @@ -140,7 +141,7 @@ public static Plane Normalize(Plane value) Scalar.Multiply(value.Normal.Y, value.Normal.Y)), Scalar.Multiply(value.Normal.Z, value.Normal.Z)); - if (!Scalar.GreaterThanOrEqual(Scalar.Abs(Scalar.Subtract(f, Scalar.One)), Scalar.As(NormalizeEpsilon))) + if (!Scalar.GreaterThanOrEqual(T.Abs(Scalar.Subtract(f, Scalar.One)), Scalar.As(NormalizeEpsilon))) { return value; // It already normalized, so we don't need to further process. } @@ -162,7 +163,7 @@ public static Plane Normalize(Plane value) /// The transformed Plane. [MethodImpl((MethodImplOptions) 768)] public static Plane Transform(Plane plane, Matrix4X4 matrix) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Matrix4X4.Invert(matrix, out Matrix4X4 m); @@ -182,7 +183,7 @@ public static Plane Transform(Plane plane, Matrix4X4 matrix) /// A new Plane that results from applying the rotation. [MethodImpl((MethodImplOptions) 768)] public static Plane Transform(Plane plane, Legacy.Quaternion rotation) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { // Compute rotation matrix. T x2 = Scalar.Add(rotation.X, rotation.X); diff --git a/sources/Maths/Maths/Plane.cs b/sources/Maths/Maths/Plane.cs index 83b0fccaf1..f14e3f989f 100644 --- a/sources/Maths/Maths/Plane.cs +++ b/sources/Maths/Maths/Plane.cs @@ -3,6 +3,7 @@ using System; using System.Globalization; +using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.Serialization; @@ -15,7 +16,8 @@ namespace Silk.NET.Maths [Serializable] [DataContract] public struct Plane - : IEquatable> where T : unmanaged, IFormattable, IEquatable, IComparable + : IEquatable> + where T : INumberBase { /// The normal vector of the Plane. [DataMember] @@ -173,7 +175,7 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new((Vector3D) from.Normal, Scalar.As(from.Distance)); + => new(from.Normal.As(), short.CreateSaturating(from.Distance)); /// /// Converts a into one with a of @@ -212,9 +214,9 @@ public static explicit operator Plane(Plane from) /// /// The type to cast to /// The casted plane - public Plane As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Plane As() where TOther : INumberBase { return new(Normal.As(), Scalar.As(Distance)); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Ray2D.cs b/sources/Maths/Maths/Ray2D.cs index 91b181f2fd..9980748f31 100644 --- a/sources/Maths/Maths/Ray2D.cs +++ b/sources/Maths/Maths/Ray2D.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.Serialization; namespace Silk.NET.Maths @@ -14,7 +15,7 @@ namespace Silk.NET.Maths [DataContract] public struct Ray2D : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { /// /// The origin of this Ray. @@ -129,9 +130,10 @@ public override int GetHashCode() /// /// The type to cast to /// The casted ray - public Ray2D As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Ray2D As() + where TOther : INumberBase { return new(Origin.As(), Direction.As()); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Ray3D.cs b/sources/Maths/Maths/Ray3D.cs index 14797d6756..b73feceb17 100644 --- a/sources/Maths/Maths/Ray3D.cs +++ b/sources/Maths/Maths/Ray3D.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.Serialization; namespace Silk.NET.Maths @@ -14,7 +15,7 @@ namespace Silk.NET.Maths [DataContract] public struct Ray3D : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { /// /// The origin of this Ray. @@ -133,9 +134,9 @@ public override int GetHashCode() /// /// The type to cast to /// The casted ray - public Ray3D As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Ray3D As() where TOther : INumberBase { return new(Origin.As(), Direction.As()); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Rectangle.Ops.cs b/sources/Maths/Maths/Rectangle.Ops.cs index 4913e6523c..7dd2d6e9a0 100644 --- a/sources/Maths/Maths/Rectangle.Ops.cs +++ b/sources/Maths/Maths/Rectangle.Ops.cs @@ -1,7 +1,8 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; namespace Silk.NET.Maths { @@ -20,7 +21,7 @@ public static class Rectangle /// The type. /// The constructed rectangle. public static Rectangle FromLTRB(T left, T top, T right, T bottom) - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { Vector2D o = new(left, top); return new Rectangle(o, new Vector2D(right, bottom) - o); diff --git a/sources/Maths/Maths/Rectangle.cs b/sources/Maths/Maths/Rectangle.cs index 344d8f02a9..c00d48993d 100644 --- a/sources/Maths/Maths/Rectangle.cs +++ b/sources/Maths/Maths/Rectangle.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.Serialization; namespace Silk.NET.Maths @@ -13,7 +14,7 @@ namespace Silk.NET.Maths [DataContract] public struct Rectangle : IEquatable> - where T : unmanaged, IFormattable, IEquatable, IComparable + where T : INumberBase { /// /// The origin. @@ -161,7 +162,7 @@ public Rectangle GetScaled(Vector2D scale, Vector2D anchor) /// The anchor. /// The calculated rectangle. public Rectangle GetScaled(Vector2D scale, Vector2D anchor) - where TScale : unmanaged, IFormattable, IEquatable, IComparable + where TScale : INumberBase { var convertedAnchor = anchor.As(); var min = (scale * (Origin.As() - convertedAnchor)) + convertedAnchor; @@ -227,9 +228,9 @@ public override int GetHashCode() /// /// The type to cast to /// The casted rectangle - public Rectangle As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Rectangle As() where TOther : INumberBase { return new(Origin.As(), Size.As()); } } -} \ No newline at end of file +} diff --git a/sources/Maths/Maths/Sphere.cs b/sources/Maths/Maths/Sphere.cs index 5985308774..91bce6e0f2 100644 --- a/sources/Maths/Maths/Sphere.cs +++ b/sources/Maths/Maths/Sphere.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Numerics; using System.Runtime.Serialization; namespace Silk.NET.Maths @@ -12,7 +13,7 @@ namespace Silk.NET.Maths [Serializable] [DataContract] public struct Sphere - : IEquatable> where T : unmanaged, IFormattable, IEquatable, IComparable + : IEquatable> where T : INumberBase { /// /// The center. @@ -168,9 +169,9 @@ public override int GetHashCode() /// /// The type to cast to /// The casted sphere - public Sphere As() where TOther : unmanaged, IFormattable, IEquatable, IComparable + public Sphere As() where TOther : INumberBase { return new(Center.As(), Scalar.As(Radius)); } } -} \ No newline at end of file +} From ffb7f58d0a373b6780d83b045b07323a38257f65 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Mon, 30 Jun 2025 20:34:30 -0700 Subject: [PATCH 38/67] Fix errors. --- sources/Maths/Maths/Matrix2X4.cs | 10 ------- sources/Maths/Maths/Matrix3X2.cs | 13 ---------- sources/Maths/Maths/Matrix3X3.Ops.cs | 2 +- sources/Maths/Maths/Matrix4X2.cs | 39 ---------------------------- sources/Maths/Maths/Matrix4X4.Ops.cs | 2 +- sources/Maths/Maths/Vector2D.gen.cs | 1 - sources/Maths/Maths/Vector3D.gen.cs | 1 - sources/Maths/Maths/Vector4D.gen.cs | 1 - 8 files changed, 2 insertions(+), 67 deletions(-) diff --git a/sources/Maths/Maths/Matrix2X4.cs b/sources/Maths/Maths/Matrix2X4.cs index 51d70e9c93..c991743a0d 100644 --- a/sources/Maths/Maths/Matrix2X4.cs +++ b/sources/Maths/Maths/Matrix2X4.cs @@ -81,16 +81,6 @@ public readonly bool IsIdentity return value1.X * value2.Row1 + value1.Y * value2.Row2; } - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix2X3 operator *(Matrix2X4 value1, Matrix4X3 value2) - { - return new(value1.M11 * value2.Row1 + value2.M12 * value2.Row2 + value1.M13 * value2.Row3 + value1.M14 * value2.Row4, - value1.M21 * value2.Row1 + value2.M22 * value2.Row2 + value1.M23 * value2.Row3 + value1.M24 * value2.Row4); - } - /// Multiplies a matrix by a scalar value. /// The source matrix. /// The scaling factor. diff --git a/sources/Maths/Maths/Matrix3X2.cs b/sources/Maths/Maths/Matrix3X2.cs index 7f3224660c..f1c69cd9a8 100644 --- a/sources/Maths/Maths/Matrix3X2.cs +++ b/sources/Maths/Maths/Matrix3X2.cs @@ -81,19 +81,6 @@ public Matrix3X2(Matrix4X2 value) return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3; } - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix3X2 operator *(Matrix3X3 value1, Matrix3X2 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M33 * value2.Row3, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2 + value1.M23 * value2.Row3 - ); - } - /// Scales all elements in a matrix by the given scalar factor. /// The source matrix. /// The scaling value to use. diff --git a/sources/Maths/Maths/Matrix3X3.Ops.cs b/sources/Maths/Maths/Matrix3X3.Ops.cs index 5a77409ea4..e955b5c9bb 100644 --- a/sources/Maths/Maths/Matrix3X3.Ops.cs +++ b/sources/Maths/Maths/Matrix3X3.Ops.cs @@ -15,6 +15,7 @@ public static partial class Matrix3X3 private const float BillboardEpsilon = 1e-4f; private const float DecomposeEpsilon = 0.0001f; + /* private struct CanonicalBasis where T : INumberBase { @@ -23,7 +24,6 @@ private struct CanonicalBasis public Vector3D Row2; }; - /* private struct VectorBasis where T : INumberBase { diff --git a/sources/Maths/Maths/Matrix4X2.cs b/sources/Maths/Maths/Matrix4X2.cs index 45d2b8c231..3893815a5d 100644 --- a/sources/Maths/Maths/Matrix4X2.cs +++ b/sources/Maths/Maths/Matrix4X2.cs @@ -85,45 +85,6 @@ public readonly bool IsIdentity Scalar.Equal(M31, Scalar.Zero) && Scalar.Equal(M32, Scalar.Zero) && Scalar.Equal(M41, Scalar.Zero) && Scalar.Equal(M42, Scalar.Zero); - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix2X2 operator *(Matrix2X4 value1, Matrix4X2 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3 + value1.M14 * value2.Row4, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3 + value1.M24 * value2.Row4 - ); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix3X2 operator *(Matrix3X4 value1, Matrix4X2 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3 + value1.M14 * value2.Row4, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3 + value1.M24 * value2.Row4, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3 + value1.M24 * value2.Row4 - ); - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static unsafe Matrix4X2 operator *(Matrix4X4 value1, Matrix4X2 value2) - { - return new( - value1.M11 * value2.Row1 + value1.M12 * value2.Row2 + value1.M13 * value2.Row3 + value1.M14 * value2.Row4, - value1.M21 * value2.Row1 + value1.M22 * value2.Row2 + value1.M23 * value2.Row3 + value1.M24 * value2.Row4, - value1.M31 * value2.Row1 + value1.M32 * value2.Row2 + value1.M33 * value2.Row3 + value1.M34 * value2.Row4, - value1.M41 * value2.Row1 + value1.M42 * value2.Row2 + value1.M43 * value2.Row3 + value1.M44 * value2.Row4 - ); - } - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. diff --git a/sources/Maths/Maths/Matrix4X4.Ops.cs b/sources/Maths/Maths/Matrix4X4.Ops.cs index 5bc49c3d06..d44381a2c8 100644 --- a/sources/Maths/Maths/Matrix4X4.Ops.cs +++ b/sources/Maths/Maths/Matrix4X4.Ops.cs @@ -20,6 +20,7 @@ public static partial class Matrix4X4 #endif private const float DecomposeEpsilon = 0.0001f; + /* private struct CanonicalBasis where T : INumberBase { @@ -28,7 +29,6 @@ private struct CanonicalBasis public Vector3D Row2; }; - /* private struct VectorBasis where T : INumberBase { diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index 3c9845a843..d62934f8fb 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -356,7 +356,6 @@ public static implicit operator (T X, T Y)(Vector2D v) => public static Vector2D operator /(Vector2D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar); - } public static partial class Vector2D diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index e894afc9a1..f65b1522b7 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -395,7 +395,6 @@ public static implicit operator (T X, T Y, T Z)(Vector3D v) => public static Vector3D operator /(Vector3D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); - } public static partial class Vector3D diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index 1cecb3c459..1055a4c936 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -434,7 +434,6 @@ public static implicit operator (T X, T Y, T Z, T W)(Vector4D v) => public static Vector4D operator /(Vector4D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); - } public static partial class Vector4D From d07c355799244a3c777a70aa5e17425e99ca124c Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 13:11:02 -0700 Subject: [PATCH 39/67] Code-gen more matrix implememtations. --- sources/Maths/Maths/Matrix2X2.cs | 125 ------------- sources/Maths/Maths/Matrix2X2.gen.cs | 131 +++++++++++++ sources/Maths/Maths/Matrix2X3.cs | 132 ------------- sources/Maths/Maths/Matrix2X3.gen.cs | 131 +++++++++++++ sources/Maths/Maths/Matrix2X4.cs | 186 ------------------- sources/Maths/Maths/Matrix2X4.gen.cs | 131 +++++++++++++ sources/Maths/Maths/Matrix3X2.cs | 163 ---------------- sources/Maths/Maths/Matrix3X2.gen.cs | 146 +++++++++++++++ sources/Maths/Maths/Matrix3X3.cs | 149 --------------- sources/Maths/Maths/Matrix3X3.gen.cs | 146 +++++++++++++++ sources/Maths/Maths/Matrix3X4.cs | 211 --------------------- sources/Maths/Maths/Matrix3X4.gen.cs | 146 +++++++++++++++ sources/Maths/Maths/Matrix4X2.cs | 188 ------------------- sources/Maths/Maths/Matrix4X2.gen.cs | 161 ++++++++++++++++ sources/Maths/Maths/Matrix4X3.cs | 236 ----------------------- sources/Maths/Maths/Matrix4X3.gen.cs | 161 ++++++++++++++++ sources/Maths/Maths/Matrix4X4.cs | 241 ------------------------ sources/Maths/Maths/Matrix4X4.gen.cs | 161 ++++++++++++++++ sources/Maths/Maths/Matrix5X4.cs | 267 --------------------------- sources/Maths/Maths/Matrix5X4.gen.cs | 176 ++++++++++++++++++ 20 files changed, 1490 insertions(+), 1898 deletions(-) diff --git a/sources/Maths/Maths/Matrix2X2.cs b/sources/Maths/Maths/Matrix2X2.cs index 50bde7046e..ada5e31b39 100644 --- a/sources/Maths/Maths/Matrix2X2.cs +++ b/sources/Maths/Maths/Matrix2X2.cs @@ -69,15 +69,6 @@ public readonly bool IsIdentity return value1 * value2.Row1 + value1 * value2.Row2; } - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static unsafe Matrix2X2 operator *(Matrix2X2 value1, T value2) - { - return new(value1.Row1 * value2, value1.Row2 * value2); - } - /// Calculates the determinant of the matrix. /// The determinant of the matrix. public readonly T GetDeterminant() @@ -91,122 +82,6 @@ public readonly T GetDeterminant() return Scalar.Subtract(Scalar.Multiply(a, d), Scalar.Multiply(b, c)); } - /// Returns a String representing this matrix instance. - /// The string representation. - public override readonly string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1}}} {{M21:{2} M22:{3}}} }}", M11, M12, - M21, M22); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X2(Matrix2X2 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M21), - Scalar.As(from.M22)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X2(Matrix2X2 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X2(Matrix2X2 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X2(Matrix2X2 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X2(Matrix2X2 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X2(Matrix2X2 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M21), - Scalar.As(from.M22)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X2(Matrix2X2 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X2(Matrix2X2 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X2(Matrix2X2 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M21), - Scalar.As(from.M22)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X2(Matrix2X2 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M21), - Scalar.As(from.M22)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X2(Matrix2X2 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X2(Matrix2X2 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M21), - Scalar.As(from.M22)); - /// /// Returns this matrix casted to /// diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index d1bffe8d59..8d49a1fdba 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -96,6 +96,14 @@ public ref Vector2D this[int row] [UnscopedRef] public ref T M22 => ref Row2.Y; + + /// + public override string ToString() => + string.Format( + "{{ {{M11:{0} M12:{1}}} {{M21:{2} M22:{3}}} }}", + Row1.X, Row1.Y, + Row2.X, Row2.Y); + /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix2X2 other && Equals(other); @@ -148,6 +156,22 @@ public Matrix2X2 Transpose() => new(-value.Row1, -value.Row2); + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix2X2 operator *(T left, Matrix2X2 right) => + new(left * right.Row1, + left * right.Row2); + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix2X2 operator *(Matrix2X2 left, T right) => + new(left.Row1 * right, + left.Row2 * right); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -155,6 +179,113 @@ public Matrix2X2 Transpose() => public static Matrix2X2 operator *(Matrix2X2 left, Matrix2X2 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X2(Matrix2X2 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X2(Matrix2X2 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X2(Matrix2X2 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X2(Matrix2X2 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X2(Matrix2X2 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X2(Matrix2X2 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X2(Matrix2X2 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X2(Matrix2X2 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X2(Matrix2X2 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X2(Matrix2X2 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X2(Matrix2X2 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X2(Matrix2X2 from) => + new(from.Row1.As(), + from.Row2.As()); } public static partial class Matrix2X2 diff --git a/sources/Maths/Maths/Matrix2X3.cs b/sources/Maths/Maths/Matrix2X3.cs index 63e4bc944b..884d142dd2 100644 --- a/sources/Maths/Maths/Matrix2X3.cs +++ b/sources/Maths/Maths/Matrix2X3.cs @@ -80,138 +80,6 @@ public readonly bool IsIdentity return value1.X * value2.Row1 + value1.Y * value2.Row2; } - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static unsafe Matrix2X3 operator *(Matrix2X3 value1, T value2) - { - return new(value1.Row1 * value2, value1.Row2 * value2); - } - - /// Returns a String representing this matrix instance. - /// The string representation. - public override readonly string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1} M13:{2} }} {{M21:{3} M22:{4} M23:{5} }} }}", - M11, M12, M13, - M21, M22, M23); - } - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X3(Matrix2X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), Scalar.As(from.M23)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X3(Matrix2X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X3(Matrix2X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), - Scalar.As(from.M22), Scalar.As(from.M23)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X3(Matrix2X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), - Scalar.As(from.M22), Scalar.As(from.M23)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X3(Matrix2X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X3(Matrix2X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), Scalar.As(from.M23)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X3(Matrix2X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), - Scalar.As(from.M22), Scalar.As(from.M23)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X3(Matrix2X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X3(Matrix2X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), Scalar.As(from.M23)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X3(Matrix2X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), Scalar.As(from.M23)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X3(Matrix2X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X3(Matrix2X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), Scalar.As(from.M23)); - /// /// Returns this matrix casted to /// diff --git a/sources/Maths/Maths/Matrix2X3.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs index 7447bdd571..d8d87fd30b 100644 --- a/sources/Maths/Maths/Matrix2X3.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -105,6 +105,14 @@ public ref Vector3D this[int row] [UnscopedRef] public ref T M23 => ref Row2.Z; + + /// + public override string ToString() => + string.Format( + "{{ {{M11:{0} M12:{1} M13:{2}}} {{M21:{3} M22:{4} M23:{5}}} }}", + Row1.X, Row1.Y, Row1.Z, + Row2.X, Row2.Y, Row2.Z); + /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix2X3 other && Equals(other); @@ -158,6 +166,22 @@ public Matrix3X2 Transpose() => new(-value.Row1, -value.Row2); + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix2X3 operator *(T left, Matrix2X3 right) => + new(left * right.Row1, + left * right.Row2); + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix2X3 operator *(Matrix2X3 left, T right) => + new(left.Row1 * right, + left.Row2 * right); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -173,6 +197,113 @@ public Matrix3X2 Transpose() => public static Matrix2X2 operator *(Matrix2X3 left, Matrix3X2 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X3(Matrix2X3 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X3(Matrix2X3 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X3(Matrix2X3 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X3(Matrix2X3 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X3(Matrix2X3 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X3(Matrix2X3 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X3(Matrix2X3 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X3(Matrix2X3 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X3(Matrix2X3 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X3(Matrix2X3 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X3(Matrix2X3 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X3(Matrix2X3 from) => + new(from.Row1.As(), + from.Row2.As()); } public static partial class Matrix2X3 diff --git a/sources/Maths/Maths/Matrix2X4.cs b/sources/Maths/Maths/Matrix2X4.cs index c991743a0d..d6d530eb34 100644 --- a/sources/Maths/Maths/Matrix2X4.cs +++ b/sources/Maths/Maths/Matrix2X4.cs @@ -81,192 +81,6 @@ public readonly bool IsIdentity return value1.X * value2.Row1 + value1.Y * value2.Row2; } - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static unsafe Matrix2X4 operator *(Matrix2X4 value1, T value2) - { - return new(value1.Row1 * value2, value1.Row2 * value2); - } - - /// Returns a String representing this matrix instance. - /// The string representation. - public override readonly string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} }}", - M11, M12, M13, M14, - M21, M22, M23, M24); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X4(Matrix2X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X4(Matrix2X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X4(Matrix2X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X4(Matrix2X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X4(Matrix2X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X4(Matrix2X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X4(Matrix2X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X4(Matrix2X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X4(Matrix2X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X4(Matrix2X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X4(Matrix2X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix2X4(Matrix2X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24) - ); - /// /// Returns this matrix casted to /// diff --git a/sources/Maths/Maths/Matrix2X4.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs index 970be0f0f5..35573895a3 100644 --- a/sources/Maths/Maths/Matrix2X4.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -119,6 +119,14 @@ public ref Vector4D this[int row] [UnscopedRef] public ref T M24 => ref Row2.W; + + /// + public override string ToString() => + string.Format( + "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} }}", + Row1.X, Row1.Y, Row1.Z, Row1.W, + Row2.X, Row2.Y, Row2.Z, Row2.W); + /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix2X4 other && Equals(other); @@ -173,6 +181,22 @@ public Matrix4X2 Transpose() => new(-value.Row1, -value.Row2); + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix2X4 operator *(T left, Matrix2X4 right) => + new(left * right.Row1, + left * right.Row2); + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix2X4 operator *(Matrix2X4 left, T right) => + new(left.Row1 * right, + left.Row2 * right); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -197,6 +221,113 @@ public Matrix4X2 Transpose() => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X4(Matrix2X4 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X4(Matrix2X4 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X4(Matrix2X4 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X4(Matrix2X4 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X4(Matrix2X4 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X4(Matrix2X4 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X4(Matrix2X4 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X4(Matrix2X4 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X4(Matrix2X4 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X4(Matrix2X4 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X4(Matrix2X4 from) => + new(from.Row1.As(), + from.Row2.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix2X4(Matrix2X4 from) => + new(from.Row1.As(), + from.Row2.As()); } public static partial class Matrix2X4 diff --git a/sources/Maths/Maths/Matrix3X2.cs b/sources/Maths/Maths/Matrix3X2.cs index f1c69cd9a8..2ec8ed1612 100644 --- a/sources/Maths/Maths/Matrix3X2.cs +++ b/sources/Maths/Maths/Matrix3X2.cs @@ -81,15 +81,6 @@ public Matrix3X2(Matrix4X2 value) return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3; } - /// Scales all elements in a matrix by the given scalar factor. - /// The source matrix. - /// The scaling value to use. - /// The resulting matrix. - public static Matrix3X2 operator *(Matrix3X2 value1, T value2) - { - return new(value1.Row1 * value2, value1.Row2 * value2, value1.Row3 * value2); - } - /// Calculates the determinant for this matrix. /// The determinant is calculated by expanding the matrix with a third column whose values are (0,0,1). /// The determinant. @@ -114,40 +105,6 @@ public readonly T GetDeterminant() return Scalar.Subtract(Scalar.Multiply(M11, M22), Scalar.Multiply(M21, M12)); } - /// Returns a String representing this matrix instance. - /// The string representation. - public override readonly string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1}}} {{M21:{2} M22:{3}}} {{M31:{4} M32:{5}}} }}", - M11, M12, - M21, M22, - M31, M32); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X2(Matrix3X2 from) - => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X2(Matrix3X2 from) - => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) - ); - /// /// Converts a into a one. /// @@ -159,127 +116,7 @@ public static explicit operator System.Numerics.Matrix3x2(Matrix3X2 from) Scalar.As(from.M21), Scalar.As(from.M22), Scalar.As(from.M31), Scalar.As(from.M32) ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X2(Matrix3X2 from) - => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X2(Matrix3X2 from) - => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X2(Matrix3X2 from) - => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) - ); - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X2(Matrix3X2 from) - => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X2(Matrix3X2 from) - => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X2(Matrix3X2 from) - => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X2(Matrix3X2 from) - => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X2(Matrix3X2 from) - => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X2(Matrix3X2 from) - => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X2(Matrix3X2 from) - => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) - ); - /// /// Returns this matrix casted to /// diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index 1caf6ea066..2bb0ed9718 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -109,6 +109,15 @@ public ref Vector2D this[int row] [UnscopedRef] public ref T M32 => ref Row3.Y; + + /// + public override string ToString() => + string.Format( + "{{ {{M11:{0} M12:{1}}} {{M21:{2} M22:{3}}} {{M31:{4} M32:{5}}} }}", + Row1.X, Row1.Y, + Row2.X, Row2.Y, + Row3.X, Row3.Y); + /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix3X2 other && Equals(other); @@ -165,6 +174,24 @@ public Matrix2X3 Transpose() => -value.Row2, -value.Row3); + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix3X2 operator *(T left, Matrix3X2 right) => + new(left * right.Row1, + left * right.Row2, + left * right.Row3); + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix3X2 operator *(Matrix3X2 left, T right) => + new(left.Row1 * right, + left.Row2 * right, + left.Row3 * right); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -182,6 +209,125 @@ public Matrix2X3 Transpose() => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X2(Matrix3X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X2(Matrix3X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X2(Matrix3X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X2(Matrix3X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X2(Matrix3X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X2(Matrix3X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X2(Matrix3X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X2(Matrix3X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X2(Matrix3X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X2(Matrix3X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X2(Matrix3X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X2(Matrix3X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); } public static partial class Matrix3X2 diff --git a/sources/Maths/Maths/Matrix3X3.cs b/sources/Maths/Maths/Matrix3X3.cs index b5161c146d..69e0db0bd1 100644 --- a/sources/Maths/Maths/Matrix3X3.cs +++ b/sources/Maths/Maths/Matrix3X3.cs @@ -95,15 +95,6 @@ public readonly bool IsIdentity return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3; } - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static unsafe Matrix3X3 operator *(Matrix3X3 value1, T value2) - { - return new(value1.Row1 * value2, value1.Row2 * value2, value1.Row3 * value2); - } - /// Calculates the determinant of the matrix. /// The determinant of the matrix. public readonly T GetDeterminant() @@ -123,146 +114,6 @@ public readonly T GetDeterminant() Scalar.Multiply(c, Scalar.Subtract(Scalar.Multiply(d, h), Scalar.Multiply(e, g)))); } - /// Returns a String representing this matrix instance. - /// The string representation. - public override readonly string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1} M13:{2} }} {{M21:{3} M22:{4} M23:{5} }} {{M31:{6} M32:{7} M33:{8}}} }}", - M11, M12, M13, - M21, M22, M23, - M31, M32, M33); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X3(Matrix3X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), Scalar.As(from.M33)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X3(Matrix3X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X3(Matrix3X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), - Scalar.As(from.M22), Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X3(Matrix3X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), - Scalar.As(from.M22), Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X3(Matrix3X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X3(Matrix3X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), Scalar.As(from.M33)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X3(Matrix3X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), - Scalar.As(from.M22), Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X3(Matrix3X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X3(Matrix3X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), Scalar.As(from.M33)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X3(Matrix3X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), Scalar.As(from.M33)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X3(Matrix3X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X3(Matrix3X3 from) - => new(Scalar.As(from.M11), Scalar.As(from.M12), Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), Scalar.As(from.M33)); - /// /// Returns this matrix casted to /// diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index ad3c0b5b2a..0796c2baa5 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -134,6 +134,15 @@ public ref Vector3D this[int row] [UnscopedRef] public ref T M33 => ref Row3.Z; + + /// + public override string ToString() => + string.Format( + "{{ {{M11:{0} M12:{1} M13:{2}}} {{M21:{3} M22:{4} M23:{5}}} {{M31:{6} M32:{7} M33:{8}}} }}", + Row1.X, Row1.Y, Row1.Z, + Row2.X, Row2.Y, Row2.Z, + Row3.X, Row3.Y, Row3.Z); + /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix3X3 other && Equals(other); @@ -191,6 +200,24 @@ public Matrix3X3 Transpose() => -value.Row2, -value.Row3); + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix3X3 operator *(T left, Matrix3X3 right) => + new(left * right.Row1, + left * right.Row2, + left * right.Row3); + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix3X3 operator *(Matrix3X3 left, T right) => + new(left.Row1 * right, + left.Row2 * right, + left.Row3 * right); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -216,6 +243,125 @@ public Matrix3X3 Transpose() => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X3(Matrix3X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X3(Matrix3X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X3(Matrix3X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X3(Matrix3X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X3(Matrix3X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X3(Matrix3X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X3(Matrix3X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X3(Matrix3X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X3(Matrix3X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X3(Matrix3X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X3(Matrix3X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X3(Matrix3X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); } public static partial class Matrix3X3 diff --git a/sources/Maths/Maths/Matrix3X4.cs b/sources/Maths/Maths/Matrix3X4.cs index 966669f93b..b84ae7b298 100644 --- a/sources/Maths/Maths/Matrix3X4.cs +++ b/sources/Maths/Maths/Matrix3X4.cs @@ -98,217 +98,6 @@ public readonly bool IsIdentity return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3; } - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static unsafe Matrix3X4 operator *(Matrix3X4 value1, T value2) - { - return new(value1.Row1 * value2, value1.Row2 * value2, value1.Row3 * value2); - } - - /// Returns a String representing this matrix instance. - /// The string representation. - public override readonly string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} {{M31:{8} M32:{9} M33:{10} M34:{11}}} }}", - M11, M12, M13, M14, - M21, M22, M23, M24, - M31, M32, M33, M34); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X4(Matrix3X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X4(Matrix3X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X4(Matrix3X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X4(Matrix3X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X4(Matrix3X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X4(Matrix3X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X4(Matrix3X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X4(Matrix3X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X4(Matrix3X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X4(Matrix3X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X4(Matrix3X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix3X4(Matrix3X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34) - ); - /// /// Returns this matrix casted to /// diff --git a/sources/Maths/Maths/Matrix3X4.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs index fa2463be59..e662cce318 100644 --- a/sources/Maths/Maths/Matrix3X4.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -147,6 +147,15 @@ public ref Vector4D this[int row] [UnscopedRef] public ref T M34 => ref Row3.W; + + /// + public override string ToString() => + string.Format( + "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} {{M31:{8} M32:{9} M33:{10} M34:{11}}} }}", + Row1.X, Row1.Y, Row1.Z, Row1.W, + Row2.X, Row2.Y, Row2.Z, Row2.W, + Row3.X, Row3.Y, Row3.Z, Row3.W); + /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix3X4 other && Equals(other); @@ -205,6 +214,24 @@ public Matrix4X3 Transpose() => -value.Row2, -value.Row3); + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix3X4 operator *(T left, Matrix3X4 right) => + new(left * right.Row1, + left * right.Row2, + left * right.Row3); + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix3X4 operator *(Matrix3X4 left, T right) => + new(left.Row1 * right, + left.Row2 * right, + left.Row3 * right); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -239,6 +266,125 @@ public Matrix4X3 Transpose() => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X4(Matrix3X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X4(Matrix3X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X4(Matrix3X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X4(Matrix3X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X4(Matrix3X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X4(Matrix3X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X4(Matrix3X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X4(Matrix3X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X4(Matrix3X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X4(Matrix3X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X4(Matrix3X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix3X4(Matrix3X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As()); } public static partial class Matrix3X4 diff --git a/sources/Maths/Maths/Matrix4X2.cs b/sources/Maths/Maths/Matrix4X2.cs index 3893815a5d..606ca14133 100644 --- a/sources/Maths/Maths/Matrix4X2.cs +++ b/sources/Maths/Maths/Matrix4X2.cs @@ -94,194 +94,6 @@ public readonly bool IsIdentity return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3 + value1.W * value2.Row4; } - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static unsafe Matrix4X2 operator *(Matrix4X2 value1, T value2) - { - return new(value1.Row1 * value2, value1.Row2 * value2, value1.Row3 * value2, value1.Row4 * value2); - } - - /// Returns a String representing this matrix instance. - /// The string representation. - public override readonly string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1}}} {{M21:{2} M22:{3}}} {{M31:{4} M32:{5}}} {{M41:{6} M42:{7}}} }}", - M11, M12, - M21, M22, - M31, M32, - M41, M42); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X2(Matrix4X2 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M41), Scalar.As(from.M42) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X2(Matrix4X2 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M41), Scalar.As(from.M42) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X2(Matrix4X2 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M41), Scalar.As(from.M42) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X2(Matrix4X2 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M41), Scalar.As(from.M42) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X2(Matrix4X2 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M41), Scalar.As(from.M42) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X2(Matrix4X2 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M41), Scalar.As(from.M42) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X2(Matrix4X2 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M41), Scalar.As(from.M42) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X2(Matrix4X2 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M41), Scalar.As(from.M42) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X2(Matrix4X2 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M41), Scalar.As(from.M42) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X2(Matrix4X2 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M41), Scalar.As(from.M42) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X2(Matrix4X2 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M41), Scalar.As(from.M42) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X2(Matrix4X2 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M41), Scalar.As(from.M42) - ); - /// /// Returns this matrix casted to /// diff --git a/sources/Maths/Maths/Matrix4X2.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs index 8bd1df9859..e5f3a6cff8 100644 --- a/sources/Maths/Maths/Matrix4X2.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -127,6 +127,16 @@ public ref Vector2D this[int row] [UnscopedRef] public ref T M42 => ref Row4.Y; + + /// + public override string ToString() => + string.Format( + "{{ {{M11:{0} M12:{1}}} {{M21:{2} M22:{3}}} {{M31:{4} M32:{5}}} {{M41:{6} M42:{7}}} }}", + Row1.X, Row1.Y, + Row2.X, Row2.Y, + Row3.X, Row3.Y, + Row4.X, Row4.Y); + /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix4X2 other && Equals(other); @@ -187,6 +197,26 @@ public Matrix2X4 Transpose() => -value.Row3, -value.Row4); + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix4X2 operator *(T left, Matrix4X2 right) => + new(left * right.Row1, + left * right.Row2, + left * right.Row3, + left * right.Row4); + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix4X2 operator *(Matrix4X2 left, T right) => + new(left.Row1 * right, + left.Row2 * right, + left.Row3 * right, + left.Row4 * right); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -216,6 +246,137 @@ public Matrix2X4 Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X2(Matrix4X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X2(Matrix4X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X2(Matrix4X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X2(Matrix4X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X2(Matrix4X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X2(Matrix4X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X2(Matrix4X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X2(Matrix4X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X2(Matrix4X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X2(Matrix4X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X2(Matrix4X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X2(Matrix4X2 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); } public static partial class Matrix4X2 diff --git a/sources/Maths/Maths/Matrix4X3.cs b/sources/Maths/Maths/Matrix4X3.cs index 3cfd7e313a..7e69e7d550 100644 --- a/sources/Maths/Maths/Matrix4X3.cs +++ b/sources/Maths/Maths/Matrix4X3.cs @@ -117,242 +117,6 @@ public readonly bool IsIdentity return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3 + value1.W * value2.Row4; } - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static unsafe Matrix4X3 operator *(Matrix4X3 value1, T value2) - { - return new(value1.Row1 * value2, value1.Row2 * value2, value1.Row3 * value2, value1.Row4 * value2); - } - - /// Returns a String representing this matrix instance. - /// The string representation. - public override readonly string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1} M13:{2}}} {{M21:{3} M22:{4} M23:{5}}} {{M31:{6} M32:{7} M33:{8}}} {{M41:{9} M42:{10} M43:{11}}} }}", - M11, M12, M13, - M21, M22, M23, - M31, M32, M33, - M41, M42, M43); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X3(Matrix4X3 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X3(Matrix4X3 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X3(Matrix4X3 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X3(Matrix4X3 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X3(Matrix4X3 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X3(Matrix4X3 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X3(Matrix4X3 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X3(Matrix4X3 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X3(Matrix4X3 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X3(Matrix4X3 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X3(Matrix4X3 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X3(Matrix4X3 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43) - ); - /// /// Returns this matrix casted to /// diff --git a/sources/Maths/Maths/Matrix4X3.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs index 7fcb883410..b21822d0f2 100644 --- a/sources/Maths/Maths/Matrix4X3.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -151,6 +151,16 @@ public ref Vector3D this[int row] [UnscopedRef] public ref T M43 => ref Row4.Z; + + /// + public override string ToString() => + string.Format( + "{{ {{M11:{0} M12:{1} M13:{2}}} {{M21:{3} M22:{4} M23:{5}}} {{M31:{6} M32:{7} M33:{8}}} {{M41:{9} M42:{10} M43:{11}}} }}", + Row1.X, Row1.Y, Row1.Z, + Row2.X, Row2.Y, Row2.Z, + Row3.X, Row3.Y, Row3.Z, + Row4.X, Row4.Y, Row4.Z); + /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix4X3 other && Equals(other); @@ -212,6 +222,26 @@ public Matrix3X4 Transpose() => -value.Row3, -value.Row4); + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix4X3 operator *(T left, Matrix4X3 right) => + new(left * right.Row1, + left * right.Row2, + left * right.Row3, + left * right.Row4); + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix4X3 operator *(Matrix4X3 left, T right) => + new(left.Row1 * right, + left.Row2 * right, + left.Row3 * right, + left.Row4 * right); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -249,6 +279,137 @@ public Matrix3X4 Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X3(Matrix4X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X3(Matrix4X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X3(Matrix4X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X3(Matrix4X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X3(Matrix4X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X3(Matrix4X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X3(Matrix4X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X3(Matrix4X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X3(Matrix4X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X3(Matrix4X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X3(Matrix4X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X3(Matrix4X3 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); } public static partial class Matrix4X3 diff --git a/sources/Maths/Maths/Matrix4X4.cs b/sources/Maths/Maths/Matrix4X4.cs index 700a86cdb5..2a5149bd5b 100644 --- a/sources/Maths/Maths/Matrix4X4.cs +++ b/sources/Maths/Maths/Matrix4X4.cs @@ -97,20 +97,6 @@ public readonly bool IsIdentity value1.W * value2.Row4; } - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static unsafe Matrix4X4 operator *(Matrix4X4 value1, T value2) - { - return new( - value1.Row1 * value2, - value1.Row2 * value2, - value1.Row3 * value2, - value1.Row4 * value2 - ); - } - /// Calculates the determinant of the matrix. /// The determinant of the matrix. public readonly T GetDeterminant() @@ -175,233 +161,6 @@ public readonly T GetDeterminant() Scalar.Multiply(g, in_jm))))); } - /// Returns a String representing this matrix instance. - /// The string representation. - public override readonly string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} {{M31:{8} M32:{9} M33:{10} M34:{11}}} {{M41:{12} M42:{13} M43:{14} M44:{15}}} }}", - M11, M12, M13, M14, - M21, M22, M23, M24, - M31, M32, M33, M34, - M41, M42, M43, M44); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X4(Matrix4X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X4(Matrix4X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X4(Matrix4X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X4(Matrix4X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X4(Matrix4X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X4(Matrix4X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X4(Matrix4X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X4(Matrix4X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X4(Matrix4X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X4(Matrix4X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X4(Matrix4X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix4X4(Matrix4X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44) - ); - /// /// Returns this matrix casted to /// diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index 7fe91550bb..c93d2d3804 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -182,6 +182,16 @@ public ref Vector4D this[int row] [UnscopedRef] public ref T M44 => ref Row4.W; + + /// + public override string ToString() => + string.Format( + "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} {{M31:{8} M32:{9} M33:{10} M34:{11}}} {{M41:{12} M42:{13} M43:{14} M44:{15}}} }}", + Row1.X, Row1.Y, Row1.Z, Row1.W, + Row2.X, Row2.Y, Row2.Z, Row2.W, + Row3.X, Row3.Y, Row3.Z, Row3.W, + Row4.X, Row4.Y, Row4.Z, Row4.W); + /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix4X4 other && Equals(other); @@ -244,6 +254,26 @@ public Matrix4X4 Transpose() => -value.Row3, -value.Row4); + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix4X4 operator *(T left, Matrix4X4 right) => + new(left * right.Row1, + left * right.Row2, + left * right.Row3, + left * right.Row4); + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix4X4 operator *(Matrix4X4 left, T right) => + new(left.Row1 * right, + left.Row2 * right, + left.Row3 * right, + left.Row4 * right); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -290,6 +320,137 @@ public Matrix4X4 Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X4(Matrix4X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X4(Matrix4X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X4(Matrix4X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X4(Matrix4X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X4(Matrix4X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X4(Matrix4X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X4(Matrix4X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X4(Matrix4X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X4(Matrix4X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X4(Matrix4X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X4(Matrix4X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix4X4(Matrix4X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As()); } public static partial class Matrix4X4 diff --git a/sources/Maths/Maths/Matrix5X4.cs b/sources/Maths/Maths/Matrix5X4.cs index b9c85c3f89..8f624e5b99 100644 --- a/sources/Maths/Maths/Matrix5X4.cs +++ b/sources/Maths/Maths/Matrix5X4.cs @@ -128,273 +128,6 @@ public readonly bool IsIdentity value1.W * value2.Row4 + value2.Row5; } - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static unsafe Matrix5X4 operator *(Matrix5X4 value1, T value2) - { - return new( - value1.Row1 * value2, - value1.Row2 * value2, - value1.Row3 * value2, - value1.Row4 * value2, - value1.Row5 * value2 - ); - } - - /// Returns a String representing this matrix instance. - /// The string representation. - public override readonly string ToString() - { - return string.Format(CultureInfo.CurrentCulture, "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} {{M31:{8} M32:{9} M33:{10} M34:{11}}} {{M41:{12} M42:{13} M43:{14} M44:{15}}} {{M51:{16} M52:{17} M53:{18} M54:{19}}} }}", - M11, M12, M13, M14, - M21, M22, M23, M24, - M31, M32, M33, M34, - M41, M42, M43, M44, - M51, M52, M53, M54); - } - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix5X4(Matrix5X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44), - Scalar.As(from.M51), Scalar.As(from.M52), - Scalar.As(from.M53), Scalar.As(from.M54) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix5X4(Matrix5X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44), - Scalar.As(from.M51), Scalar.As(from.M52), - Scalar.As(from.M53), Scalar.As(from.M54) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix5X4(Matrix5X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44), - Scalar.As(from.M51), Scalar.As(from.M52), - Scalar.As(from.M53), Scalar.As(from.M54) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix5X4(Matrix5X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44), - Scalar.As(from.M51), Scalar.As(from.M52), - Scalar.As(from.M53), Scalar.As(from.M54) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix5X4(Matrix5X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44), - Scalar.As(from.M51), Scalar.As(from.M52), - Scalar.As(from.M53), Scalar.As(from.M54) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix5X4(Matrix5X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44), - Scalar.As(from.M51), Scalar.As(from.M52), - Scalar.As(from.M53), Scalar.As(from.M54) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix5X4(Matrix5X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44), - Scalar.As(from.M51), Scalar.As(from.M52), - Scalar.As(from.M53), Scalar.As(from.M54) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix5X4(Matrix5X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44), - Scalar.As(from.M51), Scalar.As(from.M52), - Scalar.As(from.M53), Scalar.As(from.M54) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix5X4(Matrix5X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44), - Scalar.As(from.M51), Scalar.As(from.M52), - Scalar.As(from.M53), Scalar.As(from.M54) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix5X4(Matrix5X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44), - Scalar.As(from.M51), Scalar.As(from.M52), - Scalar.As(from.M53), Scalar.As(from.M54) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix5X4(Matrix5X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44), - Scalar.As(from.M51), Scalar.As(from.M52), - Scalar.As(from.M53), Scalar.As(from.M54) - ); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Matrix5X4(Matrix5X4 from) - => new - ( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M13), Scalar.As(from.M14), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M23), Scalar.As(from.M24), - Scalar.As(from.M31), Scalar.As(from.M32), - Scalar.As(from.M33), Scalar.As(from.M34), - Scalar.As(from.M41), Scalar.As(from.M42), - Scalar.As(from.M43), Scalar.As(from.M44), - Scalar.As(from.M51), Scalar.As(from.M52), - Scalar.As(from.M53), Scalar.As(from.M54) - ); - /// /// Returns this matrix casted to /// diff --git a/sources/Maths/Maths/Matrix5X4.gen.cs b/sources/Maths/Maths/Matrix5X4.gen.cs index c4da23f556..def96a81ab 100644 --- a/sources/Maths/Maths/Matrix5X4.gen.cs +++ b/sources/Maths/Maths/Matrix5X4.gen.cs @@ -187,6 +187,17 @@ public ref Vector4D this[int row] [UnscopedRef] public ref T M54 => ref Row5.W; + + /// + public override string ToString() => + string.Format( + "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} {{M31:{8} M32:{9} M33:{10} M34:{11}}} {{M41:{12} M42:{13} M43:{14} M44:{15}}} {{M51:{16} M52:{17} M53:{18} M54:{19}}} }}", + Row1.X, Row1.Y, Row1.Z, Row1.W, + Row2.X, Row2.Y, Row2.Z, Row2.W, + Row3.X, Row3.Y, Row3.Z, Row3.W, + Row4.X, Row4.Y, Row4.Z, Row4.W, + Row5.X, Row5.Y, Row5.Z, Row5.W); + /// [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix5X4 other && Equals(other); @@ -246,6 +257,28 @@ public ref Vector4D this[int row] -value.Row4, -value.Row5); + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix5X4 operator *(T left, Matrix5X4 right) => + new(left * right.Row1, + left * right.Row2, + left * right.Row3, + left * right.Row4, + left * right.Row5); + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix5X4 operator *(Matrix5X4 left, T right) => + new(left.Row1 * right, + left.Row2 * right, + left.Row3 * right, + left.Row4 * right, + left.Row5 * right); + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -256,6 +289,149 @@ public ref Vector4D this[int row] left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix5X4(Matrix5X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As(), + from.Row5.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix5X4(Matrix5X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As(), + from.Row5.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix5X4(Matrix5X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As(), + from.Row5.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix5X4(Matrix5X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As(), + from.Row5.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix5X4(Matrix5X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As(), + from.Row5.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix5X4(Matrix5X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As(), + from.Row5.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix5X4(Matrix5X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As(), + from.Row5.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix5X4(Matrix5X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As(), + from.Row5.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix5X4(Matrix5X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As(), + from.Row5.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix5X4(Matrix5X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As(), + from.Row5.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix5X4(Matrix5X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As(), + from.Row5.As()); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix + /// The matrix + public static explicit operator Matrix5X4(Matrix5X4 from) => + new(from.Row1.As(), + from.Row2.As(), + from.Row3.As(), + from.Row4.As(), + from.Row5.As()); } public static partial class Matrix5X4 From 80fbbfc378d539179bf19605cadff43ff08571b2 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 13:24:42 -0700 Subject: [PATCH 40/67] Types that need Min/Max (e.g. Box) use INumber instead of INumberBase. INumber implies a total order opposed to INumberBase which supports e.g. Complex numbers. --- sources/Maths/Maths/Box2D.cs | 7 ++++--- sources/Maths/Maths/Box3D.cs | 5 +++-- sources/Maths/Maths/Cube.cs | 5 +++-- sources/Maths/Maths/Rectangle.Ops.cs | 2 +- sources/Maths/Maths/Rectangle.cs | 5 +++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/sources/Maths/Maths/Box2D.cs b/sources/Maths/Maths/Box2D.cs index a5536faf6e..f038fd5fd5 100644 --- a/sources/Maths/Maths/Box2D.cs +++ b/sources/Maths/Maths/Box2D.cs @@ -15,7 +15,7 @@ namespace Silk.NET.Maths [DataContract] public struct Box2D : IEquatable> - where T : INumberBase + where T : INumber { /// /// The min. @@ -149,7 +149,7 @@ public Box2D GetScaled(Vector2D scale, Vector2D anchor) /// The type of the scale. /// The calculated box. public Box2D GetScaled(Vector2D scale, Vector2D anchor) - where TScale : INumberBase + where TScale : INumber { return this.As().GetScaled(scale, anchor.As()).As(); } @@ -210,7 +210,8 @@ public override int GetHashCode() /// /// The type to cast to /// The casted box - public Box2D As() where TOther : INumberBase + public Box2D As() + where TOther : INumber { return new(Min.As(), Max.As()); } diff --git a/sources/Maths/Maths/Box3D.cs b/sources/Maths/Maths/Box3D.cs index f32a0afd1f..040c2b0256 100644 --- a/sources/Maths/Maths/Box3D.cs +++ b/sources/Maths/Maths/Box3D.cs @@ -15,7 +15,7 @@ namespace Silk.NET.Maths [DataContract] public struct Box3D : IEquatable> - where T : INumberBase + where T : INumber { /// /// The min. @@ -222,7 +222,8 @@ public override int GetHashCode() /// /// The type to cast to /// The casted box - public Box3D As() where TOther : INumberBase + public Box3D As() + where TOther : INumber { return new(Min.As(), Max.As()); } diff --git a/sources/Maths/Maths/Cube.cs b/sources/Maths/Maths/Cube.cs index b0a2e2a3c2..90bc620d49 100644 --- a/sources/Maths/Maths/Cube.cs +++ b/sources/Maths/Maths/Cube.cs @@ -15,7 +15,7 @@ namespace Silk.NET.Maths [DataContract] public struct Cube : IEquatable> - where T : INumberBase + where T : INumber { /// /// The origin. @@ -236,7 +236,8 @@ public override int GetHashCode() /// /// The type to cast to /// The casted cube - public Cube As() where TOther : INumberBase + public Cube As() + where TOther : INumber { return new(Origin.As(), Max.As()); } diff --git a/sources/Maths/Maths/Rectangle.Ops.cs b/sources/Maths/Maths/Rectangle.Ops.cs index 7dd2d6e9a0..cb1175a1a8 100644 --- a/sources/Maths/Maths/Rectangle.Ops.cs +++ b/sources/Maths/Maths/Rectangle.Ops.cs @@ -21,7 +21,7 @@ public static class Rectangle /// The type. /// The constructed rectangle. public static Rectangle FromLTRB(T left, T top, T right, T bottom) - where T : INumberBase + where T : INumber { Vector2D o = new(left, top); return new Rectangle(o, new Vector2D(right, bottom) - o); diff --git a/sources/Maths/Maths/Rectangle.cs b/sources/Maths/Maths/Rectangle.cs index c00d48993d..db90d7032b 100644 --- a/sources/Maths/Maths/Rectangle.cs +++ b/sources/Maths/Maths/Rectangle.cs @@ -14,7 +14,7 @@ namespace Silk.NET.Maths [DataContract] public struct Rectangle : IEquatable> - where T : INumberBase + where T : INumber { /// /// The origin. @@ -228,7 +228,8 @@ public override int GetHashCode() /// /// The type to cast to /// The casted rectangle - public Rectangle As() where TOther : INumberBase + public Rectangle As() + where TOther : INumber { return new(Origin.As(), Size.As()); } From 2a79fd860ebba7e5c8bf5db55e11360c899d9e43 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 13:25:13 -0700 Subject: [PATCH 41/67] Added explicit casts for vectors. --- sources/Maths/Maths/Matrix2X2.gen.cs | 48 +++++++------- sources/Maths/Maths/Matrix2X3.gen.cs | 48 +++++++------- sources/Maths/Maths/Matrix2X4.gen.cs | 48 +++++++------- sources/Maths/Maths/Matrix3X2.gen.cs | 48 +++++++------- sources/Maths/Maths/Matrix3X3.gen.cs | 48 +++++++------- sources/Maths/Maths/Matrix3X4.gen.cs | 48 +++++++------- sources/Maths/Maths/Matrix4X2.gen.cs | 48 +++++++------- sources/Maths/Maths/Matrix4X3.gen.cs | 48 +++++++------- sources/Maths/Maths/Matrix4X4.gen.cs | 48 +++++++------- sources/Maths/Maths/Matrix5X4.gen.cs | 48 +++++++------- sources/Maths/Maths/Vector2D.gen.cs | 96 ++++++++++++++++++++++++++++ sources/Maths/Maths/Vector3D.gen.cs | 96 ++++++++++++++++++++++++++++ sources/Maths/Maths/Vector4D.gen.cs | 96 ++++++++++++++++++++++++++++ 13 files changed, 528 insertions(+), 240 deletions(-) diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index 8d49a1fdba..d1490acf18 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -182,8 +182,8 @@ public Matrix2X2 Transpose() => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => new(from.Row1.As(), from.Row2.As()); @@ -191,8 +191,8 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => new(from.Row1.As(), from.Row2.As()); @@ -200,8 +200,8 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => new(from.Row1.As(), from.Row2.As()); @@ -209,8 +209,8 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => new(from.Row1.As(), from.Row2.As()); @@ -218,8 +218,8 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => new(from.Row1.As(), from.Row2.As()); @@ -227,8 +227,8 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => new(from.Row1.As(), from.Row2.As()); @@ -236,8 +236,8 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => new(from.Row1.As(), from.Row2.As()); @@ -245,8 +245,8 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => new(from.Row1.As(), from.Row2.As()); @@ -254,8 +254,8 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => new(from.Row1.As(), from.Row2.As()); @@ -263,8 +263,8 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => new(from.Row1.As(), from.Row2.As()); @@ -272,8 +272,8 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => new(from.Row1.As(), from.Row2.As()); @@ -281,8 +281,8 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => new(from.Row1.As(), from.Row2.As()); diff --git a/sources/Maths/Maths/Matrix2X3.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs index d8d87fd30b..07f9ec51b9 100644 --- a/sources/Maths/Maths/Matrix2X3.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -200,8 +200,8 @@ public Matrix3X2 Transpose() => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => new(from.Row1.As(), from.Row2.As()); @@ -209,8 +209,8 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => new(from.Row1.As(), from.Row2.As()); @@ -218,8 +218,8 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => new(from.Row1.As(), from.Row2.As()); @@ -227,8 +227,8 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => new(from.Row1.As(), from.Row2.As()); @@ -236,8 +236,8 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => new(from.Row1.As(), from.Row2.As()); @@ -245,8 +245,8 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => new(from.Row1.As(), from.Row2.As()); @@ -254,8 +254,8 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => new(from.Row1.As(), from.Row2.As()); @@ -263,8 +263,8 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => new(from.Row1.As(), from.Row2.As()); @@ -272,8 +272,8 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => new(from.Row1.As(), from.Row2.As()); @@ -281,8 +281,8 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => new(from.Row1.As(), from.Row2.As()); @@ -290,8 +290,8 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => new(from.Row1.As(), from.Row2.As()); @@ -299,8 +299,8 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => new(from.Row1.As(), from.Row2.As()); diff --git a/sources/Maths/Maths/Matrix2X4.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs index 35573895a3..ee07f8dfee 100644 --- a/sources/Maths/Maths/Matrix2X4.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -224,8 +224,8 @@ public Matrix4X2 Transpose() => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => new(from.Row1.As(), from.Row2.As()); @@ -233,8 +233,8 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => new(from.Row1.As(), from.Row2.As()); @@ -242,8 +242,8 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => new(from.Row1.As(), from.Row2.As()); @@ -251,8 +251,8 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => new(from.Row1.As(), from.Row2.As()); @@ -260,8 +260,8 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => new(from.Row1.As(), from.Row2.As()); @@ -269,8 +269,8 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => new(from.Row1.As(), from.Row2.As()); @@ -278,8 +278,8 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => new(from.Row1.As(), from.Row2.As()); @@ -287,8 +287,8 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => new(from.Row1.As(), from.Row2.As()); @@ -296,8 +296,8 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => new(from.Row1.As(), from.Row2.As()); @@ -305,8 +305,8 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => new(from.Row1.As(), from.Row2.As()); @@ -314,8 +314,8 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => new(from.Row1.As(), from.Row2.As()); @@ -323,8 +323,8 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => new(from.Row1.As(), from.Row2.As()); diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index 2bb0ed9718..3c03e4b538 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -212,8 +212,8 @@ public Matrix2X3 Transpose() => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -222,8 +222,8 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -232,8 +232,8 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -242,8 +242,8 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -252,8 +252,8 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -262,8 +262,8 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -272,8 +272,8 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -282,8 +282,8 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -292,8 +292,8 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -302,8 +302,8 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -312,8 +312,8 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -322,8 +322,8 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => new(from.Row1.As(), from.Row2.As(), diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index 0796c2baa5..6466c089d6 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -246,8 +246,8 @@ public Matrix3X3 Transpose() => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -256,8 +256,8 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -266,8 +266,8 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -276,8 +276,8 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -286,8 +286,8 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -296,8 +296,8 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -306,8 +306,8 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -316,8 +316,8 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -326,8 +326,8 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -336,8 +336,8 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -346,8 +346,8 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -356,8 +356,8 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => new(from.Row1.As(), from.Row2.As(), diff --git a/sources/Maths/Maths/Matrix3X4.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs index e662cce318..ce53d29ad9 100644 --- a/sources/Maths/Maths/Matrix3X4.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -269,8 +269,8 @@ public Matrix4X3 Transpose() => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -279,8 +279,8 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -289,8 +289,8 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -299,8 +299,8 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -309,8 +309,8 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -319,8 +319,8 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -329,8 +329,8 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -339,8 +339,8 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -349,8 +349,8 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -359,8 +359,8 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -369,8 +369,8 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -379,8 +379,8 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => new(from.Row1.As(), from.Row2.As(), diff --git a/sources/Maths/Maths/Matrix4X2.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs index e5f3a6cff8..0cda66d434 100644 --- a/sources/Maths/Maths/Matrix4X2.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -249,8 +249,8 @@ public Matrix2X4 Transpose() => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -260,8 +260,8 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -271,8 +271,8 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -282,8 +282,8 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -293,8 +293,8 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -304,8 +304,8 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -315,8 +315,8 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -326,8 +326,8 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -337,8 +337,8 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -348,8 +348,8 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -359,8 +359,8 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => new(from.Row1.As(), from.Row2.As(), @@ -370,8 +370,8 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => new(from.Row1.As(), from.Row2.As(), diff --git a/sources/Maths/Maths/Matrix4X3.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs index b21822d0f2..f5d3add102 100644 --- a/sources/Maths/Maths/Matrix4X3.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -282,8 +282,8 @@ public Matrix3X4 Transpose() => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -293,8 +293,8 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -304,8 +304,8 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -315,8 +315,8 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -326,8 +326,8 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -337,8 +337,8 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -348,8 +348,8 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -359,8 +359,8 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -370,8 +370,8 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -381,8 +381,8 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -392,8 +392,8 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => new(from.Row1.As(), from.Row2.As(), @@ -403,8 +403,8 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => new(from.Row1.As(), from.Row2.As(), diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index c93d2d3804..c77c210af0 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -323,8 +323,8 @@ public Matrix4X4 Transpose() => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -334,8 +334,8 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -345,8 +345,8 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -356,8 +356,8 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -367,8 +367,8 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -378,8 +378,8 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -389,8 +389,8 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -400,8 +400,8 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -411,8 +411,8 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -422,8 +422,8 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -433,8 +433,8 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -444,8 +444,8 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => new(from.Row1.As(), from.Row2.As(), diff --git a/sources/Maths/Maths/Matrix5X4.gen.cs b/sources/Maths/Maths/Matrix5X4.gen.cs index def96a81ab..91ae1f4986 100644 --- a/sources/Maths/Maths/Matrix5X4.gen.cs +++ b/sources/Maths/Maths/Matrix5X4.gen.cs @@ -292,8 +292,8 @@ public override string ToString() => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -304,8 +304,8 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -316,8 +316,8 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -328,8 +328,8 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -340,8 +340,8 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -352,8 +352,8 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -364,8 +364,8 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -376,8 +376,8 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -388,8 +388,8 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -400,8 +400,8 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -412,8 +412,8 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => new(from.Row1.As(), from.Row2.As(), @@ -424,8 +424,8 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// /// Converts a matrix of into one with an underlying type of . /// - /// The source matrix - /// The matrix + /// The source matrix. + /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => new(from.Row1.As(), from.Row2.As(), diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index d62934f8fb..0b09be2ea6 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -356,6 +356,102 @@ public static implicit operator (T X, T Y)(Vector2D v) => public static Vector2D operator /(Vector2D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector2D(Vector2D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector2D(Vector2D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector2D(Vector2D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector2D(Vector2D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector2D(Vector2D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector2D(Vector2D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector2D(Vector2D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector2D(Vector2D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector2D(Vector2D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector2D(Vector2D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector2D(Vector2D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector2D(Vector2D from) => + from.As(); } public static partial class Vector2D diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index f65b1522b7..ac758bac66 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -395,6 +395,102 @@ public static implicit operator (T X, T Y, T Z)(Vector3D v) => public static Vector3D operator /(Vector3D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector3D(Vector3D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector3D(Vector3D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector3D(Vector3D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector3D(Vector3D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector3D(Vector3D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector3D(Vector3D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector3D(Vector3D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector3D(Vector3D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector3D(Vector3D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector3D(Vector3D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector3D(Vector3D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector3D(Vector3D from) => + from.As(); } public static partial class Vector3D diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index 1055a4c936..210e3a98b4 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -434,6 +434,102 @@ public static implicit operator (T X, T Y, T Z, T W)(Vector4D v) => public static Vector4D operator /(Vector4D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector4D(Vector4D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector4D(Vector4D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector4D(Vector4D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector4D(Vector4D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector4D(Vector4D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector4D(Vector4D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector4D(Vector4D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector4D(Vector4D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector4D(Vector4D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector4D(Vector4D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector4D(Vector4D from) => + from.As(); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator Vector4D(Vector4D from) => + from.As(); } public static partial class Vector4D From 5e0e7d9cd9a88f316971d3b85ed9bb4d48a924f2 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 14:55:53 -0700 Subject: [PATCH 42/67] Use extension properties for LengthSquared and Length. Use these for Normalize. Add DistanceSquared and Distance. --- sources/Maths/Maths/Silk.NET.Maths.csproj | 1 + sources/Maths/Maths/Vector2D.cs | 37 ++++++------------- sources/Maths/Maths/Vector2D.gen.cs | 44 ++++++++++++++++++----- sources/Maths/Maths/Vector3D.cs | 29 ++++++--------- sources/Maths/Maths/Vector3D.gen.cs | 44 ++++++++++++++++++----- sources/Maths/Maths/Vector4D.cs | 2 -- sources/Maths/Maths/Vector4D.gen.cs | 44 ++++++++++++++++++----- 7 files changed, 127 insertions(+), 74 deletions(-) diff --git a/sources/Maths/Maths/Silk.NET.Maths.csproj b/sources/Maths/Maths/Silk.NET.Maths.csproj index dbfdad1475..c4a41cabc6 100644 --- a/sources/Maths/Maths/Silk.NET.Maths.csproj +++ b/sources/Maths/Maths/Silk.NET.Maths.csproj @@ -2,6 +2,7 @@ net8.0 + preview enable true true diff --git a/sources/Maths/Maths/Vector2D.cs b/sources/Maths/Maths/Vector2D.cs index dd577a241c..2f8e1cd237 100644 --- a/sources/Maths/Maths/Vector2D.cs +++ b/sources/Maths/Maths/Vector2D.cs @@ -14,12 +14,6 @@ namespace Silk.NET.Maths /// A structure representing a 2D integer vector. public partial struct Vector2D { - /// Computes the cross product of this vector with another vector. - public T Cross(Vector2D other) => (X * other.Y) - (Y * other.X); - - /// Computes the cross product of two vectors. - public static T Cross(Vector2D left, Vector2D right) => (left.X * right.Y) - (left.Y * right.X); - // Casts /// Explicitly casts a to a . @@ -47,32 +41,21 @@ public static Vector2D LerpClamped(Vector2D a, Vector2D b, Vector2D a.X + (b.X - a.X) * T.Clamp(t.X, T.Zero, T.One), a.Y + (b.Y - a.Y) * T.Clamp(t.Y, T.Zero, T.One) ); - - // IFloatingPointIeee754 - - public static (Vector2D Sin, Vector2D Cos) SinCos(Vector2D x) => - (new(T.Sin(x.X), T.Sin(x.Y)), new(T.Cos(x.X), T.Cos(x.Y))); - - public static (Vector2D SinPi, Vector2D CosPi) SinCosPi(Vector2D x) => - (new(T.SinPi(x.X), T.SinPi(x.Y)), new(T.CosPi(x.X), T.CosPi(x.Y))); - - public static Vector2D FusedMultiplyAdd(Vector2D left, Vector2D right, Vector2D addend) => - new(T.FusedMultiplyAdd(left.X, right.X, addend.X), T.FusedMultiplyAdd(left.Y, right.Y, addend.Y)); - - public static Vector2D FusedMultiplyAdd(Vector2D left, Vector2D right, T addend) => - new(T.FusedMultiplyAdd(left.X, right.X, addend), T.FusedMultiplyAdd(left.Y, right.Y, addend)); - - public static Vector2D FusedMultiplyAdd(Vector2D left, T right, Vector2D addend) => - new(T.FusedMultiplyAdd(left.X, right, addend.X), T.FusedMultiplyAdd(left.Y, right, addend.Y)); - - public static Vector2D FusedMultiplyAdd(Vector2D left, T right, T addend) => - new(T.FusedMultiplyAdd(left.X, right, addend), T.FusedMultiplyAdd(left.Y, right, addend)); } public static partial class Vector2D { /// Computes the cross product of two vectors. public static T Cross(this Vector2D left, Vector2D right) - where T : IFloatingPointIeee754 => (left.X * right.Y) - (left.Y * right.X); + where T : INumberBase => + (left.X * right.Y) - (left.Y * right.X); + + public static (Vector2D Sin, Vector2D Cos) SinCos(this Vector2D x) + where T : INumberBase => + (new(T.Sin(x.X), T.Sin(x.Y)), new(T.Cos(x.X), T.Cos(x.Y))); + + public static (Vector2D SinPi, Vector2D CosPi) SinCosPi(this Vector2D x) + where T : INumberBase => + (new(T.SinPi(x.X), T.SinPi(x.Y)), new(T.CosPi(x.X), T.CosPi(x.Y))); } } diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index 0b09be2ea6..fb65471a0b 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -51,8 +51,6 @@ public Vector2D(ReadOnlySpan values) /// Gets the vector (0, 1). public static Vector2D UnitY => new(T.Zero, T.One); - /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => Vector2D.Dot(this, this); /// T IReadOnlyList.this[int index] => this[index]; @@ -456,6 +454,20 @@ public static explicit operator Vector2D(Vector2D from) => public static partial class Vector2D { + extension(Vector2D vector) + where T : IRootFunctions + { + /// Gets the length of the vector. + public T Length => T.Sqrt(vector.LengthSquared); + } + + extension(Vector2D vector) + where T : INumberBase + { + /// Gets the length squared of the vector. + public T LengthSquared => Vector2D.Dot(vector, vector); + } + /// Computes the dot product of two vectors. public static T Dot(this Vector2D left, Vector2D right) where T : INumberBase => @@ -469,19 +481,33 @@ public static Vector2D Reflect(Vector2D vector, Vector2D normal) return vector - (normal * (dot + dot)); } - /// Computes the length of the vector. - public static T GetLength(this Vector2D vector) - where T : IFloatingPointIeee754 => - T.Sqrt(vector.LengthSquared); - /// Normalizes a vector. public static Vector2D Normalize(this Vector2D vector) - where T : IFloatingPointIeee754 + where T : IRootFunctions { - T length = vector.GetLength(); + T length = vector.Length; return length != T.Zero ? vector / length : Vector2D.Zero; } + /// Returns the Euclidean distance between the two given points. + /// The first point. + /// The second point. + /// The distance. + public static T Distance(Vector2D value1, Vector2D value2) + where T : IRootFunctions => + T.Sqrt(DistanceSquared(value1, value2)); + + /// Returns the Euclidean distance squared between the two given points. + /// The first point. + /// The second point. + /// The distance squared. + public static T DistanceSquared(Vector2D value1, Vector2D value2) + where T : INumberBase + { + var difference = value1 - value2; + return Dot(difference, difference); + } + /// Applies to the provided arguments. /// A vector whose members will be provided for . public static Vector2D Sign(this Vector2D value) diff --git a/sources/Maths/Maths/Vector3D.cs b/sources/Maths/Maths/Vector3D.cs index d1a2cdb784..3423cd71be 100644 --- a/sources/Maths/Maths/Vector3D.cs +++ b/sources/Maths/Maths/Vector3D.cs @@ -14,24 +14,6 @@ namespace Silk.NET.Maths /// A structure representing a 3D integer vector. public partial struct Vector3D { - /// Computes the cross product of this vector with another vector. - public Vector3D Cross(Vector3D other) => - new Vector3D( - (Y * other.Z) - (Z * other.Y), - (Z * other.X) - (X * other.Z), - (X * other.Y) - (Y * other.X) - ); - - /// Computes the cross product of two vectors. - public static Vector3D Cross(Vector3D left, Vector3D right) => - new Vector3D( - (left.Y * right.Z) - (left.Z * right.Y), - (left.Z * right.X) - (left.X * right.Z), - (left.X * right.Y) - (left.Y * right.X) - ); - - // Casts - /// Explicitly casts a to a . public static explicit operator Vector3D(System.Numerics.Vector3 v) => new Vector3D((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T))); @@ -48,4 +30,15 @@ public static (Vector3D Quotient, Vector3D Remainder) DivRem(Vector3D l return (new Vector3D(qX, qY, qZ), new Vector3D(rX, rY, rZ)); } } + + public static partial class Vector2D + { + /// Computes the cross product of two vectors. + public static Vector3D Cross(this Vector3D left, Vector3D right) + where T : INumberBase => + new Vector3D( + (left.Y * right.Z) - (left.Z * right.Y), + (left.Z * right.X) - (left.X * right.Z), + (left.X * right.Y) - (left.Y * right.X)); + } } diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index ac758bac66..368a08c31a 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -61,8 +61,6 @@ public Vector3D(ReadOnlySpan values) /// Gets the vector (0, 0, 1). public static Vector3D UnitZ => new(T.Zero, T.Zero, T.One); - /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => Vector3D.Dot(this, this); /// T IReadOnlyList.this[int index] => this[index]; @@ -495,6 +493,20 @@ public static explicit operator Vector3D(Vector3D from) => public static partial class Vector3D { + extension(Vector3D vector) + where T : IRootFunctions + { + /// Gets the length of the vector. + public T Length => T.Sqrt(vector.LengthSquared); + } + + extension(Vector3D vector) + where T : INumberBase + { + /// Gets the length squared of the vector. + public T LengthSquared => Vector3D.Dot(vector, vector); + } + /// Computes the dot product of two vectors. public static T Dot(this Vector3D left, Vector3D right) where T : INumberBase => @@ -508,19 +520,33 @@ public static Vector3D Reflect(Vector3D vector, Vector3D normal) return vector - (normal * (dot + dot)); } - /// Computes the length of the vector. - public static T GetLength(this Vector3D vector) - where T : IFloatingPointIeee754 => - T.Sqrt(vector.LengthSquared); - /// Normalizes a vector. public static Vector3D Normalize(this Vector3D vector) - where T : IFloatingPointIeee754 + where T : IRootFunctions { - T length = vector.GetLength(); + T length = vector.Length; return length != T.Zero ? vector / length : Vector3D.Zero; } + /// Returns the Euclidean distance between the two given points. + /// The first point. + /// The second point. + /// The distance. + public static T Distance(Vector3D value1, Vector3D value2) + where T : IRootFunctions => + T.Sqrt(DistanceSquared(value1, value2)); + + /// Returns the Euclidean distance squared between the two given points. + /// The first point. + /// The second point. + /// The distance squared. + public static T DistanceSquared(Vector3D value1, Vector3D value2) + where T : INumberBase + { + var difference = value1 - value2; + return Dot(difference, difference); + } + /// Applies to the provided arguments. /// A vector whose members will be provided for . public static Vector3D Sign(this Vector3D value) diff --git a/sources/Maths/Maths/Vector4D.cs b/sources/Maths/Maths/Vector4D.cs index a50f79549d..b0ce4f0345 100644 --- a/sources/Maths/Maths/Vector4D.cs +++ b/sources/Maths/Maths/Vector4D.cs @@ -13,8 +13,6 @@ namespace Silk.NET.Maths /// A structure representing a 4D integer vector. public partial struct Vector4D { - // Casts - /// Explicitly casts a System.Numerics.Vector4 to a Vector4D. public static explicit operator Vector4D(System.Numerics.Vector4 v) => new Vector4D((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T)), (T)Convert.ChangeType(v.W, typeof(T))); diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index 210e3a98b4..8b433d61c2 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -71,8 +71,6 @@ public Vector4D(ReadOnlySpan values) /// Gets the vector (0, 0, 0, 1). public static Vector4D UnitW => new(T.Zero, T.Zero, T.Zero, T.One); - /// Gets the squared length of the vector (dot product with itself). - public T LengthSquared => Vector4D.Dot(this, this); /// T IReadOnlyList.this[int index] => this[index]; @@ -534,6 +532,20 @@ public static explicit operator Vector4D(Vector4D from) => public static partial class Vector4D { + extension(Vector4D vector) + where T : IRootFunctions + { + /// Gets the length of the vector. + public T Length => T.Sqrt(vector.LengthSquared); + } + + extension(Vector4D vector) + where T : INumberBase + { + /// Gets the length squared of the vector. + public T LengthSquared => Vector4D.Dot(vector, vector); + } + /// Computes the dot product of two vectors. public static T Dot(this Vector4D left, Vector4D right) where T : INumberBase => @@ -547,19 +559,33 @@ public static Vector4D Reflect(Vector4D vector, Vector4D normal) return vector - (normal * (dot + dot)); } - /// Computes the length of the vector. - public static T GetLength(this Vector4D vector) - where T : IFloatingPointIeee754 => - T.Sqrt(vector.LengthSquared); - /// Normalizes a vector. public static Vector4D Normalize(this Vector4D vector) - where T : IFloatingPointIeee754 + where T : IRootFunctions { - T length = vector.GetLength(); + T length = vector.Length; return length != T.Zero ? vector / length : Vector4D.Zero; } + /// Returns the Euclidean distance between the two given points. + /// The first point. + /// The second point. + /// The distance. + public static T Distance(Vector4D value1, Vector4D value2) + where T : IRootFunctions => + T.Sqrt(DistanceSquared(value1, value2)); + + /// Returns the Euclidean distance squared between the two given points. + /// The first point. + /// The second point. + /// The distance squared. + public static T DistanceSquared(Vector4D value1, Vector4D value2) + where T : INumberBase + { + var difference = value1 - value2; + return Dot(difference, difference); + } + /// Applies to the provided arguments. /// A vector whose members will be provided for . public static Vector4D Sign(this Vector4D value) From 5973151c022420dccf9ba432b80391dd792eb091 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 15:31:36 -0700 Subject: [PATCH 43/67] Generate more vector functions and reorganize. --- sources/Maths/Maths/Vector2D.cs | 44 ++++------------------------- sources/Maths/Maths/Vector2D.gen.cs | 27 ++++++++++++++++++ sources/Maths/Maths/Vector3D.cs | 26 ++++------------- sources/Maths/Maths/Vector3D.gen.cs | 29 +++++++++++++++++++ sources/Maths/Maths/Vector4D.cs | 24 ++++------------ sources/Maths/Maths/Vector4D.gen.cs | 31 ++++++++++++++++++++ 6 files changed, 103 insertions(+), 78 deletions(-) diff --git a/sources/Maths/Maths/Vector2D.cs b/sources/Maths/Maths/Vector2D.cs index 2f8e1cd237..5ade5f68db 100644 --- a/sources/Maths/Maths/Vector2D.cs +++ b/sources/Maths/Maths/Vector2D.cs @@ -1,46 +1,20 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections; -using System.Diagnostics.CodeAnalysis; using System.Numerics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Text; namespace Silk.NET.Maths { /// A structure representing a 2D integer vector. public partial struct Vector2D { - // Casts - - /// Explicitly casts a to a . - public static explicit operator Vector2D(System.Numerics.Vector2 v) => + /// Explicitly casts a to a . + public static explicit operator Vector2D(Vector2 v) => new Vector2D((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T))); - /// Explicitly casts a to . - public static explicit operator System.Numerics.Vector2(Vector2D v) => - new System.Numerics.Vector2(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); - - public static (Vector2D Quotient, Vector2D Remainder) DivRem(Vector2D left, Vector2D right) - { - var (qX, rX) = T.DivRem(left.X, right.X); - var (qY, rY) = T.DivRem(left.Y, right.Y); - return (new Vector2D(qX, qY), new Vector2D(rX, rY)); - } - - /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). - public static Vector2D LerpClamped(Vector2D a, Vector2D b, T t) => - Vector2D.Lerp(a, b, T.Clamp(t, T.Zero, T.One)); - - /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). - public static Vector2D LerpClamped(Vector2D a, Vector2D b, Vector2D t) => - new( - a.X + (b.X - a.X) * T.Clamp(t.X, T.Zero, T.One), - a.Y + (b.Y - a.Y) * T.Clamp(t.Y, T.Zero, T.One) - ); + /// Explicitly casts a to . + public static explicit operator Vector2(Vector2D v) => + new Vector2(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); } public static partial class Vector2D @@ -49,13 +23,5 @@ public static partial class Vector2D public static T Cross(this Vector2D left, Vector2D right) where T : INumberBase => (left.X * right.Y) - (left.Y * right.X); - - public static (Vector2D Sin, Vector2D Cos) SinCos(this Vector2D x) - where T : INumberBase => - (new(T.Sin(x.X), T.Sin(x.Y)), new(T.Cos(x.X), T.Cos(x.Y))); - - public static (Vector2D SinPi, Vector2D CosPi) SinCosPi(this Vector2D x) - where T : INumberBase => - (new(T.SinPi(x.X), T.SinPi(x.Y)), new(T.CosPi(x.X), T.CosPi(x.Y))); } } diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index fb65471a0b..474b209e2f 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -508,6 +508,33 @@ public static T DistanceSquared(Vector2D value1, Vector2D value2) return Dot(difference, difference); } + /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). + public static Vector2D LerpClamped(Vector2D a, Vector2D b, T amount) + where T : IFloatingPointIeee754 => + Lerp(a, b, T.Clamp(amount, T.Zero, T.One)); + + /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). + public static Vector2D LerpClamped(Vector2D a, Vector2D b, Vector2D amount) + where T : IFloatingPointIeee754 => + new(T.Lerp(a.X, b.X, T.Clamp(amount.X, T.Zero, T.One)), + T.Lerp(a.Y, b.Y, T.Clamp(amount.Y, T.Zero, T.One))); + + public static (Vector2D Sin, Vector2D Cos) SinCos(this Vector2D x) + where T : ITrigonometricFunctions => + (new(T.Sin(x.X), T.Sin(x.Y)), new(T.Cos(x.X), T.Cos(x.Y))); + + public static (Vector2D SinPi, Vector2D CosPi) SinCosPi(this Vector2D x) + where T : ITrigonometricFunctions => + (new(T.SinPi(x.X), T.SinPi(x.Y)), new(T.CosPi(x.X), T.CosPi(x.Y))); + + public static (Vector2D Quotient, Vector2D Remainder) DivRem(Vector2D left, Vector2D right) + where T : IBinaryInteger + { + var (qX, rX) = T.DivRem(left.X, right.X); + var (qY, rY) = T.DivRem(left.Y, right.Y); + return (new Vector2D(qX, qY), new Vector2D(rX, rY)); + } + /// Applies to the provided arguments. /// A vector whose members will be provided for . public static Vector2D Sign(this Vector2D value) diff --git a/sources/Maths/Maths/Vector3D.cs b/sources/Maths/Maths/Vector3D.cs index 3423cd71be..6e70b85bd8 100644 --- a/sources/Maths/Maths/Vector3D.cs +++ b/sources/Maths/Maths/Vector3D.cs @@ -1,37 +1,23 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections; -using System.Diagnostics.CodeAnalysis; using System.Numerics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Text; namespace Silk.NET.Maths { /// A structure representing a 3D integer vector. public partial struct Vector3D { - /// Explicitly casts a to a . - public static explicit operator Vector3D(System.Numerics.Vector3 v) => + /// Explicitly casts a to a . + public static explicit operator Vector3D(Vector3 v) => new Vector3D((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T))); - /// Explicitly casts a to . - public static explicit operator System.Numerics.Vector3(Vector3D v) => - new System.Numerics.Vector3(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z)); - - public static (Vector3D Quotient, Vector3D Remainder) DivRem(Vector3D left, Vector3D right) - { - var (qX, rX) = T.DivRem(left.X, right.X); - var (qY, rY) = T.DivRem(left.Y, right.Y); - var (qZ, rZ) = T.DivRem(left.Z, right.Z); - return (new Vector3D(qX, qY, qZ), new Vector3D(rX, rY, rZ)); - } + /// Explicitly casts a to . + public static explicit operator Vector3(Vector3D v) => + new Vector3(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z)); } - public static partial class Vector2D + public static partial class Vector3D { /// Computes the cross product of two vectors. public static Vector3D Cross(this Vector3D left, Vector3D right) diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index 368a08c31a..e915fd65bf 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -547,6 +547,35 @@ public static T DistanceSquared(Vector3D value1, Vector3D value2) return Dot(difference, difference); } + /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). + public static Vector3D LerpClamped(Vector3D a, Vector3D b, T amount) + where T : IFloatingPointIeee754 => + Lerp(a, b, T.Clamp(amount, T.Zero, T.One)); + + /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). + public static Vector3D LerpClamped(Vector3D a, Vector3D b, Vector3D amount) + where T : IFloatingPointIeee754 => + new(T.Lerp(a.X, b.X, T.Clamp(amount.X, T.Zero, T.One)), + T.Lerp(a.Y, b.Y, T.Clamp(amount.Y, T.Zero, T.One)), + T.Lerp(a.Z, b.Z, T.Clamp(amount.Z, T.Zero, T.One))); + + public static (Vector3D Sin, Vector3D Cos) SinCos(this Vector3D x) + where T : ITrigonometricFunctions => + (new(T.Sin(x.X), T.Sin(x.Y), T.Sin(x.Z)), new(T.Cos(x.X), T.Cos(x.Y), T.Cos(x.Z))); + + public static (Vector3D SinPi, Vector3D CosPi) SinCosPi(this Vector3D x) + where T : ITrigonometricFunctions => + (new(T.SinPi(x.X), T.SinPi(x.Y), T.SinPi(x.Z)), new(T.CosPi(x.X), T.CosPi(x.Y), T.CosPi(x.Z))); + + public static (Vector3D Quotient, Vector3D Remainder) DivRem(Vector3D left, Vector3D right) + where T : IBinaryInteger + { + var (qX, rX) = T.DivRem(left.X, right.X); + var (qY, rY) = T.DivRem(left.Y, right.Y); + var (qZ, rZ) = T.DivRem(left.Z, right.Z); + return (new Vector3D(qX, qY, qZ), new Vector3D(rX, rY, rZ)); + } + /// Applies to the provided arguments. /// A vector whose members will be provided for . public static Vector3D Sign(this Vector3D value) diff --git a/sources/Maths/Maths/Vector4D.cs b/sources/Maths/Maths/Vector4D.cs index b0ce4f0345..8a11841c66 100644 --- a/sources/Maths/Maths/Vector4D.cs +++ b/sources/Maths/Maths/Vector4D.cs @@ -1,33 +1,19 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections; -using System.Diagnostics.CodeAnalysis; using System.Numerics; -using System.Runtime.InteropServices; -using System.Text; namespace Silk.NET.Maths { /// A structure representing a 4D integer vector. public partial struct Vector4D { - /// Explicitly casts a System.Numerics.Vector4 to a Vector4D. - public static explicit operator Vector4D(System.Numerics.Vector4 v) => + /// Explicitly casts a to a . + public static explicit operator Vector4D(Vector4 v) => new Vector4D((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T)), (T)Convert.ChangeType(v.W, typeof(T))); - /// Explicitly casts a Vector4D to System.Numerics.Vector4. - public static explicit operator System.Numerics.Vector4(Vector4D v) => - new System.Numerics.Vector4(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z), Convert.ToSingle(v.W)); - - public static (Vector4D Quotient, Vector4D Remainder) DivRem(Vector4D left, Vector4D right) - { - var (qX, rX) = T.DivRem(left.X, right.X); - var (qY, rY) = T.DivRem(left.Y, right.Y); - var (qZ, rZ) = T.DivRem(left.Z, right.Z); - var (qW, rW) = T.DivRem(left.W, right.W); - return (new Vector4D(qX, qY, qZ, qW), new Vector4D(rX, rY, rZ, rW)); - } + /// Explicitly casts a to . + public static explicit operator Vector4(Vector4D v) => + new Vector4(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z), Convert.ToSingle(v.W)); } } diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index 8b433d61c2..04cf959ede 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -586,6 +586,37 @@ public static T DistanceSquared(Vector4D value1, Vector4D value2) return Dot(difference, difference); } + /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). + public static Vector4D LerpClamped(Vector4D a, Vector4D b, T amount) + where T : IFloatingPointIeee754 => + Lerp(a, b, T.Clamp(amount, T.Zero, T.One)); + + /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). + public static Vector4D LerpClamped(Vector4D a, Vector4D b, Vector4D amount) + where T : IFloatingPointIeee754 => + new(T.Lerp(a.X, b.X, T.Clamp(amount.X, T.Zero, T.One)), + T.Lerp(a.Y, b.Y, T.Clamp(amount.Y, T.Zero, T.One)), + T.Lerp(a.Z, b.Z, T.Clamp(amount.Z, T.Zero, T.One)), + T.Lerp(a.W, b.W, T.Clamp(amount.W, T.Zero, T.One))); + + public static (Vector4D Sin, Vector4D Cos) SinCos(this Vector4D x) + where T : ITrigonometricFunctions => + (new(T.Sin(x.X), T.Sin(x.Y), T.Sin(x.Z), T.Sin(x.W)), new(T.Cos(x.X), T.Cos(x.Y), T.Cos(x.Z), T.Cos(x.W))); + + public static (Vector4D SinPi, Vector4D CosPi) SinCosPi(this Vector4D x) + where T : ITrigonometricFunctions => + (new(T.SinPi(x.X), T.SinPi(x.Y), T.SinPi(x.Z), T.SinPi(x.W)), new(T.CosPi(x.X), T.CosPi(x.Y), T.CosPi(x.Z), T.CosPi(x.W))); + + public static (Vector4D Quotient, Vector4D Remainder) DivRem(Vector4D left, Vector4D right) + where T : IBinaryInteger + { + var (qX, rX) = T.DivRem(left.X, right.X); + var (qY, rY) = T.DivRem(left.Y, right.Y); + var (qZ, rZ) = T.DivRem(left.Z, right.Z); + var (qW, rW) = T.DivRem(left.W, right.W); + return (new Vector4D(qX, qY, qZ, qW), new Vector4D(rX, rY, rZ, rW)); + } + /// Applies to the provided arguments. /// A vector whose members will be provided for . public static Vector4D Sign(this Vector4D value) From 69be9de99547f689e869339a15d47af1efc787ee Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 15:32:06 -0700 Subject: [PATCH 44/67] Fix type constraints. --- sources/Maths/Maths/Circle.cs | 4 ++-- sources/Maths/Maths/Matrix2X3.Ops.cs | 2 +- sources/Maths/Maths/Matrix3X3.Ops.cs | 2 +- sources/Maths/Maths/Matrix4X4.Ops.cs | 8 ++++---- sources/Maths/Maths/Sphere.cs | 6 ++++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/sources/Maths/Maths/Circle.cs b/sources/Maths/Maths/Circle.cs index fd0a4ff342..4be7fcc35e 100644 --- a/sources/Maths/Maths/Circle.cs +++ b/sources/Maths/Maths/Circle.cs @@ -14,7 +14,7 @@ namespace Silk.NET.Maths [DataContract] public struct Circle : IEquatable> - where T : INumberBase + where T : IRootFunctions { /// /// The center. @@ -174,7 +174,7 @@ public override int GetHashCode() /// /// The type to cast to /// The casted circle - public Circle As() where TOther : INumberBase + public Circle As() where TOther : IRootFunctions { return new(Center.As(), Scalar.As(Radius)); } diff --git a/sources/Maths/Maths/Matrix2X3.Ops.cs b/sources/Maths/Maths/Matrix2X3.Ops.cs index cd5d662780..81cae99cff 100644 --- a/sources/Maths/Maths/Matrix2X3.Ops.cs +++ b/sources/Maths/Maths/Matrix2X3.Ops.cs @@ -32,7 +32,7 @@ public static Matrix2X3 Add(Matrix2X3 value1, Matrix2X3 value2) /// The forward vector of the camera. /// The created billboard matrix public static Matrix2X3 CreateBillboard(Vector3D objectPosition, Vector3D cameraPosition, Vector3D cameraUpVector, Vector3D cameraForwardVector) - where T : INumberBase + where T : IRootFunctions { Vector3D zaxis = objectPosition - cameraPosition; var norm = zaxis.LengthSquared; diff --git a/sources/Maths/Maths/Matrix3X3.Ops.cs b/sources/Maths/Maths/Matrix3X3.Ops.cs index e955b5c9bb..3f1dcf198d 100644 --- a/sources/Maths/Maths/Matrix3X3.Ops.cs +++ b/sources/Maths/Maths/Matrix3X3.Ops.cs @@ -53,7 +53,7 @@ public static Matrix3X3 Add(Matrix3X3 value1, Matrix3X3 value2) /// The forward vector of the camera. /// The created billboard matrix public static Matrix3X3 CreateBillboard(Vector3D objectPosition, Vector3D cameraPosition, Vector3D cameraUpVector, Vector3D cameraForwardVector) - where T : INumberBase + where T : IRootFunctions { Vector3D zaxis = objectPosition - cameraPosition; var norm = zaxis.LengthSquared; diff --git a/sources/Maths/Maths/Matrix4X4.Ops.cs b/sources/Maths/Maths/Matrix4X4.Ops.cs index d44381a2c8..450925695d 100644 --- a/sources/Maths/Maths/Matrix4X4.Ops.cs +++ b/sources/Maths/Maths/Matrix4X4.Ops.cs @@ -58,7 +58,7 @@ public static Matrix4X4 Add(Matrix4X4 value1, Matrix4X4 value2) /// The forward vector of the camera. /// The created billboard matrix public static Matrix4X4 CreateBillboard(Vector3D objectPosition, Vector3D cameraPosition, Vector3D cameraUpVector, Vector3D cameraForwardVector) - where T : INumberBase + where T : IRootFunctions { Vector3D zaxis = objectPosition - cameraPosition; var norm = zaxis.LengthSquared; @@ -90,7 +90,7 @@ public static Matrix4X4 CreateBillboard(Vector3D objectPosition, Vector /// Forward vector of the object. /// The created billboard matrix. public static Matrix4X4 CreateConstrainedBillboard(Vector3D objectPosition, Vector3D cameraPosition, Vector3D rotateAxis, Vector3D cameraForwardVector, Vector3D objectForwardVector) - where T : INumberBase + where T : IRootFunctions { // Treat the case when object and camera positions are too close. Vector3D faceDir = objectPosition - cameraPosition; @@ -250,7 +250,7 @@ public static Matrix4X4 CreateFromYawPitchRoll(T yaw, T pitch, T roll) /// The direction that is "up" from the camera's point of view. /// The view matrix. public static Matrix4X4 CreateLookAt(Vector3D cameraPosition, Vector3D cameraTarget, Vector3D cameraUpVector) - where T : INumberBase + where T : IRootFunctions { Vector3D zaxis = Vector3D.Normalize(cameraPosition - cameraTarget); Vector3D xaxis = Vector3D.Normalize(Vector3D.Cross(cameraUpVector, zaxis)); @@ -814,7 +814,7 @@ public static Matrix4X4 CreateTranslation(T xPosition, T yPosition, T zPos /// Upward direction of the object; usually [0, 1, 0]. /// The world matrix. public static Matrix4X4 CreateWorld(Vector3D position, Vector3D forward, Vector3D up) - where T : INumberBase + where T : IRootFunctions { Vector3D zaxis = Vector3D.Normalize(-forward); Vector3D xaxis = Vector3D.Normalize(Vector3D.Cross(up, zaxis)); diff --git a/sources/Maths/Maths/Sphere.cs b/sources/Maths/Maths/Sphere.cs index 91bce6e0f2..759a13290a 100644 --- a/sources/Maths/Maths/Sphere.cs +++ b/sources/Maths/Maths/Sphere.cs @@ -13,7 +13,8 @@ namespace Silk.NET.Maths [Serializable] [DataContract] public struct Sphere - : IEquatable> where T : INumberBase + : IEquatable> + where T : IRootFunctions { /// /// The center. @@ -169,7 +170,8 @@ public override int GetHashCode() /// /// The type to cast to /// The casted sphere - public Sphere As() where TOther : INumberBase + public Sphere As() + where TOther : IRootFunctions { return new(Center.As(), Scalar.As(Radius)); } From 75b1c5de6a3b20785330c7f5a9b3fa9c739a3d48 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 16:31:17 -0700 Subject: [PATCH 45/67] Overloads for casts, As, CreateChecked, CreateSaturating, and CreateTruncating. --- sources/Maths/Maths/Matrix2X2.cs | 10 - sources/Maths/Maths/Matrix2X2.gen.cs | 178 ++++++++++++++--- sources/Maths/Maths/Matrix2X3.cs | 10 - sources/Maths/Maths/Matrix2X3.gen.cs | 178 ++++++++++++++--- sources/Maths/Maths/Matrix2X4.cs | 10 - sources/Maths/Maths/Matrix2X4.gen.cs | 178 ++++++++++++++--- sources/Maths/Maths/Matrix3X2.cs | 10 - sources/Maths/Maths/Matrix3X2.gen.cs | 214 ++++++++++++++++---- sources/Maths/Maths/Matrix3X3.cs | 10 - sources/Maths/Maths/Matrix3X3.gen.cs | 214 ++++++++++++++++---- sources/Maths/Maths/Matrix3X4.cs | 10 - sources/Maths/Maths/Matrix3X4.gen.cs | 214 ++++++++++++++++---- sources/Maths/Maths/Matrix4X2.cs | 10 - sources/Maths/Maths/Matrix4X2.gen.cs | 250 ++++++++++++++++++----- sources/Maths/Maths/Matrix4X3.cs | 10 - sources/Maths/Maths/Matrix4X3.gen.cs | 250 ++++++++++++++++++----- sources/Maths/Maths/Matrix4X4.cs | 10 - sources/Maths/Maths/Matrix4X4.gen.cs | 250 ++++++++++++++++++----- sources/Maths/Maths/Matrix5X4.cs | 10 - sources/Maths/Maths/Matrix5X4.gen.cs | 286 +++++++++++++++++++++------ sources/Maths/Maths/Vector2D.gen.cs | 155 +++++++++++++-- sources/Maths/Maths/Vector3D.gen.cs | 159 ++++++++++++--- sources/Maths/Maths/Vector4D.gen.cs | 163 ++++++++++++--- 23 files changed, 2236 insertions(+), 553 deletions(-) diff --git a/sources/Maths/Maths/Matrix2X2.cs b/sources/Maths/Maths/Matrix2X2.cs index ada5e31b39..c1af4faa51 100644 --- a/sources/Maths/Maths/Matrix2X2.cs +++ b/sources/Maths/Maths/Matrix2X2.cs @@ -81,15 +81,5 @@ public readonly T GetDeterminant() return Scalar.Subtract(Scalar.Multiply(a, d), Scalar.Multiply(b, c)); } - - /// - /// Returns this matrix casted to - /// - /// The type to cast to - /// The casted matrix - public Matrix2X2 As() where TOther : INumberBase - { - return new(Row1.As(), Row2.As()); - } } } diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index d1490acf18..0a61042a45 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -114,6 +114,27 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Converts the components of this vector to another type. + public static Matrix2X2 CreateChecked(Matrix2X2 other) + where TOther : INumberBase => + new(Vector2D.CreateChecked(other.Row1), Vector2D.CreateChecked(other.Row2)); + + /// Converts the components of this vector to another type. + public static Matrix2X2 CreateSaturating(Matrix2X2 other) + where TOther : INumberBase => + new(Vector2D.CreateSaturating(other.Row1), Vector2D.CreateSaturating(other.Row2)); + + /// Converts the components of this vector to another type. + public static Matrix2X2 CreateTruncating(Matrix2X2 other) + where TOther : INumberBase => + new(Vector2D.CreateTruncating(other.Row1), Vector2D.CreateTruncating(other.Row2)); + + /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + public Matrix2X2 As() + where TOther : INumberBase => + new(Row1.As(), Row2.As()); + /// Computes the transpose of the matrix. public Matrix2X2 Transpose() => new(new(M11, M21), @@ -179,14 +200,24 @@ public Matrix2X2 Transpose() => public static Matrix2X2 operator *(Matrix2X2 left, Matrix2X2 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2); + /// /// Converts a matrix of into one with an underlying type of . /// /// The source matrix. /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X2(Matrix2X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -194,8 +225,17 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X2(Matrix2X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -203,8 +243,17 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X2(Matrix2X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -212,8 +261,17 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X2(Matrix2X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -221,8 +279,17 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X2(Matrix2X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -230,8 +297,17 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X2(Matrix2X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -239,8 +315,17 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X2(Matrix2X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -248,8 +333,17 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X2(Matrix2X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -257,8 +351,17 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X2(Matrix2X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -266,8 +369,17 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X2(Matrix2X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -275,8 +387,17 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X2(Matrix2X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -284,8 +405,17 @@ public static explicit operator Matrix2X2(Matrix2X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X2(Matrix2X2 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X2(Matrix2X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2)); } public static partial class Matrix2X2 diff --git a/sources/Maths/Maths/Matrix2X3.cs b/sources/Maths/Maths/Matrix2X3.cs index 884d142dd2..75e94fa6ed 100644 --- a/sources/Maths/Maths/Matrix2X3.cs +++ b/sources/Maths/Maths/Matrix2X3.cs @@ -79,15 +79,5 @@ public readonly bool IsIdentity { return value1.X * value2.Row1 + value1.Y * value2.Row2; } - - /// - /// Returns this matrix casted to - /// - /// The type to cast to - /// The casted matrix - public Matrix2X3 As() where TOther : INumberBase - { - return new(Row1.As(), Row2.As()); - } } } diff --git a/sources/Maths/Maths/Matrix2X3.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs index 07f9ec51b9..cd3fd0c468 100644 --- a/sources/Maths/Maths/Matrix2X3.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -123,6 +123,27 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Converts the components of this vector to another type. + public static Matrix2X3 CreateChecked(Matrix2X3 other) + where TOther : INumberBase => + new(Vector3D.CreateChecked(other.Row1), Vector3D.CreateChecked(other.Row2)); + + /// Converts the components of this vector to another type. + public static Matrix2X3 CreateSaturating(Matrix2X3 other) + where TOther : INumberBase => + new(Vector3D.CreateSaturating(other.Row1), Vector3D.CreateSaturating(other.Row2)); + + /// Converts the components of this vector to another type. + public static Matrix2X3 CreateTruncating(Matrix2X3 other) + where TOther : INumberBase => + new(Vector3D.CreateTruncating(other.Row1), Vector3D.CreateTruncating(other.Row2)); + + /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + public Matrix2X3 As() + where TOther : INumberBase => + new(Row1.As(), Row2.As()); + /// Computes the transpose of the matrix. public Matrix3X2 Transpose() => new(new(M11, M21), @@ -197,14 +218,24 @@ public Matrix3X2 Transpose() => public static Matrix2X2 operator *(Matrix2X3 left, Matrix3X2 right) => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3); + /// /// Converts a matrix of into one with an underlying type of . /// /// The source matrix. /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X3(Matrix2X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -212,8 +243,17 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X3(Matrix2X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -221,8 +261,17 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X3(Matrix2X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -230,8 +279,17 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X3(Matrix2X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -239,8 +297,17 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X3(Matrix2X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -248,8 +315,17 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X3(Matrix2X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -257,8 +333,17 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X3(Matrix2X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -266,8 +351,17 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X3(Matrix2X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -275,8 +369,17 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X3(Matrix2X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -284,8 +387,17 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X3(Matrix2X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -293,8 +405,17 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X3(Matrix2X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -302,8 +423,17 @@ public static explicit operator Matrix2X3(Matrix2X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X3(Matrix2X3 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X3(Matrix2X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2)); } public static partial class Matrix2X3 diff --git a/sources/Maths/Maths/Matrix2X4.cs b/sources/Maths/Maths/Matrix2X4.cs index d6d530eb34..fb82209033 100644 --- a/sources/Maths/Maths/Matrix2X4.cs +++ b/sources/Maths/Maths/Matrix2X4.cs @@ -80,15 +80,5 @@ public readonly bool IsIdentity { return value1.X * value2.Row1 + value1.Y * value2.Row2; } - - /// - /// Returns this matrix casted to - /// - /// The type to cast to - /// The casted matrix - public Matrix2X4 As() where TOther : INumberBase - { - return new(Row1.As(), Row2.As()); - } } } diff --git a/sources/Maths/Maths/Matrix2X4.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs index ee07f8dfee..2e8af8f158 100644 --- a/sources/Maths/Maths/Matrix2X4.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -137,6 +137,27 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); + /// Converts the components of this vector to another type. + public static Matrix2X4 CreateChecked(Matrix2X4 other) + where TOther : INumberBase => + new(Vector4D.CreateChecked(other.Row1), Vector4D.CreateChecked(other.Row2)); + + /// Converts the components of this vector to another type. + public static Matrix2X4 CreateSaturating(Matrix2X4 other) + where TOther : INumberBase => + new(Vector4D.CreateSaturating(other.Row1), Vector4D.CreateSaturating(other.Row2)); + + /// Converts the components of this vector to another type. + public static Matrix2X4 CreateTruncating(Matrix2X4 other) + where TOther : INumberBase => + new(Vector4D.CreateTruncating(other.Row1), Vector4D.CreateTruncating(other.Row2)); + + /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + public Matrix2X4 As() + where TOther : INumberBase => + new(Row1.As(), Row2.As()); + /// Computes the transpose of the matrix. public Matrix4X2 Transpose() => new(new(M11, M21), @@ -221,14 +242,24 @@ public Matrix4X2 Transpose() => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + /// /// Converts a matrix of into one with an underlying type of . /// /// The source matrix. /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X4(Matrix2X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -236,8 +267,17 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X4(Matrix2X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -245,8 +285,17 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X4(Matrix2X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -254,8 +303,17 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X4(Matrix2X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -263,8 +321,17 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X4(Matrix2X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -272,8 +339,17 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X4(Matrix2X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -281,8 +357,17 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X4(Matrix2X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -290,8 +375,17 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X4(Matrix2X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -299,8 +393,17 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X4(Matrix2X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -308,8 +411,17 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X4(Matrix2X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -317,8 +429,17 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X4(Matrix2X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2)); /// /// Converts a matrix of into one with an underlying type of . @@ -326,8 +447,17 @@ public static explicit operator Matrix2X4(Matrix2X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix2X4(Matrix2X4 from) => - new(from.Row1.As(), - from.Row2.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix2X4(Matrix2X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2)); } public static partial class Matrix2X4 diff --git a/sources/Maths/Maths/Matrix3X2.cs b/sources/Maths/Maths/Matrix3X2.cs index 2ec8ed1612..95bd53d619 100644 --- a/sources/Maths/Maths/Matrix3X2.cs +++ b/sources/Maths/Maths/Matrix3X2.cs @@ -116,15 +116,5 @@ public static explicit operator System.Numerics.Matrix3x2(Matrix3X2 from) Scalar.As(from.M21), Scalar.As(from.M22), Scalar.As(from.M31), Scalar.As(from.M32) ); - - /// - /// Returns this matrix casted to - /// - /// The type to cast to - /// The casted matrix - public Matrix3X2 As() where TOther : INumberBase - { - return new(Row1.As(), Row2.As(), Row3.As()); - } } } diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index 3c03e4b538..3afe6bdefa 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -128,6 +128,27 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Converts the components of this vector to another type. + public static Matrix3X2 CreateChecked(Matrix3X2 other) + where TOther : INumberBase => + new(Vector2D.CreateChecked(other.Row1), Vector2D.CreateChecked(other.Row2), Vector2D.CreateChecked(other.Row3)); + + /// Converts the components of this vector to another type. + public static Matrix3X2 CreateSaturating(Matrix3X2 other) + where TOther : INumberBase => + new(Vector2D.CreateSaturating(other.Row1), Vector2D.CreateSaturating(other.Row2), Vector2D.CreateSaturating(other.Row3)); + + /// Converts the components of this vector to another type. + public static Matrix3X2 CreateTruncating(Matrix3X2 other) + where TOther : INumberBase => + new(Vector2D.CreateTruncating(other.Row1), Vector2D.CreateTruncating(other.Row2), Vector2D.CreateTruncating(other.Row3)); + + /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + public Matrix3X2 As() + where TOther : INumberBase => + new(Row1.As(), Row2.As(), Row3.As()); + /// Computes the transpose of the matrix. public Matrix2X3 Transpose() => new(new(M11, M21, M31), @@ -209,15 +230,26 @@ public Matrix2X3 Transpose() => new(left.M11 * right.Row1 + left.M12 * right.Row2, left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + /// /// Converts a matrix of into one with an underlying type of . /// /// The source matrix. /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X2(Matrix3X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -225,9 +257,19 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X2(Matrix3X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -235,9 +277,19 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X2(Matrix3X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -245,9 +297,19 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X2(Matrix3X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -255,9 +317,19 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X2(Matrix3X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -265,9 +337,19 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X2(Matrix3X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -275,9 +357,19 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X2(Matrix3X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -285,9 +377,19 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X2(Matrix3X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -295,9 +397,19 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X2(Matrix3X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -305,9 +417,19 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X2(Matrix3X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -315,9 +437,19 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X2(Matrix3X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -325,9 +457,19 @@ public static explicit operator Matrix3X2(Matrix3X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X2(Matrix3X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X2(Matrix3X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3)); } public static partial class Matrix3X2 diff --git a/sources/Maths/Maths/Matrix3X3.cs b/sources/Maths/Maths/Matrix3X3.cs index 69e0db0bd1..27cf5a9bf6 100644 --- a/sources/Maths/Maths/Matrix3X3.cs +++ b/sources/Maths/Maths/Matrix3X3.cs @@ -113,15 +113,5 @@ public readonly T GetDeterminant() Scalar.Multiply(b, Scalar.Subtract(Scalar.Multiply(d, i), Scalar.Multiply(f, g)))), Scalar.Multiply(c, Scalar.Subtract(Scalar.Multiply(d, h), Scalar.Multiply(e, g)))); } - - /// - /// Returns this matrix casted to - /// - /// The type to cast to - /// The casted matrix - public Matrix3X3 As() where TOther : INumberBase - { - return new(Row1.As(), Row2.As(), Row3.As()); - } } } diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index 6466c089d6..4b039ee5b5 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -153,6 +153,27 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Converts the components of this vector to another type. + public static Matrix3X3 CreateChecked(Matrix3X3 other) + where TOther : INumberBase => + new(Vector3D.CreateChecked(other.Row1), Vector3D.CreateChecked(other.Row2), Vector3D.CreateChecked(other.Row3)); + + /// Converts the components of this vector to another type. + public static Matrix3X3 CreateSaturating(Matrix3X3 other) + where TOther : INumberBase => + new(Vector3D.CreateSaturating(other.Row1), Vector3D.CreateSaturating(other.Row2), Vector3D.CreateSaturating(other.Row3)); + + /// Converts the components of this vector to another type. + public static Matrix3X3 CreateTruncating(Matrix3X3 other) + where TOther : INumberBase => + new(Vector3D.CreateTruncating(other.Row1), Vector3D.CreateTruncating(other.Row2), Vector3D.CreateTruncating(other.Row3)); + + /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + public Matrix3X3 As() + where TOther : INumberBase => + new(Row1.As(), Row2.As(), Row3.As()); + /// Computes the transpose of the matrix. public Matrix3X3 Transpose() => new(new(M11, M21, M31), @@ -243,15 +264,26 @@ public Matrix3X3 Transpose() => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3); + /// /// Converts a matrix of into one with an underlying type of . /// /// The source matrix. /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X3(Matrix3X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -259,9 +291,19 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X3(Matrix3X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -269,9 +311,19 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X3(Matrix3X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -279,9 +331,19 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X3(Matrix3X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -289,9 +351,19 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X3(Matrix3X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -299,9 +371,19 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X3(Matrix3X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -309,9 +391,19 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X3(Matrix3X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -319,9 +411,19 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X3(Matrix3X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -329,9 +431,19 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X3(Matrix3X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -339,9 +451,19 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X3(Matrix3X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -349,9 +471,19 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X3(Matrix3X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -359,9 +491,19 @@ public static explicit operator Matrix3X3(Matrix3X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X3(Matrix3X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X3(Matrix3X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3)); } public static partial class Matrix3X3 diff --git a/sources/Maths/Maths/Matrix3X4.cs b/sources/Maths/Maths/Matrix3X4.cs index b84ae7b298..ed6c1c1193 100644 --- a/sources/Maths/Maths/Matrix3X4.cs +++ b/sources/Maths/Maths/Matrix3X4.cs @@ -97,15 +97,5 @@ public readonly bool IsIdentity { return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3; } - - /// - /// Returns this matrix casted to - /// - /// The type to cast to - /// The casted matrix - public Matrix3X4 As() where TOther : INumberBase - { - return new(Row1.As(), Row2.As(), Row3.As()); - } } } diff --git a/sources/Maths/Maths/Matrix3X4.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs index ce53d29ad9..640fe89ad4 100644 --- a/sources/Maths/Maths/Matrix3X4.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -166,6 +166,27 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); + /// Converts the components of this vector to another type. + public static Matrix3X4 CreateChecked(Matrix3X4 other) + where TOther : INumberBase => + new(Vector4D.CreateChecked(other.Row1), Vector4D.CreateChecked(other.Row2), Vector4D.CreateChecked(other.Row3)); + + /// Converts the components of this vector to another type. + public static Matrix3X4 CreateSaturating(Matrix3X4 other) + where TOther : INumberBase => + new(Vector4D.CreateSaturating(other.Row1), Vector4D.CreateSaturating(other.Row2), Vector4D.CreateSaturating(other.Row3)); + + /// Converts the components of this vector to another type. + public static Matrix3X4 CreateTruncating(Matrix3X4 other) + where TOther : INumberBase => + new(Vector4D.CreateTruncating(other.Row1), Vector4D.CreateTruncating(other.Row2), Vector4D.CreateTruncating(other.Row3)); + + /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + public Matrix3X4 As() + where TOther : INumberBase => + new(Row1.As(), Row2.As(), Row3.As()); + /// Computes the transpose of the matrix. public Matrix4X3 Transpose() => new(new(M11, M21, M31), @@ -266,15 +287,26 @@ public Matrix4X3 Transpose() => new(left.M11 * right.Row1 + left.M12 * right.Row2 + left.M13 * right.Row3 + left.M14 * right.Row4, left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4); + /// /// Converts a matrix of into one with an underlying type of . /// /// The source matrix. /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X4(Matrix3X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -282,9 +314,19 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X4(Matrix3X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -292,9 +334,19 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X4(Matrix3X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -302,9 +354,19 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X4(Matrix3X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -312,9 +374,19 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X4(Matrix3X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -322,9 +394,19 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X4(Matrix3X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -332,9 +414,19 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X4(Matrix3X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -342,9 +434,19 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X4(Matrix3X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -352,9 +454,19 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X4(Matrix3X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -362,9 +474,19 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X4(Matrix3X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -372,9 +494,19 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X4(Matrix3X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3)); /// /// Converts a matrix of into one with an underlying type of . @@ -382,9 +514,19 @@ public static explicit operator Matrix3X4(Matrix3X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix3X4(Matrix3X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix3X4(Matrix3X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3)); } public static partial class Matrix3X4 diff --git a/sources/Maths/Maths/Matrix4X2.cs b/sources/Maths/Maths/Matrix4X2.cs index 606ca14133..32aa778cd5 100644 --- a/sources/Maths/Maths/Matrix4X2.cs +++ b/sources/Maths/Maths/Matrix4X2.cs @@ -93,15 +93,5 @@ public readonly bool IsIdentity { return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3 + value1.W * value2.Row4; } - - /// - /// Returns this matrix casted to - /// - /// The type to cast to - /// The casted matrix - public Matrix4X2 As() where TOther : INumberBase - { - return new(Row1.As(), Row2.As(), Row3.As(), Row4.As()); - } } } diff --git a/sources/Maths/Maths/Matrix4X2.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs index 0cda66d434..2cad4a3085 100644 --- a/sources/Maths/Maths/Matrix4X2.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -147,6 +147,27 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Converts the components of this vector to another type. + public static Matrix4X2 CreateChecked(Matrix4X2 other) + where TOther : INumberBase => + new(Vector2D.CreateChecked(other.Row1), Vector2D.CreateChecked(other.Row2), Vector2D.CreateChecked(other.Row3), Vector2D.CreateChecked(other.Row4)); + + /// Converts the components of this vector to another type. + public static Matrix4X2 CreateSaturating(Matrix4X2 other) + where TOther : INumberBase => + new(Vector2D.CreateSaturating(other.Row1), Vector2D.CreateSaturating(other.Row2), Vector2D.CreateSaturating(other.Row3), Vector2D.CreateSaturating(other.Row4)); + + /// Converts the components of this vector to another type. + public static Matrix4X2 CreateTruncating(Matrix4X2 other) + where TOther : INumberBase => + new(Vector2D.CreateTruncating(other.Row1), Vector2D.CreateTruncating(other.Row2), Vector2D.CreateTruncating(other.Row3), Vector2D.CreateTruncating(other.Row4)); + + /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + public Matrix4X2 As() + where TOther : INumberBase => + new(Row1.As(), Row2.As(), Row3.As(), Row4.As()); + /// Computes the transpose of the matrix. public Matrix2X4 Transpose() => new(new(M11, M21, M31, M41), @@ -246,16 +267,28 @@ public Matrix2X4 Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2, left.M41 * right.Row1 + left.M42 * right.Row2); + /// /// Converts a matrix of into one with an underlying type of . /// /// The source matrix. /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3), + Vector2D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X2(Matrix4X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3), + Vector2D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -263,10 +296,21 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3), + Vector2D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X2(Matrix4X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3), + Vector2D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -274,10 +318,21 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3), + Vector2D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X2(Matrix4X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3), + Vector2D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -285,10 +340,21 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3), + Vector2D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X2(Matrix4X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3), + Vector2D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -296,10 +362,21 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3), + Vector2D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X2(Matrix4X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3), + Vector2D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -307,10 +384,21 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3), + Vector2D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X2(Matrix4X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3), + Vector2D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -318,10 +406,21 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3), + Vector2D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X2(Matrix4X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3), + Vector2D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -329,10 +428,21 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3), + Vector2D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X2(Matrix4X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3), + Vector2D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -340,10 +450,21 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3), + Vector2D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X2(Matrix4X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3), + Vector2D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -351,10 +472,21 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3), + Vector2D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X2(Matrix4X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3), + Vector2D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -362,10 +494,21 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3), + Vector2D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X2(Matrix4X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3), + Vector2D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -373,10 +516,21 @@ public static explicit operator Matrix4X2(Matrix4X2 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X2(Matrix4X2 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector2D.CreateTruncating(from.Row1), + Vector2D.CreateTruncating(from.Row2), + Vector2D.CreateTruncating(from.Row3), + Vector2D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X2(Matrix4X2 from) => + new(Vector2D.CreateChecked(from.Row1), + Vector2D.CreateChecked(from.Row2), + Vector2D.CreateChecked(from.Row3), + Vector2D.CreateChecked(from.Row4)); } public static partial class Matrix4X2 diff --git a/sources/Maths/Maths/Matrix4X3.cs b/sources/Maths/Maths/Matrix4X3.cs index 7e69e7d550..b6d740fcc5 100644 --- a/sources/Maths/Maths/Matrix4X3.cs +++ b/sources/Maths/Maths/Matrix4X3.cs @@ -116,15 +116,5 @@ public readonly bool IsIdentity { return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3 + value1.W * value2.Row4; } - - /// - /// Returns this matrix casted to - /// - /// The type to cast to - /// The casted matrix - public Matrix4X3 As() where TOther : INumberBase - { - return new(Row1.As(), Row2.As(), Row3.As(), Row4.As()); - } } } diff --git a/sources/Maths/Maths/Matrix4X3.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs index f5d3add102..bb4c1216ff 100644 --- a/sources/Maths/Maths/Matrix4X3.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -171,6 +171,27 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Converts the components of this vector to another type. + public static Matrix4X3 CreateChecked(Matrix4X3 other) + where TOther : INumberBase => + new(Vector3D.CreateChecked(other.Row1), Vector3D.CreateChecked(other.Row2), Vector3D.CreateChecked(other.Row3), Vector3D.CreateChecked(other.Row4)); + + /// Converts the components of this vector to another type. + public static Matrix4X3 CreateSaturating(Matrix4X3 other) + where TOther : INumberBase => + new(Vector3D.CreateSaturating(other.Row1), Vector3D.CreateSaturating(other.Row2), Vector3D.CreateSaturating(other.Row3), Vector3D.CreateSaturating(other.Row4)); + + /// Converts the components of this vector to another type. + public static Matrix4X3 CreateTruncating(Matrix4X3 other) + where TOther : INumberBase => + new(Vector3D.CreateTruncating(other.Row1), Vector3D.CreateTruncating(other.Row2), Vector3D.CreateTruncating(other.Row3), Vector3D.CreateTruncating(other.Row4)); + + /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + public Matrix4X3 As() + where TOther : INumberBase => + new(Row1.As(), Row2.As(), Row3.As(), Row4.As()); + /// Computes the transpose of the matrix. public Matrix3X4 Transpose() => new(new(M11, M21, M31, M41), @@ -279,16 +300,28 @@ public Matrix3X4 Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3); + /// /// Converts a matrix of into one with an underlying type of . /// /// The source matrix. /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3), + Vector3D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X3(Matrix4X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3), + Vector3D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -296,10 +329,21 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3), + Vector3D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X3(Matrix4X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3), + Vector3D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -307,10 +351,21 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3), + Vector3D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X3(Matrix4X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3), + Vector3D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -318,10 +373,21 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3), + Vector3D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X3(Matrix4X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3), + Vector3D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -329,10 +395,21 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3), + Vector3D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X3(Matrix4X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3), + Vector3D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -340,10 +417,21 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3), + Vector3D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X3(Matrix4X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3), + Vector3D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -351,10 +439,21 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3), + Vector3D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X3(Matrix4X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3), + Vector3D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -362,10 +461,21 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3), + Vector3D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X3(Matrix4X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3), + Vector3D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -373,10 +483,21 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3), + Vector3D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X3(Matrix4X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3), + Vector3D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -384,10 +505,21 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3), + Vector3D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X3(Matrix4X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3), + Vector3D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -395,10 +527,21 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3), + Vector3D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X3(Matrix4X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3), + Vector3D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -406,10 +549,21 @@ public static explicit operator Matrix4X3(Matrix4X3 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X3(Matrix4X3 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector3D.CreateTruncating(from.Row1), + Vector3D.CreateTruncating(from.Row2), + Vector3D.CreateTruncating(from.Row3), + Vector3D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X3(Matrix4X3 from) => + new(Vector3D.CreateChecked(from.Row1), + Vector3D.CreateChecked(from.Row2), + Vector3D.CreateChecked(from.Row3), + Vector3D.CreateChecked(from.Row4)); } public static partial class Matrix4X3 diff --git a/sources/Maths/Maths/Matrix4X4.cs b/sources/Maths/Maths/Matrix4X4.cs index 2a5149bd5b..61118d8d30 100644 --- a/sources/Maths/Maths/Matrix4X4.cs +++ b/sources/Maths/Maths/Matrix4X4.cs @@ -160,15 +160,5 @@ public readonly T GetDeterminant() Scalar.Subtract(Scalar.Multiply(e, jo_kn), Scalar.Multiply(f, io_km)), Scalar.Multiply(g, in_jm))))); } - - /// - /// Returns this matrix casted to - /// - /// The type to cast to - /// The casted matrix - public Matrix4X4 As() where TOther : INumberBase - { - return new(Row1.As(), Row2.As(), Row3.As(), Row4.As()); - } } } diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index c77c210af0..046b54feda 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -202,6 +202,27 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); + /// Converts the components of this vector to another type. + public static Matrix4X4 CreateChecked(Matrix4X4 other) + where TOther : INumberBase => + new(Vector4D.CreateChecked(other.Row1), Vector4D.CreateChecked(other.Row2), Vector4D.CreateChecked(other.Row3), Vector4D.CreateChecked(other.Row4)); + + /// Converts the components of this vector to another type. + public static Matrix4X4 CreateSaturating(Matrix4X4 other) + where TOther : INumberBase => + new(Vector4D.CreateSaturating(other.Row1), Vector4D.CreateSaturating(other.Row2), Vector4D.CreateSaturating(other.Row3), Vector4D.CreateSaturating(other.Row4)); + + /// Converts the components of this vector to another type. + public static Matrix4X4 CreateTruncating(Matrix4X4 other) + where TOther : INumberBase => + new(Vector4D.CreateTruncating(other.Row1), Vector4D.CreateTruncating(other.Row2), Vector4D.CreateTruncating(other.Row3), Vector4D.CreateTruncating(other.Row4)); + + /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + public Matrix4X4 As() + where TOther : INumberBase => + new(Row1.As(), Row2.As(), Row3.As(), Row4.As()); + /// Computes the transpose of the matrix. public Matrix4X4 Transpose() => new(new(M11, M21, M31, M41), @@ -320,16 +341,28 @@ public Matrix4X4 Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2 + left.M23 * right.Row3 + left.M24 * right.Row4, left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + /// /// Converts a matrix of into one with an underlying type of . /// /// The source matrix. /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X4(Matrix4X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -337,10 +370,21 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X4(Matrix4X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -348,10 +392,21 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X4(Matrix4X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -359,10 +414,21 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X4(Matrix4X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -370,10 +436,21 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X4(Matrix4X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -381,10 +458,21 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X4(Matrix4X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -392,10 +480,21 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X4(Matrix4X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -403,10 +502,21 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X4(Matrix4X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -414,10 +524,21 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X4(Matrix4X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -425,10 +546,21 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X4(Matrix4X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -436,10 +568,21 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X4(Matrix4X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4)); /// /// Converts a matrix of into one with an underlying type of . @@ -447,10 +590,21 @@ public static explicit operator Matrix4X4(Matrix4X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix4X4(Matrix4X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix4X4(Matrix4X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4)); } public static partial class Matrix4X4 diff --git a/sources/Maths/Maths/Matrix5X4.cs b/sources/Maths/Maths/Matrix5X4.cs index 8f624e5b99..71ab1fd0eb 100644 --- a/sources/Maths/Maths/Matrix5X4.cs +++ b/sources/Maths/Maths/Matrix5X4.cs @@ -127,15 +127,5 @@ public readonly bool IsIdentity return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3 + value1.W * value2.Row4 + value2.Row5; } - - /// - /// Returns this matrix casted to - /// - /// The type to cast to - /// The casted matrix - public Matrix5X4 As() where TOther : INumberBase - { - return new(Row1.As(), Row2.As(), Row3.As(), Row4.As(), Row5.As()); - } } } diff --git a/sources/Maths/Maths/Matrix5X4.gen.cs b/sources/Maths/Maths/Matrix5X4.gen.cs index 91ae1f4986..a294471477 100644 --- a/sources/Maths/Maths/Matrix5X4.gen.cs +++ b/sources/Maths/Maths/Matrix5X4.gen.cs @@ -208,6 +208,27 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4, Row5); + /// Converts the components of this vector to another type. + public static Matrix5X4 CreateChecked(Matrix5X4 other) + where TOther : INumberBase => + new(Vector4D.CreateChecked(other.Row1), Vector4D.CreateChecked(other.Row2), Vector4D.CreateChecked(other.Row3), Vector4D.CreateChecked(other.Row4), Vector4D.CreateChecked(other.Row5)); + + /// Converts the components of this vector to another type. + public static Matrix5X4 CreateSaturating(Matrix5X4 other) + where TOther : INumberBase => + new(Vector4D.CreateSaturating(other.Row1), Vector4D.CreateSaturating(other.Row2), Vector4D.CreateSaturating(other.Row3), Vector4D.CreateSaturating(other.Row4), Vector4D.CreateSaturating(other.Row5)); + + /// Converts the components of this vector to another type. + public static Matrix5X4 CreateTruncating(Matrix5X4 other) + where TOther : INumberBase => + new(Vector4D.CreateTruncating(other.Row1), Vector4D.CreateTruncating(other.Row2), Vector4D.CreateTruncating(other.Row3), Vector4D.CreateTruncating(other.Row4), Vector4D.CreateTruncating(other.Row5)); + + /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + public Matrix5X4 As() + where TOther : INumberBase => + new(Row1.As(), Row2.As(), Row3.As(), Row4.As(), Row5.As()); + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. @@ -289,17 +310,30 @@ public override string ToString() => left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4, left.M51 * right.Row1 + left.M52 * right.Row2 + left.M53 * right.Row3 + left.M54 * right.Row4); + /// /// Converts a matrix of into one with an underlying type of . /// /// The source matrix. /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As(), - from.Row5.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4), + Vector4D.CreateTruncating(from.Row5)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix5X4(Matrix5X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4), + Vector4D.CreateChecked(from.Row5)); /// /// Converts a matrix of into one with an underlying type of . @@ -307,11 +341,23 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As(), - from.Row5.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4), + Vector4D.CreateTruncating(from.Row5)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix5X4(Matrix5X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4), + Vector4D.CreateChecked(from.Row5)); /// /// Converts a matrix of into one with an underlying type of . @@ -319,11 +365,23 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As(), - from.Row5.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4), + Vector4D.CreateTruncating(from.Row5)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix5X4(Matrix5X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4), + Vector4D.CreateChecked(from.Row5)); /// /// Converts a matrix of into one with an underlying type of . @@ -331,11 +389,23 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As(), - from.Row5.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4), + Vector4D.CreateTruncating(from.Row5)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix5X4(Matrix5X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4), + Vector4D.CreateChecked(from.Row5)); /// /// Converts a matrix of into one with an underlying type of . @@ -343,11 +413,23 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As(), - from.Row5.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4), + Vector4D.CreateTruncating(from.Row5)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix5X4(Matrix5X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4), + Vector4D.CreateChecked(from.Row5)); /// /// Converts a matrix of into one with an underlying type of . @@ -355,11 +437,23 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As(), - from.Row5.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4), + Vector4D.CreateTruncating(from.Row5)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix5X4(Matrix5X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4), + Vector4D.CreateChecked(from.Row5)); /// /// Converts a matrix of into one with an underlying type of . @@ -367,11 +461,23 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As(), - from.Row5.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4), + Vector4D.CreateTruncating(from.Row5)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix5X4(Matrix5X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4), + Vector4D.CreateChecked(from.Row5)); /// /// Converts a matrix of into one with an underlying type of . @@ -379,11 +485,23 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As(), - from.Row5.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4), + Vector4D.CreateTruncating(from.Row5)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix5X4(Matrix5X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4), + Vector4D.CreateChecked(from.Row5)); /// /// Converts a matrix of into one with an underlying type of . @@ -391,11 +509,23 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As(), - from.Row5.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4), + Vector4D.CreateTruncating(from.Row5)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix5X4(Matrix5X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4), + Vector4D.CreateChecked(from.Row5)); /// /// Converts a matrix of into one with an underlying type of . @@ -403,11 +533,23 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As(), - from.Row5.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4), + Vector4D.CreateTruncating(from.Row5)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix5X4(Matrix5X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4), + Vector4D.CreateChecked(from.Row5)); /// /// Converts a matrix of into one with an underlying type of . @@ -415,11 +557,23 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As(), - from.Row5.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4), + Vector4D.CreateTruncating(from.Row5)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix5X4(Matrix5X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4), + Vector4D.CreateChecked(from.Row5)); /// /// Converts a matrix of into one with an underlying type of . @@ -427,11 +581,23 @@ public static explicit operator Matrix5X4(Matrix5X4 from) => /// The source matrix. /// The matrix. public static explicit operator Matrix5X4(Matrix5X4 from) => - new(from.Row1.As(), - from.Row2.As(), - from.Row3.As(), - from.Row4.As(), - from.Row5.As()); + new(Vector4D.CreateTruncating(from.Row1), + Vector4D.CreateTruncating(from.Row2), + Vector4D.CreateTruncating(from.Row3), + Vector4D.CreateTruncating(from.Row4), + Vector4D.CreateTruncating(from.Row5)); + + /// + /// Converts a matrix of into one with an underlying type of . + /// + /// The source matrix. + /// The matrix. + public static explicit operator checked Matrix5X4(Matrix5X4 from) => + new(Vector4D.CreateChecked(from.Row1), + Vector4D.CreateChecked(from.Row2), + Vector4D.CreateChecked(from.Row3), + Vector4D.CreateChecked(from.Row4), + Vector4D.CreateChecked(from.Row5)); } public static partial class Matrix5X4 diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index 474b209e2f..09e6b203bc 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -300,19 +300,26 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm /// public override int GetHashCode() => HashCode.Combine(X, Y); - /// Desconstructs a vector into its components. - /// The X component. - /// The Y component. - public void Deconstruct(out T x, out T y) - { - x = X; - y = Y; - } + /// Converts the components of this vector to another type. + public static Vector2D CreateChecked(Vector2D source) + where TOther : INumberBase => + new(T.CreateChecked(source.X), T.CreateChecked(source.Y)); + + /// Converts the components of this vector to another type. + public static Vector2D CreateSaturating(Vector2D source) + where TOther : INumberBase => + new(T.CreateSaturating(source.X), T.CreateSaturating(source.Y)); /// Converts the components of this vector to another type. + public static Vector2D CreateTruncating(Vector2D source) + where TOther : INumberBase => + new(T.CreateTruncating(source.X), T.CreateTruncating(source.Y)); + + /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating, or a cast instead.", error: false)] public Vector2D As() where TOther : INumberBase => - new(TOther.CreateSaturating(X), TOther.CreateSaturating(Y)); + Vector2D.CreateTruncating(this); /// Implicitly casts a to a . public static implicit operator Vector2D((T X, T Y) v) => @@ -361,7 +368,15 @@ public static implicit operator (T X, T Y)(Vector2D v) => /// The source vector. /// The vector. public static explicit operator Vector2D(Vector2D from) => - from.As(); + Vector2D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector2D(Vector2D from) => + Vector2D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -369,7 +384,15 @@ public static explicit operator Vector2D(Vector2D from) => /// The source vector. /// The vector. public static explicit operator Vector2D(Vector2D from) => - from.As(); + Vector2D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector2D(Vector2D from) => + Vector2D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -377,7 +400,15 @@ public static explicit operator Vector2D(Vector2D from) => /// The source vector. /// The vector. public static explicit operator Vector2D(Vector2D from) => - from.As(); + Vector2D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector2D(Vector2D from) => + Vector2D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -385,7 +416,15 @@ public static explicit operator Vector2D(Vector2D from) => /// The source vector. /// The vector. public static explicit operator Vector2D(Vector2D from) => - from.As(); + Vector2D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector2D(Vector2D from) => + Vector2D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -393,7 +432,15 @@ public static explicit operator Vector2D(Vector2D from) => /// The source vector. /// The vector. public static explicit operator Vector2D(Vector2D from) => - from.As(); + Vector2D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector2D(Vector2D from) => + Vector2D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -401,7 +448,15 @@ public static explicit operator Vector2D(Vector2D from) => /// The source vector. /// The vector. public static explicit operator Vector2D(Vector2D from) => - from.As(); + Vector2D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector2D(Vector2D from) => + Vector2D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -409,7 +464,15 @@ public static explicit operator Vector2D(Vector2D from) => /// The source vector. /// The vector. public static explicit operator Vector2D(Vector2D from) => - from.As(); + Vector2D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector2D(Vector2D from) => + Vector2D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -417,7 +480,15 @@ public static explicit operator Vector2D(Vector2D from) => /// The source vector. /// The vector. public static explicit operator Vector2D(Vector2D from) => - from.As(); + Vector2D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector2D(Vector2D from) => + Vector2D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -425,7 +496,15 @@ public static explicit operator Vector2D(Vector2D from) => /// The source vector. /// The vector. public static explicit operator Vector2D(Vector2D from) => - from.As(); + Vector2D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector2D(Vector2D from) => + Vector2D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -433,7 +512,15 @@ public static explicit operator Vector2D(Vector2D from) => /// The source vector. /// The vector. public static explicit operator Vector2D(Vector2D from) => - from.As(); + Vector2D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector2D(Vector2D from) => + Vector2D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -441,7 +528,15 @@ public static explicit operator Vector2D(Vector2D from) => /// The source vector. /// The vector. public static explicit operator Vector2D(Vector2D from) => - from.As(); + Vector2D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector2D(Vector2D from) => + Vector2D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -449,7 +544,15 @@ public static explicit operator Vector2D(Vector2D from) => /// The source vector. /// The vector. public static explicit operator Vector2D(Vector2D from) => - from.As(); + Vector2D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector2D(Vector2D from) => + Vector2D.CreateChecked(from); } public static partial class Vector2D @@ -468,6 +571,16 @@ public static partial class Vector2D public T LengthSquared => Vector2D.Dot(vector, vector); } + /// Desconstructs a vector into its components. + /// The X component. + /// The Y component. + public static void Deconstruct(this Vector2D vector, out T x, out T y) + where T : INumberBase + { + x = vector.X; + y = vector.Y; + } + /// Computes the dot product of two vectors. public static T Dot(this Vector2D left, Vector2D right) where T : INumberBase => diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index e915fd65bf..cb34c6f13f 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -337,21 +337,26 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm /// public override int GetHashCode() => HashCode.Combine(X, Y, Z); - /// Desconstructs a vector into its components. - /// The X component. - /// The Y component. - /// The Z component. - public void Deconstruct(out T x, out T y, out T z) - { - x = X; - y = Y; - z = Z; - } + /// Converts the components of this vector to another type. + public static Vector3D CreateChecked(Vector3D source) + where TOther : INumberBase => + new(T.CreateChecked(source.X), T.CreateChecked(source.Y), T.CreateChecked(source.Z)); + + /// Converts the components of this vector to another type. + public static Vector3D CreateSaturating(Vector3D source) + where TOther : INumberBase => + new(T.CreateSaturating(source.X), T.CreateSaturating(source.Y), T.CreateSaturating(source.Z)); + + /// Converts the components of this vector to another type. + public static Vector3D CreateTruncating(Vector3D source) + where TOther : INumberBase => + new(T.CreateTruncating(source.X), T.CreateTruncating(source.Y), T.CreateTruncating(source.Z)); /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating, or a cast instead.", error: false)] public Vector3D As() where TOther : INumberBase => - new(TOther.CreateSaturating(X), TOther.CreateSaturating(Y), TOther.CreateSaturating(Z)); + Vector3D.CreateTruncating(this); /// Implicitly casts a to a . public static implicit operator Vector3D((T X, T Y, T Z) v) => @@ -400,7 +405,15 @@ public static implicit operator (T X, T Y, T Z)(Vector3D v) => /// The source vector. /// The vector. public static explicit operator Vector3D(Vector3D from) => - from.As(); + Vector3D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector3D(Vector3D from) => + Vector3D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -408,7 +421,15 @@ public static explicit operator Vector3D(Vector3D from) => /// The source vector. /// The vector. public static explicit operator Vector3D(Vector3D from) => - from.As(); + Vector3D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector3D(Vector3D from) => + Vector3D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -416,7 +437,15 @@ public static explicit operator Vector3D(Vector3D from) => /// The source vector. /// The vector. public static explicit operator Vector3D(Vector3D from) => - from.As(); + Vector3D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector3D(Vector3D from) => + Vector3D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -424,7 +453,15 @@ public static explicit operator Vector3D(Vector3D from) => /// The source vector. /// The vector. public static explicit operator Vector3D(Vector3D from) => - from.As(); + Vector3D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector3D(Vector3D from) => + Vector3D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -432,7 +469,15 @@ public static explicit operator Vector3D(Vector3D from) => /// The source vector. /// The vector. public static explicit operator Vector3D(Vector3D from) => - from.As(); + Vector3D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector3D(Vector3D from) => + Vector3D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -440,7 +485,15 @@ public static explicit operator Vector3D(Vector3D from) => /// The source vector. /// The vector. public static explicit operator Vector3D(Vector3D from) => - from.As(); + Vector3D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector3D(Vector3D from) => + Vector3D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -448,7 +501,15 @@ public static explicit operator Vector3D(Vector3D from) => /// The source vector. /// The vector. public static explicit operator Vector3D(Vector3D from) => - from.As(); + Vector3D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector3D(Vector3D from) => + Vector3D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -456,7 +517,15 @@ public static explicit operator Vector3D(Vector3D from) => /// The source vector. /// The vector. public static explicit operator Vector3D(Vector3D from) => - from.As(); + Vector3D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector3D(Vector3D from) => + Vector3D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -464,7 +533,15 @@ public static explicit operator Vector3D(Vector3D from) => /// The source vector. /// The vector. public static explicit operator Vector3D(Vector3D from) => - from.As(); + Vector3D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector3D(Vector3D from) => + Vector3D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -472,7 +549,15 @@ public static explicit operator Vector3D(Vector3D from) => /// The source vector. /// The vector. public static explicit operator Vector3D(Vector3D from) => - from.As(); + Vector3D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector3D(Vector3D from) => + Vector3D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -480,7 +565,15 @@ public static explicit operator Vector3D(Vector3D from) => /// The source vector. /// The vector. public static explicit operator Vector3D(Vector3D from) => - from.As(); + Vector3D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector3D(Vector3D from) => + Vector3D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -488,7 +581,15 @@ public static explicit operator Vector3D(Vector3D from) => /// The source vector. /// The vector. public static explicit operator Vector3D(Vector3D from) => - from.As(); + Vector3D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector3D(Vector3D from) => + Vector3D.CreateChecked(from); } public static partial class Vector3D @@ -507,6 +608,18 @@ public static partial class Vector3D public T LengthSquared => Vector3D.Dot(vector, vector); } + /// Desconstructs a vector into its components. + /// The X component. + /// The Y component. + /// The Z component. + public static void Deconstruct(this Vector3D vector, out T x, out T y, out T z) + where T : INumberBase + { + x = vector.X; + y = vector.Y; + z = vector.Z; + } + /// Computes the dot product of two vectors. public static T Dot(this Vector3D left, Vector3D right) where T : INumberBase => diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index 04cf959ede..bfdfbecb07 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -374,23 +374,26 @@ static bool IParsable>.TryParse([NotNullWhen(true)] string? s, IForm /// public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); - /// Desconstructs a vector into its components. - /// The X component. - /// The Y component. - /// The Z component. - /// The W component. - public void Deconstruct(out T x, out T y, out T z, out T w) - { - x = X; - y = Y; - z = Z; - w = W; - } + /// Converts the components of this vector to another type. + public static Vector4D CreateChecked(Vector4D source) + where TOther : INumberBase => + new(T.CreateChecked(source.X), T.CreateChecked(source.Y), T.CreateChecked(source.Z), T.CreateChecked(source.W)); + + /// Converts the components of this vector to another type. + public static Vector4D CreateSaturating(Vector4D source) + where TOther : INumberBase => + new(T.CreateSaturating(source.X), T.CreateSaturating(source.Y), T.CreateSaturating(source.Z), T.CreateSaturating(source.W)); /// Converts the components of this vector to another type. + public static Vector4D CreateTruncating(Vector4D source) + where TOther : INumberBase => + new(T.CreateTruncating(source.X), T.CreateTruncating(source.Y), T.CreateTruncating(source.Z), T.CreateTruncating(source.W)); + + /// Converts the components of this vector to another type. + [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating, or a cast instead.", error: false)] public Vector4D As() where TOther : INumberBase => - new(TOther.CreateSaturating(X), TOther.CreateSaturating(Y), TOther.CreateSaturating(Z), TOther.CreateSaturating(W)); + Vector4D.CreateTruncating(this); /// Implicitly casts a to a . public static implicit operator Vector4D((T X, T Y, T Z, T W) v) => @@ -439,7 +442,15 @@ public static implicit operator (T X, T Y, T Z, T W)(Vector4D v) => /// The source vector. /// The vector. public static explicit operator Vector4D(Vector4D from) => - from.As(); + Vector4D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector4D(Vector4D from) => + Vector4D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -447,7 +458,15 @@ public static explicit operator Vector4D(Vector4D from) => /// The source vector. /// The vector. public static explicit operator Vector4D(Vector4D from) => - from.As(); + Vector4D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector4D(Vector4D from) => + Vector4D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -455,7 +474,15 @@ public static explicit operator Vector4D(Vector4D from) => /// The source vector. /// The vector. public static explicit operator Vector4D(Vector4D from) => - from.As(); + Vector4D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector4D(Vector4D from) => + Vector4D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -463,7 +490,15 @@ public static explicit operator Vector4D(Vector4D from) => /// The source vector. /// The vector. public static explicit operator Vector4D(Vector4D from) => - from.As(); + Vector4D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector4D(Vector4D from) => + Vector4D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -471,7 +506,15 @@ public static explicit operator Vector4D(Vector4D from) => /// The source vector. /// The vector. public static explicit operator Vector4D(Vector4D from) => - from.As(); + Vector4D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector4D(Vector4D from) => + Vector4D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -479,7 +522,15 @@ public static explicit operator Vector4D(Vector4D from) => /// The source vector. /// The vector. public static explicit operator Vector4D(Vector4D from) => - from.As(); + Vector4D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector4D(Vector4D from) => + Vector4D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -487,7 +538,15 @@ public static explicit operator Vector4D(Vector4D from) => /// The source vector. /// The vector. public static explicit operator Vector4D(Vector4D from) => - from.As(); + Vector4D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector4D(Vector4D from) => + Vector4D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -495,7 +554,15 @@ public static explicit operator Vector4D(Vector4D from) => /// The source vector. /// The vector. public static explicit operator Vector4D(Vector4D from) => - from.As(); + Vector4D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector4D(Vector4D from) => + Vector4D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -503,7 +570,15 @@ public static explicit operator Vector4D(Vector4D from) => /// The source vector. /// The vector. public static explicit operator Vector4D(Vector4D from) => - from.As(); + Vector4D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector4D(Vector4D from) => + Vector4D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -511,7 +586,15 @@ public static explicit operator Vector4D(Vector4D from) => /// The source vector. /// The vector. public static explicit operator Vector4D(Vector4D from) => - from.As(); + Vector4D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector4D(Vector4D from) => + Vector4D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -519,7 +602,15 @@ public static explicit operator Vector4D(Vector4D from) => /// The source vector. /// The vector. public static explicit operator Vector4D(Vector4D from) => - from.As(); + Vector4D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector4D(Vector4D from) => + Vector4D.CreateChecked(from); /// /// Converts a vector of into one with an underlying type of . @@ -527,7 +618,15 @@ public static explicit operator Vector4D(Vector4D from) => /// The source vector. /// The vector. public static explicit operator Vector4D(Vector4D from) => - from.As(); + Vector4D.CreateTruncating(from); + + /// + /// Converts a vector of into one with an underlying type of . + /// + /// The source vector. + /// The vector. + public static explicit operator checked Vector4D(Vector4D from) => + Vector4D.CreateChecked(from); } public static partial class Vector4D @@ -546,6 +645,20 @@ public static partial class Vector4D public T LengthSquared => Vector4D.Dot(vector, vector); } + /// Desconstructs a vector into its components. + /// The X component. + /// The Y component. + /// The Z component. + /// The W component. + public static void Deconstruct(this Vector4D vector, out T x, out T y, out T z, out T w) + where T : INumberBase + { + x = vector.X; + y = vector.Y; + z = vector.Z; + w = vector.W; + } + /// Computes the dot product of two vectors. public static T Dot(this Vector4D left, Vector4D right) where T : INumberBase => From ac8e94ef8cfef1e8c0e16cf60840b3880e69936c Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 16:47:12 -0700 Subject: [PATCH 46/67] Handle IsIdentity and GetDeterminant errors. --- sources/Maths/Maths/Matrix2X2.cs | 10 ++-------- sources/Maths/Maths/Matrix2X2.gen.cs | 4 ++++ sources/Maths/Maths/Matrix2X3.cs | 6 +----- sources/Maths/Maths/Matrix2X4.cs | 7 +------ sources/Maths/Maths/Matrix3X2.cs | 4 +++- sources/Maths/Maths/Matrix3X3.cs | 15 +++------------ sources/Maths/Maths/Matrix3X3.gen.cs | 4 ++++ sources/Maths/Maths/Matrix3X4.cs | 9 +-------- sources/Maths/Maths/Matrix4X2.cs | 7 +------ sources/Maths/Maths/Matrix4X3.cs | 9 +-------- sources/Maths/Maths/Matrix4X4.cs | 21 ++++----------------- sources/Maths/Maths/Matrix4X4.gen.cs | 4 ++++ sources/Maths/Maths/Matrix5X4.cs | 13 +------------ 13 files changed, 30 insertions(+), 83 deletions(-) diff --git a/sources/Maths/Maths/Matrix2X2.cs b/sources/Maths/Maths/Matrix2X2.cs index c1af4faa51..5085e8de98 100644 --- a/sources/Maths/Maths/Matrix2X2.cs +++ b/sources/Maths/Maths/Matrix2X2.cs @@ -54,12 +54,6 @@ public Matrix2X2(Matrix4X2 value) Row2 = new(value.M21, value.M22); } - /// Returns whether the matrix is the identity matrix. - public readonly bool IsIdentity - => Scalar.Equal(M11, Scalar.One) && - Scalar.Equal(M22, Scalar.One) && // Check diagonal element first for early out. - Scalar.Equal(M12, Scalar.Zero) && Scalar.Equal(M21, Scalar.Zero); - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -76,8 +70,8 @@ public readonly T GetDeterminant() // | a b | // | c d | = ad - bc - T a = M11, b = M12; - T d = M21, c = M22; + T a = Row1.X, b = Row1.Y; + T d = Row2.X, c = Row1.Y; return Scalar.Subtract(Scalar.Multiply(a, d), Scalar.Multiply(b, c)); } diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index 0a61042a45..16706b400d 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -14,6 +14,10 @@ public partial struct Matrix2X2 : new(T.MultiplicativeIdentity, T.Zero), new(T.Zero, T.MultiplicativeIdentity)); + /// Returns whether the matrix is the identity matrix. + [IgnoreDataMember] + public readonly bool IsIdentity => this == Identity; + /// The 1st row of the matrix represented as a vector. [IgnoreDataMember] public Vector2D Row1; diff --git a/sources/Maths/Maths/Matrix2X3.cs b/sources/Maths/Maths/Matrix2X3.cs index 75e94fa6ed..6309127676 100644 --- a/sources/Maths/Maths/Matrix2X3.cs +++ b/sources/Maths/Maths/Matrix2X3.cs @@ -65,11 +65,7 @@ public Matrix2X3(Matrix4X2 value) /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] - public readonly bool IsIdentity - => Scalar.Equal(M11, Scalar.One) && - Scalar.Equal(M22, Scalar.One) && // Check diagonal element first for early out. - Scalar.Equal(M12, Scalar.Zero) && Scalar.Equal(M13, Scalar.Zero) && - Scalar.Equal(M21, Scalar.Zero) && Scalar.Equal(M23, Scalar.Zero); + public readonly bool IsIdentity => this == Identity; /// Multiplies a vector by a matrix. /// The vector. diff --git a/sources/Maths/Maths/Matrix2X4.cs b/sources/Maths/Maths/Matrix2X4.cs index fb82209033..72401a53c5 100644 --- a/sources/Maths/Maths/Matrix2X4.cs +++ b/sources/Maths/Maths/Matrix2X4.cs @@ -65,12 +65,7 @@ public Matrix2X4(Matrix4X2 value) /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] - public readonly bool IsIdentity - => Scalar.Equal(M11, Scalar.One) && - Scalar.Equal(M22, Scalar.One) && // Check diagonal element first for early out. - Scalar.Equal(M12, Scalar.Zero) && Scalar.Equal(M13, Scalar.Zero) && - Scalar.Equal(M14, Scalar.Zero) && Scalar.Equal(M21, Scalar.Zero) && - Scalar.Equal(M23, Scalar.Zero) && Scalar.Equal(M24, Scalar.Zero); + public readonly bool IsIdentity => this == Identity; /// Multiplies a vector by a matrix. /// The vector. diff --git a/sources/Maths/Maths/Matrix3X2.cs b/sources/Maths/Maths/Matrix3X2.cs index 95bd53d619..fe2716e323 100644 --- a/sources/Maths/Maths/Matrix3X2.cs +++ b/sources/Maths/Maths/Matrix3X2.cs @@ -102,7 +102,9 @@ public readonly T GetDeterminant() // // Collapse out the constants and oh look, this is just a 2x2 determinant! - return Scalar.Subtract(Scalar.Multiply(M11, M22), Scalar.Multiply(M21, M12)); + return Scalar.Subtract( + Scalar.Multiply(Row1.X, Row2.Y), + Scalar.Multiply(Row2.X, Row1.Y)); } /// diff --git a/sources/Maths/Maths/Matrix3X3.cs b/sources/Maths/Maths/Matrix3X3.cs index 27cf5a9bf6..39fff98e60 100644 --- a/sources/Maths/Maths/Matrix3X3.cs +++ b/sources/Maths/Maths/Matrix3X3.cs @@ -77,15 +77,6 @@ public Matrix3X3(Matrix4X4 value) Row3 = new(value.M31, value.M32, value.M33); } - /// Returns whether the matrix is the identity matrix. - [IgnoreDataMember] - public readonly bool IsIdentity - => Scalar.Equal(M11, Scalar.One) && Scalar.Equal(M22, Scalar.One) && - Scalar.Equal(M33, Scalar.One) && // Check diagonal element first for early out. - Scalar.Equal(M12, Scalar.Zero) && Scalar.Equal(M13, Scalar.Zero) && - Scalar.Equal(M21, Scalar.Zero) && Scalar.Equal(M23, Scalar.Zero) && - Scalar.Equal(M31, Scalar.Zero) && Scalar.Equal(M32, Scalar.Zero); - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -103,9 +94,9 @@ public readonly T GetDeterminant() // | d e f | = ( a ( ei - fh ) - b ( di - fg ) + c ( dh - eg ) ) // | g h i | - T a = M11, b = M12, c = M13; - T d = M21, e = M22, f = M23; - T g = M31, h = M32, i = M33; + T a = Row1.X, b = Row1.Y, c = Row1.Z; + T d = Row2.X, e = Row2.Y, f = Row2.Z; + T g = Row3.X, h = Row3.Y, i = Row3.Z; return Scalar.Add( Scalar.Subtract( diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index 4b039ee5b5..33e2f9db96 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -15,6 +15,10 @@ public partial struct Matrix3X3 : new(T.Zero, T.MultiplicativeIdentity, T.Zero), new(T.Zero, T.Zero, T.MultiplicativeIdentity)); + /// Returns whether the matrix is the identity matrix. + [IgnoreDataMember] + public readonly bool IsIdentity => this == Identity; + /// The 1st row of the matrix represented as a vector. [IgnoreDataMember] public Vector3D Row1; diff --git a/sources/Maths/Maths/Matrix3X4.cs b/sources/Maths/Maths/Matrix3X4.cs index ed6c1c1193..84076d5572 100644 --- a/sources/Maths/Maths/Matrix3X4.cs +++ b/sources/Maths/Maths/Matrix3X4.cs @@ -80,14 +80,7 @@ public Matrix3X4(Matrix4X2 value) /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] - public readonly bool IsIdentity - => Scalar.Equal(M11, Scalar.One) && Scalar.Equal(M22, Scalar.One) && - Scalar.Equal(M33, Scalar.One) && // Check diagonal element first for early out. - Scalar.Equal(M12, Scalar.Zero) && Scalar.Equal(M13, Scalar.Zero) && - Scalar.Equal(M14, Scalar.Zero) && Scalar.Equal(M21, Scalar.Zero) && - Scalar.Equal(M23, Scalar.Zero) && Scalar.Equal(M24, Scalar.Zero) && - Scalar.Equal(M31, Scalar.Zero) && Scalar.Equal(M32, Scalar.Zero) && - Scalar.Equal(M34, Scalar.Zero); + public readonly bool IsIdentity => this == Identity; /// Multiplies a vector by a matrix. /// The vector. diff --git a/sources/Maths/Maths/Matrix4X2.cs b/sources/Maths/Maths/Matrix4X2.cs index 32aa778cd5..6086ca84b4 100644 --- a/sources/Maths/Maths/Matrix4X2.cs +++ b/sources/Maths/Maths/Matrix4X2.cs @@ -78,12 +78,7 @@ public Matrix4X2(Matrix2X4 value) /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] - public readonly bool IsIdentity - => Scalar.Equal(M11, Scalar.One) && - Scalar.Equal(M22, Scalar.One) && // Check diagonal element first for early out. - Scalar.Equal(M12, Scalar.Zero) && Scalar.Equal(M21, Scalar.Zero) && - Scalar.Equal(M31, Scalar.Zero) && Scalar.Equal(M32, Scalar.Zero) && - Scalar.Equal(M41, Scalar.Zero) && Scalar.Equal(M42, Scalar.Zero); + public readonly bool IsIdentity => this == Identity; /// Multiplies a vector by a matrix. /// The vector. diff --git a/sources/Maths/Maths/Matrix4X3.cs b/sources/Maths/Maths/Matrix4X3.cs index b6d740fcc5..1611662778 100644 --- a/sources/Maths/Maths/Matrix4X3.cs +++ b/sources/Maths/Maths/Matrix4X3.cs @@ -99,14 +99,7 @@ public Matrix4X3(Matrix4X4 value) /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] - public readonly bool IsIdentity - => Scalar.Equal(M11, Scalar.One) && Scalar.Equal(M22, Scalar.One) && - Scalar.Equal(M33, Scalar.One) && // Check diagonal element first for early out. - Scalar.Equal(M12, Scalar.Zero) && Scalar.Equal(M13, Scalar.Zero) && - Scalar.Equal(M21, Scalar.Zero) && Scalar.Equal(M23, Scalar.Zero) && - Scalar.Equal(M31, Scalar.Zero) && Scalar.Equal(M32, Scalar.Zero) && - Scalar.Equal(M41, Scalar.Zero) && Scalar.Equal(M42, Scalar.Zero) && - Scalar.Equal(M43, Scalar.Zero); + public readonly bool IsIdentity => this == Identity; /// Multiplies a vector by a matrix. /// The vector. diff --git a/sources/Maths/Maths/Matrix4X4.cs b/sources/Maths/Maths/Matrix4X4.cs index 61118d8d30..c951ad86b9 100644 --- a/sources/Maths/Maths/Matrix4X4.cs +++ b/sources/Maths/Maths/Matrix4X4.cs @@ -74,19 +74,6 @@ public Matrix4X4(Matrix4X2 value) Row4 = new(value.M41, value.M42, default, Scalar.One); } - /// Returns whether the matrix is the identity matrix. - [IgnoreDataMember] - public readonly bool IsIdentity - => Scalar.Equal(M11, Scalar.One) && Scalar.Equal(M22, Scalar.One) && - Scalar.Equal(M33, Scalar.One) && - Scalar.Equal(M44, Scalar.One) && // Check diagonal element first for early out. - Scalar.Equal(M12, Scalar.Zero) && Scalar.Equal(M13, Scalar.Zero) && - Scalar.Equal(M14, Scalar.Zero) && Scalar.Equal(M21, Scalar.Zero) && - Scalar.Equal(M23, Scalar.Zero) && Scalar.Equal(M24, Scalar.Zero) && - Scalar.Equal(M31, Scalar.Zero) && Scalar.Equal(M32, Scalar.Zero) && - Scalar.Equal(M34, Scalar.Zero) && Scalar.Equal(M41, Scalar.Zero) && - Scalar.Equal(M42, Scalar.Zero) && Scalar.Equal(M43, Scalar.Zero); - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -128,10 +115,10 @@ public readonly T GetDeterminant() // add: 6 + 8 + 3 = 17 // mul: 12 + 16 = 28 - T a = M11, b = M12, c = M13, d = M14; - T e = M21, f = M22, g = M23, h = M24; - T i = M31, j = M32, k = M33, l = M34; - T m = M41, n = M42, o = M43, p = M44; + T a = Row1.X, b = Row1.Y, c = Row1.Z, d = Row1.W; + T e = Row2.X, f = Row2.Y, g = Row2.Z, h = Row2.W; + T i = Row3.X, j = Row3.Y, k = Row3.Z, l = Row3.W; + T m = Row4.X, n = Row4.Y, o = Row4.Z, p = Row4.W; T kp_lo = Scalar.Subtract(Scalar.Multiply(k, p), Scalar.Multiply(l, o)); T jp_ln = Scalar.Subtract(Scalar.Multiply(j, p), Scalar.Multiply(l, n)); diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index 046b54feda..5346ae1daf 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -16,6 +16,10 @@ public partial struct Matrix4X4 : new(T.Zero, T.Zero, T.MultiplicativeIdentity, T.Zero), new(T.Zero, T.Zero, T.Zero, T.MultiplicativeIdentity)); + /// Returns whether the matrix is the identity matrix. + [IgnoreDataMember] + public readonly bool IsIdentity => this == Identity; + /// The 1st row of the matrix represented as a vector. [IgnoreDataMember] public Vector4D Row1; diff --git a/sources/Maths/Maths/Matrix5X4.cs b/sources/Maths/Maths/Matrix5X4.cs index 71ab1fd0eb..0d6e940a43 100644 --- a/sources/Maths/Maths/Matrix5X4.cs +++ b/sources/Maths/Maths/Matrix5X4.cs @@ -105,18 +105,7 @@ public Matrix5X4(Matrix4X2 value) /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] - public readonly bool IsIdentity - => Scalar.Equal(M11, Scalar.One) && Scalar.Equal(M22, Scalar.One) && - Scalar.Equal(M33, Scalar.One) && - Scalar.Equal(M44, Scalar.One) && // Check diagonal element first for early out. - Scalar.Equal(M12, Scalar.Zero) && Scalar.Equal(M13, Scalar.Zero) && - Scalar.Equal(M14, Scalar.Zero) && Scalar.Equal(M21, Scalar.Zero) && - Scalar.Equal(M23, Scalar.Zero) && Scalar.Equal(M24, Scalar.Zero) && - Scalar.Equal(M31, Scalar.Zero) && Scalar.Equal(M32, Scalar.Zero) && - Scalar.Equal(M34, Scalar.Zero) && Scalar.Equal(M41, Scalar.Zero) && - Scalar.Equal(M42, Scalar.Zero) && Scalar.Equal(M43, Scalar.Zero) && - Scalar.Equal(M51, Scalar.Zero) && Scalar.Equal(M52, Scalar.Zero) && - Scalar.Equal(M53, Scalar.Zero) && Scalar.Equal(M54, Scalar.Zero); + public readonly bool IsIdentity => this == Identity; /// Multiplies a vector by a matrix. /// The vector. From f71206cc6cb9313b7b6c9f978b6a1b08289d8eb6 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 16:58:16 -0700 Subject: [PATCH 47/67] Use T.Zero instead of default to avoid NRE. --- sources/Maths/Maths/Matrix2X3.cs | 8 +++--- sources/Maths/Maths/Matrix2X4.cs | 20 +++++++-------- sources/Maths/Maths/Matrix3X3.cs | 12 ++++----- sources/Maths/Maths/Matrix3X4.cs | 30 +++++++++++----------- sources/Maths/Maths/Matrix4X3.cs | 12 ++++----- sources/Maths/Maths/Matrix4X4.Ops.cs | 12 ++++----- sources/Maths/Maths/Matrix4X4.cs | 32 +++++++++++------------ sources/Maths/Maths/Matrix5X4.cs | 38 ++++++++++++++-------------- 8 files changed, 82 insertions(+), 82 deletions(-) diff --git a/sources/Maths/Maths/Matrix2X3.cs b/sources/Maths/Maths/Matrix2X3.cs index 6309127676..e1e4df98a8 100644 --- a/sources/Maths/Maths/Matrix2X3.cs +++ b/sources/Maths/Maths/Matrix2X3.cs @@ -24,8 +24,8 @@ public partial struct Matrix2X3 /// The source . public Matrix2X3(Matrix3X2 value) { - Row1 = new(value.M11, value.M12, default); - Row2 = new(value.M21, value.M22, default); + Row1 = new(value.M11, value.M12, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero); } /// Constructs a from the given . @@ -56,8 +56,8 @@ public Matrix2X3(Matrix2X4 value) /// The source . public Matrix2X3(Matrix4X2 value) { - Row1 = new Vector3D(value.M11, value.M12, default); - Row2 = new Vector3D(value.M21, value.M22, default); + Row1 = new Vector3D(value.M11, value.M12, T.Zero); + Row2 = new Vector3D(value.M21, value.M22, T.Zero); } /// Returns the multiplicative identity matrix. diff --git a/sources/Maths/Maths/Matrix2X4.cs b/sources/Maths/Maths/Matrix2X4.cs index 72401a53c5..838b0902cb 100644 --- a/sources/Maths/Maths/Matrix2X4.cs +++ b/sources/Maths/Maths/Matrix2X4.cs @@ -16,24 +16,24 @@ public partial struct Matrix2X4 { private static readonly Matrix2X4 _identity = new ( - Scalar.One, Scalar.Zero, Scalar.Zero, Scalar.Zero, - Scalar.Zero, Scalar.One, Scalar.Zero, Scalar.Zero + T.One, T.Zero, T.Zero, T.Zero, + T.Zero, T.One, T.Zero, T.Zero ); /// Constructs a from the given . /// The source . public Matrix2X4(Matrix3X2 value) { - Row1 = new(value.M11, value.M12, default, default); - Row2 = new(value.M21, value.M22, default, default); + Row1 = new(value.M11, value.M12, T.Zero, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero, T.Zero); } /// Constructs a from the given Matrix4x3. /// The source Matrix4x3. public Matrix2X4(Matrix4X3 value) { - Row1 = new(value.M11, value.M12, value.M13, default); - Row2 = new(value.M21, value.M22, value.M23, default); + Row1 = new(value.M11, value.M12, value.M13, T.Zero); + Row2 = new(value.M21, value.M22, value.M23, T.Zero); } /// Constructs a from the given . @@ -48,16 +48,16 @@ public Matrix2X4(Matrix3X4 value) /// The source . public Matrix2X4(Matrix3X3 value) { - Row1 = new(value.M11, value.M12, value.M13, default); - Row2 = new(value.M21, value.M22, value.M23, default); + Row1 = new(value.M11, value.M12, value.M13, T.Zero); + Row2 = new(value.M21, value.M22, value.M23, T.Zero); } /// Constructs a Matrix2x4 from the given . /// The source . public Matrix2X4(Matrix4X2 value) { - Row1 = new(value.M11, value.M12, default, default); - Row2 = new(value.M21, value.M22, default, default); + Row1 = new(value.M11, value.M12, T.Zero, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero, T.Zero); } /// Returns the multiplicative identity matrix. diff --git a/sources/Maths/Maths/Matrix3X3.cs b/sources/Maths/Maths/Matrix3X3.cs index 39fff98e60..d98120c478 100644 --- a/sources/Maths/Maths/Matrix3X3.cs +++ b/sources/Maths/Maths/Matrix3X3.cs @@ -18,9 +18,9 @@ public partial struct Matrix3X3 /// The source . public Matrix3X3(Matrix3X2 value) { - Row1 = new(value.M11, value.M12, default); - Row2 = new(value.M21, value.M22, default); - Row3 = new(value.M31, value.M32, Scalar.One); + Row1 = new(value.M11, value.M12, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero); + Row3 = new(value.M31, value.M32, T.One); } /// Constructs a from the given . @@ -63,9 +63,9 @@ public Matrix3X3(Matrix2X4 value) /// The source . public Matrix3X3(Matrix4X2 value) { - Row1 = new(value.M11, value.M12, default); - Row2 = new(value.M21, value.M22, default); - Row3 = new(value.M31, value.M32, Scalar.One); + Row1 = new(value.M11, value.M12, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero); + Row3 = new(value.M31, value.M32, T.One); } /// Constructs a from the given . diff --git a/sources/Maths/Maths/Matrix3X4.cs b/sources/Maths/Maths/Matrix3X4.cs index 84076d5572..82ed67a171 100644 --- a/sources/Maths/Maths/Matrix3X4.cs +++ b/sources/Maths/Maths/Matrix3X4.cs @@ -16,27 +16,27 @@ public partial struct Matrix3X4 { private static readonly Matrix3X4 _identity = new ( - Scalar.One, Scalar.Zero, Scalar.Zero, Scalar.Zero, - Scalar.Zero, Scalar.One, Scalar.Zero, Scalar.Zero, - Scalar.Zero, Scalar.Zero, Scalar.One, Scalar.Zero + T.One, T.Zero, T.Zero, T.Zero, + T.Zero, T.One, T.Zero, T.Zero, + T.Zero, T.Zero, T.One, T.Zero ); /// Constructs a from the given . /// The source . public Matrix3X4(Matrix3X2 value) { - Row1 = new(value.M11, value.M12, default, default); - Row2 = new(value.M21, value.M22, default, default); - Row3 = new(value.M31, value.M32, Scalar.One, default); + Row1 = new(value.M11, value.M12, T.Zero, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero, T.Zero); + Row3 = new(value.M31, value.M32, T.One, T.Zero); } /// Constructs a from the given . /// The source . public Matrix3X4(Matrix4X3 value) { - Row1 = new(value.M11, value.M12, value.M13, default); - Row2 = new(value.M21, value.M22, value.M23, default); - Row3 = new(value.M31, value.M32, value.M33, default); + Row1 = new(value.M11, value.M12, value.M13, T.Zero); + Row2 = new(value.M21, value.M22, value.M23, T.Zero); + Row3 = new(value.M31, value.M32, value.M33, T.Zero); } /// Constructs a from the given . @@ -52,9 +52,9 @@ public Matrix3X4(Matrix3X4 value) /// The source . public Matrix3X4(Matrix3X3 value) { - Row1 = new(value.M11, value.M12, value.M13, default); - Row2 = new(value.M21, value.M22, value.M23, default); - Row3 = new(value.M31, value.M32, value.M33, default); + Row1 = new(value.M11, value.M12, value.M13, T.Zero); + Row2 = new(value.M21, value.M22, value.M23, T.Zero); + Row3 = new(value.M31, value.M32, value.M33, T.Zero); } /// Constructs a from the given . @@ -70,9 +70,9 @@ public Matrix3X4(Matrix2X4 value) /// The source . public Matrix3X4(Matrix4X2 value) { - Row1 = new(value.M11, value.M12, default, default); - Row2 = new(value.M21, value.M22, default, default); - Row3 = new(value.M31, value.M32, Scalar.One, default); + Row1 = new(value.M11, value.M12, T.Zero, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero, T.Zero); + Row3 = new(value.M31, value.M32, T.One, T.Zero); } /// Returns the multiplicative identity matrix. diff --git a/sources/Maths/Maths/Matrix4X3.cs b/sources/Maths/Maths/Matrix4X3.cs index 1611662778..607aa46115 100644 --- a/sources/Maths/Maths/Matrix4X3.cs +++ b/sources/Maths/Maths/Matrix4X3.cs @@ -28,10 +28,10 @@ public partial struct Matrix4X3 /// The source . public Matrix4X3(Matrix3X2 value) { - Row1 = new(value.M11, value.M12, default); - Row2 = new(value.M21, value.M22, default); + Row1 = new(value.M11, value.M12, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero); Row3 = Vector3D.UnitZ; - Row4 = new(value.M31, value.M32, default); + Row4 = new(value.M31, value.M32, T.Zero); } /// Constructs a from the given . @@ -78,9 +78,9 @@ public Matrix4X3(Matrix2X4 value) /// The source . public Matrix4X3(Matrix4X2 value) { - Row1 = new(value.M11, value.M12, default); - Row2 = new(value.M21, value.M22, default); - Row3 = new(value.M31, value.M32, default); + Row1 = new(value.M11, value.M12, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero); + Row3 = new(value.M31, value.M32, T.Zero); Row4 = new(value.M41, value.M42, Scalar.One); } diff --git a/sources/Maths/Maths/Matrix4X4.Ops.cs b/sources/Maths/Maths/Matrix4X4.Ops.cs index 450925695d..83e8e3dc15 100644 --- a/sources/Maths/Maths/Matrix4X4.Ops.cs +++ b/sources/Maths/Maths/Matrix4X4.Ops.cs @@ -76,9 +76,9 @@ public static Matrix4X4 CreateBillboard(Vector3D objectPosition, Vector Vector3D yaxis = Vector3D.Cross(zaxis, xaxis); return new( - new(xaxis, default), - new(yaxis, default), - new(zaxis, default), + new(xaxis, T.Zero), + new(yaxis, T.Zero), + new(zaxis, T.Zero), new(objectPosition, Scalar.One)); } @@ -137,9 +137,9 @@ public static Matrix4X4 CreateConstrainedBillboard(Vector3D objectPosit } return new( - new(xaxis, default), - new(yaxis, default), - new(zaxis, default), + new(xaxis, T.Zero), + new(yaxis, T.Zero), + new(zaxis, T.Zero), new(objectPosition, Scalar.One)); } diff --git a/sources/Maths/Maths/Matrix4X4.cs b/sources/Maths/Maths/Matrix4X4.cs index c951ad86b9..b9e06be306 100644 --- a/sources/Maths/Maths/Matrix4X4.cs +++ b/sources/Maths/Maths/Matrix4X4.cs @@ -18,20 +18,20 @@ public partial struct Matrix4X4 /// The source . public Matrix4X4(Matrix3X2 value) { - Row1 = new(value.M11, value.M12, default, default); - Row2 = new(value.M21, value.M22, default, default); - Row4 = new(value.M31, value.M32, default, Scalar.One); - Row3 = new(default, default, Scalar.One, default); + Row1 = new(value.M11, value.M12, T.Zero, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero, T.Zero); + Row4 = new(value.M31, value.M32, T.Zero, T.One); + Row3 = new(T.Zero, T.Zero, T.One, T.Zero); } /// Constructs a from the given . /// The source . public Matrix4X4(Matrix4X3 value) { - Row1 = new(value.M11, value.M12, value.M13, default); - Row2 = new(value.M21, value.M22, value.M23, default); - Row3 = new(value.M31, value.M32, value.M33, default); - Row4 = new(value.M41, value.M42, value.M43, Scalar.One); + Row1 = new(value.M11, value.M12, value.M13, T.Zero); + Row2 = new(value.M21, value.M22, value.M23, T.Zero); + Row3 = new(value.M31, value.M32, value.M33, T.Zero); + Row4 = new(value.M41, value.M42, value.M43, T.One); } /// Constructs a from the given . @@ -48,10 +48,10 @@ public Matrix4X4(Matrix3X4 value) /// The source . public Matrix4X4(Matrix3X3 value) { - Row1 = new(value.M11, value.M12, value.M13, default); - Row2 = new(value.M21, value.M22, value.M23, default); - Row4 = new(value.M31, value.M32, value.M33, Scalar.One); - Row3 = new(default, default, Scalar.One, default); + Row1 = new(value.M11, value.M12, value.M13, T.Zero); + Row2 = new(value.M21, value.M22, value.M23, T.Zero); + Row4 = new(value.M31, value.M32, value.M33, T.One); + Row3 = new(T.Zero, T.Zero, T.One, T.Zero); } /// Constructs a from the given . @@ -68,10 +68,10 @@ public Matrix4X4(Matrix2X4 value) /// The source . public Matrix4X4(Matrix4X2 value) { - Row1 = new(value.M11, value.M12, default, default); - Row2 = new(value.M21, value.M22, default, default); - Row3 = new(value.M31, value.M32, Scalar.One, default); - Row4 = new(value.M41, value.M42, default, Scalar.One); + Row1 = new(value.M11, value.M12, T.Zero, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero, T.Zero); + Row3 = new(value.M31, value.M32, T.One, T.Zero); + Row4 = new(value.M41, value.M42, T.Zero, T.One); } /// Multiplies a vector by a matrix. diff --git a/sources/Maths/Maths/Matrix5X4.cs b/sources/Maths/Maths/Matrix5X4.cs index 0d6e940a43..555c6582b7 100644 --- a/sources/Maths/Maths/Matrix5X4.cs +++ b/sources/Maths/Maths/Matrix5X4.cs @@ -16,20 +16,20 @@ public partial struct Matrix5X4 { private static readonly Matrix5X4 _identity = new ( - Scalar.One, Scalar.Zero, Scalar.Zero, Scalar.Zero, - Scalar.Zero, Scalar.One, Scalar.Zero, Scalar.Zero, - Scalar.Zero, Scalar.Zero, Scalar.One, Scalar.Zero, - Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One, - Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.Zero + T.One, T.Zero, T.Zero, T.Zero, + T.Zero, T.One, T.Zero, T.Zero, + T.Zero, T.Zero, T.One, T.Zero, + T.Zero, T.Zero, T.Zero, T.One, + T.Zero, T.Zero, T.Zero, T.Zero ); /// Constructs a from the given . /// The source . public Matrix5X4(Matrix3X2 value) { - Row1 = new(value.M11, value.M12, default, default); - Row2 = new(value.M21, value.M22, default, default); - Row5 = new(value.M31, value.M32, default, default); + Row1 = new(value.M11, value.M12, T.Zero, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero, T.Zero); + Row5 = new(value.M31, value.M32, T.Zero, T.Zero); Row3 = Vector4D.UnitZ; Row4 = Vector4D.UnitW; } @@ -49,10 +49,10 @@ public Matrix5X4(Matrix4X4 value) /// The source . public Matrix5X4(Matrix4X3 value) { - Row1 = new(value.M11, value.M12, value.M13, default); - Row2 = new(value.M21, value.M22, value.M23, default); - Row3 = new(value.M31, value.M32, value.M33, default); - Row4 = new(value.M41, value.M42, value.M43, Scalar.One); + Row1 = new(value.M11, value.M12, value.M13, T.Zero); + Row2 = new(value.M21, value.M22, value.M23, T.Zero); + Row3 = new(value.M31, value.M32, value.M33, T.Zero); + Row4 = new(value.M41, value.M42, value.M43, T.One); Row5 = default; } @@ -71,9 +71,9 @@ public Matrix5X4(Matrix3X4 value) /// The source . public Matrix5X4(Matrix3X3 value) { - Row1 = new(value.M11, value.M12, value.M13, default); - Row2 = new(value.M21, value.M22, value.M23, default); - Row5 = new(value.M31, value.M32, value.M33, default); + Row1 = new(value.M11, value.M12, value.M13, T.Zero); + Row2 = new(value.M21, value.M22, value.M23, T.Zero); + Row5 = new(value.M31, value.M32, value.M33, T.Zero); Row3 = Vector4D.UnitZ; Row4 = Vector4D.UnitW; } @@ -93,10 +93,10 @@ public Matrix5X4(Matrix2X4 value) /// The source . public Matrix5X4(Matrix4X2 value) { - Row1 = new(value.M11, value.M12, default, default); - Row2 = new(value.M21, value.M22, default, default); - Row3 = new(value.M31, value.M32, Scalar.One, default); - Row4 = new(value.M41, value.M42, default, Scalar.One); + Row1 = new(value.M11, value.M12, T.Zero, T.Zero); + Row2 = new(value.M21, value.M22, T.Zero, T.Zero); + Row3 = new(value.M31, value.M32, T.One, T.Zero); + Row4 = new(value.M41, value.M42, T.Zero, T.One); Row5 = default; } From 0345ba56312fad178a192a82f63544ad3fcfea0d Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 19:41:03 -0700 Subject: [PATCH 48/67] Code-gen multiply operators. --- sources/Maths/Maths/Matrix2X2.Ops.cs | 81 ------------------ sources/Maths/Maths/Matrix2X2.cs | 9 -- sources/Maths/Maths/Matrix2X2.gen.cs | 113 ++++++++++++++++++++++++- sources/Maths/Maths/Matrix2X3.Ops.cs | 74 ---------------- sources/Maths/Maths/Matrix2X3.cs | 9 -- sources/Maths/Maths/Matrix2X3.gen.cs | 121 ++++++++++++++++++++++++++- sources/Maths/Maths/Matrix2X4.Ops.cs | 91 -------------------- sources/Maths/Maths/Matrix2X4.cs | 9 -- sources/Maths/Maths/Matrix2X4.gen.cs | 121 ++++++++++++++++++++++++++- sources/Maths/Maths/Matrix3X2.Ops.cs | 80 ------------------ sources/Maths/Maths/Matrix3X2.cs | 9 -- sources/Maths/Maths/Matrix3X2.gen.cs | 121 ++++++++++++++++++++++++++- sources/Maths/Maths/Matrix3X3.Ops.cs | 94 --------------------- sources/Maths/Maths/Matrix3X3.cs | 9 -- sources/Maths/Maths/Matrix3X3.gen.cs | 113 ++++++++++++++++++++++++- sources/Maths/Maths/Matrix3X4.Ops.cs | 98 ---------------------- sources/Maths/Maths/Matrix3X4.cs | 9 -- sources/Maths/Maths/Matrix3X4.gen.cs | 121 ++++++++++++++++++++++++++- sources/Maths/Maths/Matrix4X2.Ops.cs | 91 -------------------- sources/Maths/Maths/Matrix4X2.cs | 9 -- sources/Maths/Maths/Matrix4X2.gen.cs | 121 ++++++++++++++++++++++++++- sources/Maths/Maths/Matrix4X3.Ops.cs | 97 --------------------- sources/Maths/Maths/Matrix4X3.cs | 9 -- sources/Maths/Maths/Matrix4X3.gen.cs | 121 ++++++++++++++++++++++++++- sources/Maths/Maths/Matrix4X4.Ops.cs | 73 ---------------- sources/Maths/Maths/Matrix4X4.cs | 10 --- sources/Maths/Maths/Matrix4X4.gen.cs | 121 ++++++++++++++++++++++++++- sources/Maths/Maths/Matrix5X4.Ops.cs | 37 -------- sources/Maths/Maths/Matrix5X4.gen.cs | 51 ++++++++++- sources/Maths/Maths/Vector2D.gen.cs | 16 ++++ sources/Maths/Maths/Vector3D.gen.cs | 16 ++++ sources/Maths/Maths/Vector4D.gen.cs | 16 ++++ 32 files changed, 1162 insertions(+), 908 deletions(-) delete mode 100644 sources/Maths/Maths/Matrix2X2.Ops.cs delete mode 100644 sources/Maths/Maths/Matrix2X4.Ops.cs delete mode 100644 sources/Maths/Maths/Matrix3X4.Ops.cs delete mode 100644 sources/Maths/Maths/Matrix4X3.Ops.cs diff --git a/sources/Maths/Maths/Matrix2X2.Ops.cs b/sources/Maths/Maths/Matrix2X2.Ops.cs deleted file mode 100644 index e7f5828da8..0000000000 --- a/sources/Maths/Maths/Matrix2X2.Ops.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Numerics; -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - /// - /// Methods for working with - /// - public static partial class Matrix2X2 - { - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Add(Matrix2X2 value1, Matrix2X2 value2) - where T : INumberBase - { - return value1 + value2; - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Multiply(Matrix2X2 value1, Matrix2X2 value2) - where T : INumberBase => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X2 Multiply(Matrix3X2 value1, Matrix2X2 value2) - where T : INumberBase => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X3 Multiply(Matrix2X2 value1, Matrix2X3 value2) - where T : INumberBase => value1 * value2; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Multiply(Matrix2X2 value1, T value2) - where T : INumberBase => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Multiply(Vector2D value1, Matrix2X2 value2) - where T : INumberBase => value1 * value2; - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Negate(Matrix2X2 value) - where T : INumberBase => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Subtract(Matrix2X2 value1, Matrix2X2 value2) - where T : INumberBase => value1 - value2; - } -} diff --git a/sources/Maths/Maths/Matrix2X2.cs b/sources/Maths/Maths/Matrix2X2.cs index 5085e8de98..25d3a702ca 100644 --- a/sources/Maths/Maths/Matrix2X2.cs +++ b/sources/Maths/Maths/Matrix2X2.cs @@ -54,15 +54,6 @@ public Matrix2X2(Matrix4X2 value) Row2 = new(value.M21, value.M22); } - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - public static unsafe Vector2D operator *(Vector2D value1, Matrix2X2 value2) - { - return value1 * value2.Row1 + value1 * value2.Row2; - } - /// Calculates the determinant of the matrix. /// The determinant of the matrix. public readonly T GetDeterminant() diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index 16706b400d..154f2572ba 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -109,7 +109,6 @@ public override string ToString() => Row2.X, Row2.Y); /// - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix2X2 other && Equals(other); /// @@ -197,6 +196,20 @@ public Matrix2X2 Transpose() => new(left.Row1 * right, left.Row2 * right); + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector2D operator *(Vector2D rowVector, Matrix2X2 matrix) => + rowVector.X * matrix.Row1 + rowVector.Y * matrix.Row2; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector2D operator *(Matrix2X2 matrix, Vector2D columnVector) => + matrix.Column1 * columnVector.X + matrix.Column2 * columnVector.Y; + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -422,6 +435,9 @@ public static explicit operator checked Matrix2X2(Matrix2X2 from) => Vector2D.CreateChecked(from.Row2)); } + /// + /// Methods for working with + /// public static partial class Matrix2X2 { /// Linearly interpolates between the corresponding values of two matrices. @@ -433,5 +449,100 @@ public static Matrix2X2 Lerp(Matrix2X2 value1, Matrix2X2 value2, T a where T : IFloatingPointIeee754 => new(Vector2D.Lerp(value1.Row1, value2.Row1, amount), Vector2D.Lerp(value1.Row2, value2.Row2, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix2X2 Add(Matrix2X2 left, Matrix2X2 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix2X2 Negate(Matrix2X2 value) + where T : INumberBase + => -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix2X2 Subtract(Matrix2X2 left, Matrix2X2 right) + where T : INumberBase + => left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix2X2 Multiply(Matrix2X2 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix2X2 Multiply(T left, Matrix2X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector2D Multiply(Vector2D rowVector, Matrix2X2 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector2D Multiply(Matrix2X2 matrix, Vector2D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X2 Multiply(Matrix2X2 left, Matrix2X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X3 Multiply(Matrix2X2 left, Matrix2X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 Multiply(Matrix2X2 left, Matrix2X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X2 Multiply(Matrix3X2 left, Matrix2X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 Multiply(Matrix4X2 left, Matrix2X2 right) + where T : INumberBase => + left * right; } } diff --git a/sources/Maths/Maths/Matrix2X3.Ops.cs b/sources/Maths/Maths/Matrix2X3.Ops.cs index 81cae99cff..d9cd1234fc 100644 --- a/sources/Maths/Maths/Matrix2X3.Ops.cs +++ b/sources/Maths/Maths/Matrix2X3.Ops.cs @@ -14,17 +14,6 @@ public static partial class Matrix2X3 { private const float BillboardEpsilon = 1e-4f; - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X3 Add(Matrix2X3 value1, Matrix2X3 value2) - where T : INumberBase - { - return value1 + value2; - } - /// Creates a spherical billboard that rotates around a specified object position. /// Position of the object the billboard will rotate around. /// Position of the camera. @@ -145,69 +134,6 @@ public static Matrix2X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) return CreateFromQuaternion(q); } - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X3 Multiply(Matrix2X3 value1, Matrix3X3 value2) - where T : INumberBase - => value1 * value2; - - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Multiply(Matrix2X3 value1, Matrix3X2 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X3 Multiply(Matrix2X2 value1, Matrix2X3 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X3 Multiply(Matrix2X3 value1, T value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Multiply(Vector2D value1, Matrix2X3 value2) - where T : INumberBase - => value1 * value2; - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X3 Negate(Matrix2X3 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X3 Subtract(Matrix2X3 value1, Matrix2X3 value2) - where T : INumberBase - => value1 - value2; - /// Transforms the given matrix by applying the given Quaternion rotation. /// The source matrix to transform. /// The rotation to apply. diff --git a/sources/Maths/Maths/Matrix2X3.cs b/sources/Maths/Maths/Matrix2X3.cs index e1e4df98a8..1f9c06fc6e 100644 --- a/sources/Maths/Maths/Matrix2X3.cs +++ b/sources/Maths/Maths/Matrix2X3.cs @@ -66,14 +66,5 @@ public Matrix2X3(Matrix4X2 value) /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] public readonly bool IsIdentity => this == Identity; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - public static unsafe Vector3D operator *(Vector2D value1, Matrix2X3 value2) - { - return value1.X * value2.Row1 + value1.Y * value2.Row2; - } } } diff --git a/sources/Maths/Maths/Matrix2X3.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs index cd3fd0c468..c5d7f73970 100644 --- a/sources/Maths/Maths/Matrix2X3.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -114,7 +114,6 @@ public override string ToString() => Row2.X, Row2.Y, Row2.Z); /// - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix2X3 other && Equals(other); /// @@ -203,6 +202,20 @@ public Matrix3X2 Transpose() => new(left.Row1 * right, left.Row2 * right); + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector3D operator *(Vector2D rowVector, Matrix2X3 matrix) => + rowVector.X * matrix.Row1 + rowVector.Y * matrix.Row2; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector2D operator *(Matrix2X3 matrix, Vector3D columnVector) => + matrix.Column1 * columnVector.X + matrix.Column2 * columnVector.Y + matrix.Column3 * columnVector.Z; + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -436,6 +449,9 @@ public static explicit operator checked Matrix2X3(Matrix2X3 from) => Vector3D.CreateChecked(from.Row2)); } + /// + /// Methods for working with + /// public static partial class Matrix2X3 { /// Linearly interpolates between the corresponding values of two matrices. @@ -447,5 +463,108 @@ public static Matrix2X3 Lerp(Matrix2X3 value1, Matrix2X3 value2, T a where T : IFloatingPointIeee754 => new(Vector3D.Lerp(value1.Row1, value2.Row1, amount), Vector3D.Lerp(value1.Row2, value2.Row2, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix2X3 Add(Matrix2X3 left, Matrix2X3 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix2X3 Negate(Matrix2X3 value) + where T : INumberBase + => -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix2X3 Subtract(Matrix2X3 left, Matrix2X3 right) + where T : INumberBase + => left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix2X3 Multiply(Matrix2X3 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix2X3 Multiply(T left, Matrix2X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector3D Multiply(Vector2D rowVector, Matrix2X3 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector2D Multiply(Matrix2X3 matrix, Vector3D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X3 Multiply(Matrix2X2 left, Matrix2X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X2 Multiply(Matrix2X3 left, Matrix3X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X3 Multiply(Matrix2X3 left, Matrix3X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 Multiply(Matrix2X3 left, Matrix3X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X3 Multiply(Matrix3X2 left, Matrix2X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 Multiply(Matrix4X2 left, Matrix2X3 right) + where T : INumberBase => + left * right; } } diff --git a/sources/Maths/Maths/Matrix2X4.Ops.cs b/sources/Maths/Maths/Matrix2X4.Ops.cs deleted file mode 100644 index 4d0f06cbd4..0000000000 --- a/sources/Maths/Maths/Matrix2X4.Ops.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Numerics; -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - /// - /// Methods for working with - /// - public static partial class Matrix2X4 - { - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X4 Add(Matrix2X4 value1, Matrix2X4 value2) - where T : INumberBase - { - return value1 + value2; - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X4 Multiply(Matrix2X4 value1, Matrix4X4 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X3 Multiply(Matrix2X4 value1, Matrix4X3 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Multiply(Matrix2X4 value1, Matrix4X2 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X4 Multiply(Matrix4X2 value1, Matrix2X4 value2) - where T : INumberBase - => value1 * value2; - - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X4 Multiply(Matrix3X2 value1, Matrix2X4 value2) - where T : INumberBase - => value1 * value2; - - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X4 Multiply(Matrix2X2 value1, Matrix2X4 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Multiply(Vector2D value1, Matrix2X4 value2) - where T : INumberBase - => value1 * value2; - } -} diff --git a/sources/Maths/Maths/Matrix2X4.cs b/sources/Maths/Maths/Matrix2X4.cs index 838b0902cb..447aa4fac4 100644 --- a/sources/Maths/Maths/Matrix2X4.cs +++ b/sources/Maths/Maths/Matrix2X4.cs @@ -66,14 +66,5 @@ public Matrix2X4(Matrix4X2 value) /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] public readonly bool IsIdentity => this == Identity; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - public static unsafe Vector4D operator *(Vector2D value1, Matrix2X4 value2) - { - return value1.X * value2.Row1 + value1.Y * value2.Row2; - } } } diff --git a/sources/Maths/Maths/Matrix2X4.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs index 2e8af8f158..c9f0301392 100644 --- a/sources/Maths/Maths/Matrix2X4.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -128,7 +128,6 @@ public override string ToString() => Row2.X, Row2.Y, Row2.Z, Row2.W); /// - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix2X4 other && Equals(other); /// @@ -218,6 +217,20 @@ public Matrix4X2 Transpose() => new(left.Row1 * right, left.Row2 * right); + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector4D operator *(Vector2D rowVector, Matrix2X4 matrix) => + rowVector.X * matrix.Row1 + rowVector.Y * matrix.Row2; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector2D operator *(Matrix2X4 matrix, Vector4D columnVector) => + matrix.Column1 * columnVector.X + matrix.Column2 * columnVector.Y + matrix.Column3 * columnVector.Z + matrix.Column4 * columnVector.W; + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -460,6 +473,9 @@ public static explicit operator checked Matrix2X4(Matrix2X4 from) => Vector4D.CreateChecked(from.Row2)); } + /// + /// Methods for working with + /// public static partial class Matrix2X4 { /// Linearly interpolates between the corresponding values of two matrices. @@ -471,5 +487,108 @@ public static Matrix2X4 Lerp(Matrix2X4 value1, Matrix2X4 value2, T a where T : IFloatingPointIeee754 => new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), Vector4D.Lerp(value1.Row2, value2.Row2, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix2X4 Add(Matrix2X4 left, Matrix2X4 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix2X4 Negate(Matrix2X4 value) + where T : INumberBase + => -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix2X4 Subtract(Matrix2X4 left, Matrix2X4 right) + where T : INumberBase + => left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix2X4 Multiply(Matrix2X4 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix2X4 Multiply(T left, Matrix2X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector4D Multiply(Vector2D rowVector, Matrix2X4 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector2D Multiply(Matrix2X4 matrix, Vector4D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 Multiply(Matrix2X2 left, Matrix2X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X2 Multiply(Matrix2X4 left, Matrix4X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X3 Multiply(Matrix2X4 left, Matrix4X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 Multiply(Matrix2X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 Multiply(Matrix3X2 left, Matrix2X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X4 Multiply(Matrix4X2 left, Matrix2X4 right) + where T : INumberBase => + left * right; } } diff --git a/sources/Maths/Maths/Matrix3X2.Ops.cs b/sources/Maths/Maths/Matrix3X2.Ops.cs index 4f5194fe0a..34096ae04d 100644 --- a/sources/Maths/Maths/Matrix3X2.Ops.cs +++ b/sources/Maths/Maths/Matrix3X2.Ops.cs @@ -18,15 +18,6 @@ public static partial class Matrix3X2 private const float RotationEpsilon = 0.001f * ((float) Math.PI) / 180f; // 0.1% of a degree #endif - /// Adds each matrix element in value1 with its corresponding element in value2. - /// The first source matrix. - /// The second source matrix. - /// The matrix containing the summed values. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X2 Add(Matrix3X2 value1, Matrix3X2 value2) - where T : INumberBase - => value1 + value2; - /// Creates a rotation matrix using the given rotation in radians. /// The amount of rotation, in radians. /// A rotation matrix. @@ -413,76 +404,5 @@ public static bool Invert(Matrix3X2 matrix, out Matrix3X2 result) return true; } - - /// Multiplies two matrices together and returns the resulting matrix. - /// The first source matrix. - /// The second source matrix. - /// The product matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X2 Multiply(Matrix3X2 value1, Matrix2X2 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Multiply(Vector3D value1, Matrix3X2 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies two matrices together and returns the resulting matrix. - /// The first source matrix. - /// The second source matrix. - /// The product matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X3 Multiply(Matrix3X2 value1, Matrix2X3 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies two matrices together and returns the resulting matrix. - /// The first source matrix. - /// The second source matrix. - /// The product matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Multiply(Matrix2X3 value1, Matrix3X2 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies two matrices together and returns the resulting matrix. - /// The first source matrix. - /// The second source matrix. - /// The product matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X3 Multiply(Matrix2X3 value1, Matrix3X3 value2) - where T : INumberBase - => value1 * value2; - - /// Scales all elements in a matrix by the given scalar factor. - /// The source matrix. - /// The scaling value to use. - /// The resulting matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X2 Multiply(Matrix3X2 value1, T value2) - where T : INumberBase - => value1 * value2; - - /// Negates the given matrix by multiplying all values by -1. - /// The source matrix. - /// The negated matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X2 Negate(Matrix3X2 value) - where T : INumberBase - => -value; - - /// Subtracts each matrix element in value2 from its corresponding element in value1. - /// The first source matrix. - /// The second source matrix. - /// The matrix containing the resulting values. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X2 Subtract(Matrix3X2 value1, Matrix3X2 value2) - where T : INumberBase - => value1 - value2; } } diff --git a/sources/Maths/Maths/Matrix3X2.cs b/sources/Maths/Maths/Matrix3X2.cs index fe2716e323..6f618c2e69 100644 --- a/sources/Maths/Maths/Matrix3X2.cs +++ b/sources/Maths/Maths/Matrix3X2.cs @@ -72,15 +72,6 @@ public Matrix3X2(Matrix4X2 value) [IgnoreDataMember] public readonly bool IsIdentity => this == Identity; - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - public static unsafe Vector2D operator *(Vector3D value1, Matrix3X2 value2) - { - return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3; - } - /// Calculates the determinant for this matrix. /// The determinant is calculated by expanding the matrix with a third column whose values are (0,0,1). /// The determinant. diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index 3afe6bdefa..5f8f13123e 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -119,7 +119,6 @@ public override string ToString() => Row3.X, Row3.Y); /// - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix3X2 other && Equals(other); /// @@ -213,6 +212,20 @@ public Matrix2X3 Transpose() => left.Row2 * right, left.Row3 * right); + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector2D operator *(Vector3D rowVector, Matrix3X2 matrix) => + rowVector.X * matrix.Row1 + rowVector.Y * matrix.Row2 + rowVector.Z * matrix.Row3; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector3D operator *(Matrix3X2 matrix, Vector2D columnVector) => + matrix.Column1 * columnVector.X + matrix.Column2 * columnVector.Y; + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -472,6 +485,9 @@ public static explicit operator checked Matrix3X2(Matrix3X2 from) => Vector2D.CreateChecked(from.Row3)); } + /// + /// Methods for working with + /// public static partial class Matrix3X2 { /// Linearly interpolates between the corresponding values of two matrices. @@ -484,5 +500,108 @@ public static Matrix3X2 Lerp(Matrix3X2 value1, Matrix3X2 value2, T a new(Vector2D.Lerp(value1.Row1, value2.Row1, amount), Vector2D.Lerp(value1.Row2, value2.Row2, amount), Vector2D.Lerp(value1.Row3, value2.Row3, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix3X2 Add(Matrix3X2 left, Matrix3X2 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix3X2 Negate(Matrix3X2 value) + where T : INumberBase + => -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix3X2 Subtract(Matrix3X2 left, Matrix3X2 right) + where T : INumberBase + => left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix3X2 Multiply(Matrix3X2 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix3X2 Multiply(T left, Matrix3X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector2D Multiply(Vector3D rowVector, Matrix3X2 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector3D Multiply(Matrix3X2 matrix, Vector2D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X2 Multiply(Matrix2X3 left, Matrix3X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X2 Multiply(Matrix3X2 left, Matrix2X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X3 Multiply(Matrix3X2 left, Matrix2X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 Multiply(Matrix3X2 left, Matrix2X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X2 Multiply(Matrix3X3 left, Matrix3X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 Multiply(Matrix4X3 left, Matrix3X2 right) + where T : INumberBase => + left * right; } } diff --git a/sources/Maths/Maths/Matrix3X3.Ops.cs b/sources/Maths/Maths/Matrix3X3.Ops.cs index 3f1dcf198d..c90d00d352 100644 --- a/sources/Maths/Maths/Matrix3X3.Ops.cs +++ b/sources/Maths/Maths/Matrix3X3.Ops.cs @@ -35,17 +35,6 @@ private struct VectorBasis } */ - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X3 Add(Matrix3X3 value1, Matrix3X3 value2) - where T : INumberBase - { - return value1 + value2; - } - /// Creates a spherical billboard that rotates around a specified object position. /// Position of the object the billboard will rotate around. /// Position of the camera. @@ -287,89 +276,6 @@ public static Matrix3X3 CreateScale(T scale) return result; } - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X3 Multiply(Matrix3X3 value1, Matrix3X3 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X3 Multiply(Matrix2X3 value1, Matrix3X3 value2) - where T : INumberBase - => value1 * value2; - - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X2 Multiply(Matrix3X3 value1, Matrix3X2 value2) - where T : INumberBase - => value1 * value2; - - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X3 Multiply(Matrix4X3 value1, Matrix3X3 value2) - where T : INumberBase - => value1 * value2; - - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X4 Multiply(Matrix3X3 value1, Matrix3X4 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X3 Multiply(Matrix3X3 value1, T value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Multiply(Vector3D value1, Matrix3X3 value2) - where T : INumberBase - => value1 * value2; - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X3 Negate(Matrix3X3 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X3 Subtract(Matrix3X3 value1, Matrix3X3 value2) - where T : INumberBase - => value1 - value2; - /* /// Attempts to extract the scale, translation, and rotation components from the given scale/rotation/translation matrix. /// If successful, the out parameters will contained the extracted values. diff --git a/sources/Maths/Maths/Matrix3X3.cs b/sources/Maths/Maths/Matrix3X3.cs index d98120c478..492bc49f43 100644 --- a/sources/Maths/Maths/Matrix3X3.cs +++ b/sources/Maths/Maths/Matrix3X3.cs @@ -77,15 +77,6 @@ public Matrix3X3(Matrix4X4 value) Row3 = new(value.M31, value.M32, value.M33); } - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - public static unsafe Vector3D operator *(Vector3D value1, Matrix3X3 value2) - { - return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3; - } - /// Calculates the determinant of the matrix. /// The determinant of the matrix. public readonly T GetDeterminant() diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index 33e2f9db96..adf07c2f0a 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -148,7 +148,6 @@ public override string ToString() => Row3.X, Row3.Y, Row3.Z); /// - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix3X3 other && Equals(other); /// @@ -243,6 +242,20 @@ public Matrix3X3 Transpose() => left.Row2 * right, left.Row3 * right); + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector3D operator *(Vector3D rowVector, Matrix3X3 matrix) => + rowVector.X * matrix.Row1 + rowVector.Y * matrix.Row2 + rowVector.Z * matrix.Row3; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector3D operator *(Matrix3X3 matrix, Vector3D columnVector) => + matrix.Column1 * columnVector.X + matrix.Column2 * columnVector.Y + matrix.Column3 * columnVector.Z; + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -510,6 +523,9 @@ public static explicit operator checked Matrix3X3(Matrix3X3 from) => Vector3D.CreateChecked(from.Row3)); } + /// + /// Methods for working with + /// public static partial class Matrix3X3 { /// Linearly interpolates between the corresponding values of two matrices. @@ -522,5 +538,100 @@ public static Matrix3X3 Lerp(Matrix3X3 value1, Matrix3X3 value2, T a new(Vector3D.Lerp(value1.Row1, value2.Row1, amount), Vector3D.Lerp(value1.Row2, value2.Row2, amount), Vector3D.Lerp(value1.Row3, value2.Row3, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix3X3 Add(Matrix3X3 left, Matrix3X3 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix3X3 Negate(Matrix3X3 value) + where T : INumberBase + => -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix3X3 Subtract(Matrix3X3 left, Matrix3X3 right) + where T : INumberBase + => left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix3X3 Multiply(Matrix3X3 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix3X3 Multiply(T left, Matrix3X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector3D Multiply(Vector3D rowVector, Matrix3X3 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector3D Multiply(Matrix3X3 matrix, Vector3D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X3 Multiply(Matrix2X3 left, Matrix3X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X2 Multiply(Matrix3X3 left, Matrix3X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X3 Multiply(Matrix3X3 left, Matrix3X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 Multiply(Matrix3X3 left, Matrix3X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 Multiply(Matrix4X3 left, Matrix3X3 right) + where T : INumberBase => + left * right; } } diff --git a/sources/Maths/Maths/Matrix3X4.Ops.cs b/sources/Maths/Maths/Matrix3X4.Ops.cs deleted file mode 100644 index ae25df3fb3..0000000000 --- a/sources/Maths/Maths/Matrix3X4.Ops.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Numerics; -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - /// - /// Methods for working with - /// - public static partial class Matrix3X4 - { - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X4 Add(Matrix3X4 value1, Matrix3X4 value2) - where T : INumberBase - { - return value1 + value2; - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X3 Multiply(Matrix3X4 value1, Matrix4X3 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X4 Multiply(Matrix3X4 value1, Matrix4X4 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X4 Multiply(Matrix3X3 value1, Matrix3X4 value2) - where T : INumberBase - => value1 * value2; - - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X4 Multiply(Matrix4X3 value1, Matrix3X4 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X4 Multiply(Matrix3X4 value1, T value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Multiply(Vector3D value1, Matrix3X4 value2) - where T : INumberBase - => value1 * value2; - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X4 Negate(Matrix3X4 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X4 Subtract(Matrix3X4 value1, Matrix3X4 value2) - where T : INumberBase - => value1 - value2; - } -} diff --git a/sources/Maths/Maths/Matrix3X4.cs b/sources/Maths/Maths/Matrix3X4.cs index 82ed67a171..1143215c6a 100644 --- a/sources/Maths/Maths/Matrix3X4.cs +++ b/sources/Maths/Maths/Matrix3X4.cs @@ -81,14 +81,5 @@ public Matrix3X4(Matrix4X2 value) /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] public readonly bool IsIdentity => this == Identity; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - public static unsafe Vector4D operator *(Vector3D value1, Matrix3X4 value2) - { - return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3; - } } } diff --git a/sources/Maths/Maths/Matrix3X4.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs index 640fe89ad4..93e590bbcf 100644 --- a/sources/Maths/Maths/Matrix3X4.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -157,7 +157,6 @@ public override string ToString() => Row3.X, Row3.Y, Row3.Z, Row3.W); /// - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix3X4 other && Equals(other); /// @@ -253,6 +252,20 @@ public Matrix4X3 Transpose() => left.Row2 * right, left.Row3 * right); + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector4D operator *(Vector3D rowVector, Matrix3X4 matrix) => + rowVector.X * matrix.Row1 + rowVector.Y * matrix.Row2 + rowVector.Z * matrix.Row3; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector3D operator *(Matrix3X4 matrix, Vector4D columnVector) => + matrix.Column1 * columnVector.X + matrix.Column2 * columnVector.Y + matrix.Column3 * columnVector.Z + matrix.Column4 * columnVector.W; + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -529,6 +542,9 @@ public static explicit operator checked Matrix3X4(Matrix3X4 from) => Vector4D.CreateChecked(from.Row3)); } + /// + /// Methods for working with + /// public static partial class Matrix3X4 { /// Linearly interpolates between the corresponding values of two matrices. @@ -541,5 +557,108 @@ public static Matrix3X4 Lerp(Matrix3X4 value1, Matrix3X4 value2, T a new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), Vector4D.Lerp(value1.Row2, value2.Row2, amount), Vector4D.Lerp(value1.Row3, value2.Row3, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix3X4 Add(Matrix3X4 left, Matrix3X4 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix3X4 Negate(Matrix3X4 value) + where T : INumberBase + => -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix3X4 Subtract(Matrix3X4 left, Matrix3X4 right) + where T : INumberBase + => left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix3X4 Multiply(Matrix3X4 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix3X4 Multiply(T left, Matrix3X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector4D Multiply(Vector3D rowVector, Matrix3X4 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector3D Multiply(Matrix3X4 matrix, Vector4D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 Multiply(Matrix2X3 left, Matrix3X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 Multiply(Matrix3X3 left, Matrix3X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X2 Multiply(Matrix3X4 left, Matrix4X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X3 Multiply(Matrix3X4 left, Matrix4X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 Multiply(Matrix3X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X4 Multiply(Matrix4X3 left, Matrix3X4 right) + where T : INumberBase => + left * right; } } diff --git a/sources/Maths/Maths/Matrix4X2.Ops.cs b/sources/Maths/Maths/Matrix4X2.Ops.cs index 697280fe63..d6a6d59f00 100644 --- a/sources/Maths/Maths/Matrix4X2.Ops.cs +++ b/sources/Maths/Maths/Matrix4X2.Ops.cs @@ -12,97 +12,6 @@ namespace Silk.NET.Maths /// public static partial class Matrix4X2 { - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X2 Add(Matrix4X2 value1, Matrix4X2 value2) - where T : INumberBase - { - return value1 + value2; - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X2 Multiply(Matrix4X2 value1, Matrix2X2 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X3 Multiply(Matrix4X2 value1, Matrix2X3 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X4 Multiply(Matrix4X2 value1, Matrix2X4 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X2 Multiply(Matrix2X4 value1, Matrix4X2 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X2 Multiply(Matrix3X4 value1, Matrix4X2 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector2D Multiply(Vector4D value1, Matrix4X2 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X2 Multiply(Matrix4X4 value1, Matrix4X2 value2) - where T : INumberBase - => value1 * value2; - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X2 Negate(Matrix4X2 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X2 Subtract(Matrix4X2 value1, Matrix4X2 value2) - where T : INumberBase - => value1 - value2; - /*[MethodImpl((MethodImplOptions)768)] private static Vector128 Permute(Vector128 value, byte control) where T : INumberBase diff --git a/sources/Maths/Maths/Matrix4X2.cs b/sources/Maths/Maths/Matrix4X2.cs index 6086ca84b4..4fab060824 100644 --- a/sources/Maths/Maths/Matrix4X2.cs +++ b/sources/Maths/Maths/Matrix4X2.cs @@ -79,14 +79,5 @@ public Matrix4X2(Matrix2X4 value) /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] public readonly bool IsIdentity => this == Identity; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - public static unsafe Vector2D operator *(Vector4D value1, Matrix4X2 value2) - { - return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3 + value1.W * value2.Row4; - } } } diff --git a/sources/Maths/Maths/Matrix4X2.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs index 2cad4a3085..eb6b0133c9 100644 --- a/sources/Maths/Maths/Matrix4X2.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -138,7 +138,6 @@ public override string ToString() => Row4.X, Row4.Y); /// - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix4X2 other && Equals(other); /// @@ -238,6 +237,20 @@ public Matrix2X4 Transpose() => left.Row3 * right, left.Row4 * right); + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector2D operator *(Vector4D rowVector, Matrix4X2 matrix) => + rowVector.X * matrix.Row1 + rowVector.Y * matrix.Row2 + rowVector.Z * matrix.Row3 + rowVector.W * matrix.Row4; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector4D operator *(Matrix4X2 matrix, Vector2D columnVector) => + matrix.Column1 * columnVector.X + matrix.Column2 * columnVector.Y; + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -533,6 +546,9 @@ public static explicit operator checked Matrix4X2(Matrix4X2 from) => Vector2D.CreateChecked(from.Row4)); } + /// + /// Methods for working with + /// public static partial class Matrix4X2 { /// Linearly interpolates between the corresponding values of two matrices. @@ -546,5 +562,108 @@ public static Matrix4X2 Lerp(Matrix4X2 value1, Matrix4X2 value2, T a Vector2D.Lerp(value1.Row2, value2.Row2, amount), Vector2D.Lerp(value1.Row3, value2.Row3, amount), Vector2D.Lerp(value1.Row4, value2.Row4, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4X2 Add(Matrix4X2 left, Matrix4X2 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4X2 Negate(Matrix4X2 value) + where T : INumberBase + => -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4X2 Subtract(Matrix4X2 left, Matrix4X2 right) + where T : INumberBase + => left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix4X2 Multiply(Matrix4X2 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix4X2 Multiply(T left, Matrix4X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector2D Multiply(Vector4D rowVector, Matrix4X2 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector4D Multiply(Matrix4X2 matrix, Vector2D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X2 Multiply(Matrix2X4 left, Matrix4X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X2 Multiply(Matrix3X4 left, Matrix4X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 Multiply(Matrix4X2 left, Matrix2X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 Multiply(Matrix4X2 left, Matrix2X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X4 Multiply(Matrix4X2 left, Matrix2X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 Multiply(Matrix4X4 left, Matrix4X2 right) + where T : INumberBase => + left * right; } } diff --git a/sources/Maths/Maths/Matrix4X3.Ops.cs b/sources/Maths/Maths/Matrix4X3.Ops.cs deleted file mode 100644 index 807192cc85..0000000000 --- a/sources/Maths/Maths/Matrix4X3.Ops.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Numerics; -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - /// - /// Methods for working with - /// - public static partial class Matrix4X3 - { - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X3 Add(Matrix4X3 value1, Matrix4X3 value2) - where T : INumberBase - { - return value1 + value2; - } - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X3 Multiply(Matrix4X3 value1, Matrix3X3 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X4 Multiply(Matrix4X3 value1, Matrix3X4 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X3 Multiply(Matrix4X4 value1, Matrix4X3 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix3X3 Multiply(Matrix3X4 value1, Matrix4X3 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X3 Multiply(Matrix4X3 value1, T value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector3D Multiply(Vector4D value1, Matrix4X3 value2) - where T : INumberBase - => value1 * value2; - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X3 Negate(Matrix4X3 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X3 Subtract(Matrix4X3 value1, Matrix4X3 value2) - where T : INumberBase - => value1 - value2; - } -} diff --git a/sources/Maths/Maths/Matrix4X3.cs b/sources/Maths/Maths/Matrix4X3.cs index 607aa46115..bbda207d29 100644 --- a/sources/Maths/Maths/Matrix4X3.cs +++ b/sources/Maths/Maths/Matrix4X3.cs @@ -100,14 +100,5 @@ public Matrix4X3(Matrix4X4 value) /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] public readonly bool IsIdentity => this == Identity; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - public static unsafe Vector3D operator *(Vector4D value1, Matrix4X3 value2) - { - return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3 + value1.W * value2.Row4; - } } } diff --git a/sources/Maths/Maths/Matrix4X3.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs index bb4c1216ff..5dbf30c452 100644 --- a/sources/Maths/Maths/Matrix4X3.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -162,7 +162,6 @@ public override string ToString() => Row4.X, Row4.Y, Row4.Z); /// - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix4X3 other && Equals(other); /// @@ -263,6 +262,20 @@ public Matrix3X4 Transpose() => left.Row3 * right, left.Row4 * right); + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector3D operator *(Vector4D rowVector, Matrix4X3 matrix) => + rowVector.X * matrix.Row1 + rowVector.Y * matrix.Row2 + rowVector.Z * matrix.Row3 + rowVector.W * matrix.Row4; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector4D operator *(Matrix4X3 matrix, Vector3D columnVector) => + matrix.Column1 * columnVector.X + matrix.Column2 * columnVector.Y + matrix.Column3 * columnVector.Z; + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -566,6 +579,9 @@ public static explicit operator checked Matrix4X3(Matrix4X3 from) => Vector3D.CreateChecked(from.Row4)); } + /// + /// Methods for working with + /// public static partial class Matrix4X3 { /// Linearly interpolates between the corresponding values of two matrices. @@ -579,5 +595,108 @@ public static Matrix4X3 Lerp(Matrix4X3 value1, Matrix4X3 value2, T a Vector3D.Lerp(value1.Row2, value2.Row2, amount), Vector3D.Lerp(value1.Row3, value2.Row3, amount), Vector3D.Lerp(value1.Row4, value2.Row4, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4X3 Add(Matrix4X3 left, Matrix4X3 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4X3 Negate(Matrix4X3 value) + where T : INumberBase + => -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4X3 Subtract(Matrix4X3 left, Matrix4X3 right) + where T : INumberBase + => left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix4X3 Multiply(Matrix4X3 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix4X3 Multiply(T left, Matrix4X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector3D Multiply(Vector4D rowVector, Matrix4X3 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector4D Multiply(Matrix4X3 matrix, Vector3D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X3 Multiply(Matrix2X4 left, Matrix4X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X3 Multiply(Matrix3X4 left, Matrix4X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 Multiply(Matrix4X3 left, Matrix3X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 Multiply(Matrix4X3 left, Matrix3X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X4 Multiply(Matrix4X3 left, Matrix3X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 Multiply(Matrix4X4 left, Matrix4X3 right) + where T : INumberBase => + left * right; } } diff --git a/sources/Maths/Maths/Matrix4X4.Ops.cs b/sources/Maths/Maths/Matrix4X4.Ops.cs index 83e8e3dc15..f8c605f21c 100644 --- a/sources/Maths/Maths/Matrix4X4.Ops.cs +++ b/sources/Maths/Maths/Matrix4X4.Ops.cs @@ -40,17 +40,6 @@ private struct VectorBasis } */ - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X4 Add(Matrix4X4 value1, Matrix4X4 value2) - where T : INumberBase - { - return value1 + value2; - } - /// Creates a spherical billboard that rotates around a specified object position. /// Position of the object the billboard will rotate around. /// Position of the camera. @@ -1192,68 +1181,6 @@ static bool SoftwareFallback(Matrix4X4 matrix, out Matrix4X4 result) } } - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X4 Multiply(Matrix4X4 value1, Matrix4X4 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Vector4D Multiply(Vector4D value1, Matrix4X4 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix2X4 Multiply(Matrix2X4 value1, Matrix4X4 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X2 Multiply(Matrix4X4 value1, Matrix4X2 value2) - where T : INumberBase - => value1 * value2; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X4 Multiply(Matrix4X4 value1, T value2) - where T : INumberBase - => value1 * value2; - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X4 Negate(Matrix4X4 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix4X4 Subtract(Matrix4X4 value1, Matrix4X4 value2) - where T : INumberBase - => value1 - value2; - /*[MethodImpl((MethodImplOptions)768)] private static Vector128 Permute(Vector128 value, byte control) { diff --git a/sources/Maths/Maths/Matrix4X4.cs b/sources/Maths/Maths/Matrix4X4.cs index b9e06be306..2cd9f69e41 100644 --- a/sources/Maths/Maths/Matrix4X4.cs +++ b/sources/Maths/Maths/Matrix4X4.cs @@ -74,16 +74,6 @@ public Matrix4X4(Matrix4X2 value) Row4 = new(value.M41, value.M42, T.Zero, T.One); } - /// Multiplies a vector by a matrix. - /// The vector. - /// The matrix. - /// The result of the multiplication. - public static unsafe Vector4D operator *(Vector4D value1, Matrix4X4 value2) - { - return value1.X * value2.Row1 + value1.Y * value2.Row2 + value1.Z * value2.Row3 + - value1.W * value2.Row4; - } - /// Calculates the determinant of the matrix. /// The determinant of the matrix. public readonly T GetDeterminant() diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index 5346ae1daf..b2ffa73373 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -197,7 +197,6 @@ public override string ToString() => Row4.X, Row4.Y, Row4.Z, Row4.W); /// - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix4X4 other && Equals(other); /// @@ -299,6 +298,20 @@ public Matrix4X4 Transpose() => left.Row3 * right, left.Row4 * right); + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector4D operator *(Vector4D rowVector, Matrix4X4 matrix) => + rowVector.X * matrix.Row1 + rowVector.Y * matrix.Row2 + rowVector.Z * matrix.Row3 + rowVector.W * matrix.Row4; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector4D operator *(Matrix4X4 matrix, Vector4D columnVector) => + matrix.Column1 * columnVector.X + matrix.Column2 * columnVector.Y + matrix.Column3 * columnVector.Z + matrix.Column4 * columnVector.W; + /// Multiplies a matrix by another matrix. /// The first source matrix. /// The second source matrix. @@ -611,6 +624,9 @@ public static explicit operator checked Matrix4X4(Matrix4X4 from) => Vector4D.CreateChecked(from.Row4)); } + /// + /// Methods for working with + /// public static partial class Matrix4X4 { /// Linearly interpolates between the corresponding values of two matrices. @@ -624,5 +640,108 @@ public static Matrix4X4 Lerp(Matrix4X4 value1, Matrix4X4 value2, T a Vector4D.Lerp(value1.Row2, value2.Row2, amount), Vector4D.Lerp(value1.Row3, value2.Row3, amount), Vector4D.Lerp(value1.Row4, value2.Row4, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4X4 Add(Matrix4X4 left, Matrix4X4 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4X4 Negate(Matrix4X4 value) + where T : INumberBase + => -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4X4 Subtract(Matrix4X4 left, Matrix4X4 right) + where T : INumberBase + => left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix4X4 Multiply(Matrix4X4 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix4X4 Multiply(T left, Matrix4X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector4D Multiply(Vector4D rowVector, Matrix4X4 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector4D Multiply(Matrix4X4 matrix, Vector4D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 Multiply(Matrix2X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 Multiply(Matrix3X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 Multiply(Matrix4X4 left, Matrix4X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 Multiply(Matrix4X4 left, Matrix4X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X4 Multiply(Matrix4X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix5X4 Multiply(Matrix5X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; } } diff --git a/sources/Maths/Maths/Matrix5X4.Ops.cs b/sources/Maths/Maths/Matrix5X4.Ops.cs index 032181692f..65c6170be8 100644 --- a/sources/Maths/Maths/Matrix5X4.Ops.cs +++ b/sources/Maths/Maths/Matrix5X4.Ops.cs @@ -12,17 +12,6 @@ namespace Silk.NET.Maths /// public static partial class Matrix5X4 { - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The resulting matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix5X4 Add(Matrix5X4 value1, Matrix5X4 value2) - where T : INumberBase - { - return value1 + value2; - } - /// Multiplies a vector by a matrix. /// The vector. /// The matrix. @@ -31,31 +20,5 @@ public static Matrix5X4 Add(Matrix5X4 value1, Matrix5X4 value2) public static Vector4D Multiply(Vector4D value1, Matrix5X4 value2) where T : INumberBase => value1 * value2; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix5X4 Multiply(Matrix5X4 value1, T value2) - where T : INumberBase - => value1 * value2; - - /// Returns a new matrix with the negated elements of the given matrix. - /// The source matrix. - /// The negated matrix. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix5X4 Negate(Matrix5X4 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - [MethodImpl((MethodImplOptions) 768)] - public static Matrix5X4 Subtract(Matrix5X4 value1, Matrix5X4 value2) - where T : INumberBase - => value1 - value2; } } diff --git a/sources/Maths/Maths/Matrix5X4.gen.cs b/sources/Maths/Maths/Matrix5X4.gen.cs index a294471477..af2e8a312e 100644 --- a/sources/Maths/Maths/Matrix5X4.gen.cs +++ b/sources/Maths/Maths/Matrix5X4.gen.cs @@ -199,7 +199,6 @@ public override string ToString() => Row5.X, Row5.Y, Row5.Z, Row5.W); /// - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public override bool Equals(object? obj) => obj is Matrix5X4 other && Equals(other); /// @@ -600,6 +599,9 @@ public static explicit operator checked Matrix5X4(Matrix5X4 from) => Vector4D.CreateChecked(from.Row5)); } + /// + /// Methods for working with + /// public static partial class Matrix5X4 { /// Linearly interpolates between the corresponding values of two matrices. @@ -614,5 +616,52 @@ public static Matrix5X4 Lerp(Matrix5X4 value1, Matrix5X4 value2, T a Vector4D.Lerp(value1.Row3, value2.Row3, amount), Vector4D.Lerp(value1.Row4, value2.Row4, amount), Vector4D.Lerp(value1.Row5, value2.Row5, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix5X4 Add(Matrix5X4 left, Matrix5X4 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix5X4 Negate(Matrix5X4 value) + where T : INumberBase + => -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix5X4 Subtract(Matrix5X4 left, Matrix5X4 right) + where T : INumberBase + => left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix5X4 Multiply(Matrix5X4 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix5X4 Multiply(T left, Matrix5X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix5X4 Multiply(Matrix5X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; } } diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index 09e6b203bc..3d7286547d 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -648,6 +648,22 @@ public static (Vector2D Quotient, Vector2D Remainder) DivRem(Vector2D(qX, qY), new Vector2D(rX, rY)); } + /// Multiplies a vector by a scalar value. + /// The source vector. + /// The scaling factor. + /// The scaled vector. + public static Vector2D Multiply(Vector2D left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a vector by a scalar value. + /// The scaling factor. + /// The source vector. + /// The scaled vector. + public static Vector2D Multiply(T left, Vector2D right) + where T : INumberBase => + left * right; + /// Applies to the provided arguments. /// A vector whose members will be provided for . public static Vector2D Sign(this Vector2D value) diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index cb34c6f13f..b6572cd47f 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -689,6 +689,22 @@ public static (Vector3D Quotient, Vector3D Remainder) DivRem(Vector3D(qX, qY, qZ), new Vector3D(rX, rY, rZ)); } + /// Multiplies a vector by a scalar value. + /// The source vector. + /// The scaling factor. + /// The scaled vector. + public static Vector3D Multiply(Vector3D left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a vector by a scalar value. + /// The scaling factor. + /// The source vector. + /// The scaled vector. + public static Vector3D Multiply(T left, Vector3D right) + where T : INumberBase => + left * right; + /// Applies to the provided arguments. /// A vector whose members will be provided for . public static Vector3D Sign(this Vector3D value) diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index bfdfbecb07..ed84851eb8 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -730,6 +730,22 @@ public static (Vector4D Quotient, Vector4D Remainder) DivRem(Vector4D(qX, qY, qZ, qW), new Vector4D(rX, rY, rZ, rW)); } + /// Multiplies a vector by a scalar value. + /// The source vector. + /// The scaling factor. + /// The scaled vector. + public static Vector4D Multiply(Vector4D left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a vector by a scalar value. + /// The scaling factor. + /// The source vector. + /// The scaled vector. + public static Vector4D Multiply(T left, Vector4D right) + where T : INumberBase => + left * right; + /// Applies to the provided arguments. /// A vector whose members will be provided for . public static Vector4D Sign(this Vector4D value) From 9497be81c0f6d4d91a0655a29cc4b4d3a128ddb8 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 19:56:09 -0700 Subject: [PATCH 49/67] Recovered Old Quaternion implementation. --- sources/Maths/Maths/Matrix2X3.Ops.cs | 12 +- sources/Maths/Maths/Matrix3X3.Ops.cs | 12 +- sources/Maths/Maths/Matrix4X4.Ops.cs | 12 +- sources/Maths/Maths/Plane.Ops.cs | 4 +- .../Quaternion.cs => Quaternion.Old.cs} | 261 ++++-------------- sources/Maths/Maths/Quaternion.cs | 36 ++- 6 files changed, 99 insertions(+), 238 deletions(-) rename sources/Maths/Maths/{Legacy/Quaternion.cs => Quaternion.Old.cs} (69%) diff --git a/sources/Maths/Maths/Matrix2X3.Ops.cs b/sources/Maths/Maths/Matrix2X3.Ops.cs index d9cd1234fc..fdd180d1ce 100644 --- a/sources/Maths/Maths/Matrix2X3.Ops.cs +++ b/sources/Maths/Maths/Matrix2X3.Ops.cs @@ -94,8 +94,8 @@ public static Matrix2X3 CreateFromAxisAngle(Vector3D axis, T angle) /// Creates a rotation matrix from the given Quaternion rotation value. /// The source Quaternion. /// The rotation matrix. - public static Matrix2X3 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quaternion quaternion) - where T : INumberBase + public static Matrix2X3 CreateFromQuaternion(Quaternion quaternion) + where T : ITrigonometricFunctions { Matrix2X3 result = Matrix2X3.Identity; @@ -128,9 +128,9 @@ public static Matrix2X3 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quatern /// Angle of rotation, in radians, around the Z-axis. /// The rotation matrix. public static Matrix2X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) - where T : INumberBase + where T : ITrigonometricFunctions { - Legacy.Quaternion q = Legacy.Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); + var q = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(q); } @@ -138,8 +138,8 @@ public static Matrix2X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) /// The source matrix to transform. /// The rotation to apply. /// The transformed matrix. - public static Matrix2X3 Transform(Matrix2X3 value, Legacy.Quaternion rotation) - where T : INumberBase + public static Matrix2X3 Transform(Matrix2X3 value, Quaternion rotation) + where T : ITrigonometricFunctions { // Compute rotation matrix. T x2 = Scalar.Add(rotation.X, rotation.X); diff --git a/sources/Maths/Maths/Matrix3X3.Ops.cs b/sources/Maths/Maths/Matrix3X3.Ops.cs index c90d00d352..2cdcb433e6 100644 --- a/sources/Maths/Maths/Matrix3X3.Ops.cs +++ b/sources/Maths/Maths/Matrix3X3.Ops.cs @@ -119,8 +119,8 @@ public static Matrix3X3 CreateFromAxisAngle(Vector3D axis, T angle) /// Creates a rotation matrix from the given Quaternion rotation value. /// The source Quaternion. /// The rotation matrix. - public static Matrix3X3 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quaternion quaternion) - where T : INumberBase + public static Matrix3X3 CreateFromQuaternion(Quaternion quaternion) + where T : ITrigonometricFunctions { Matrix3X3 result = Matrix3X3.Identity; @@ -157,9 +157,9 @@ public static Matrix3X3 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quatern /// Angle of rotation, in radians, around the Z-axis. /// The rotation matrix. public static Matrix3X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) - where T : INumberBase + where T : ITrigonometricFunctions { - Legacy.Quaternion q = Legacy.Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); + var q = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(q); } @@ -475,8 +475,8 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out /// The source matrix to transform. /// The rotation to apply. /// The transformed matrix. - public static Matrix3X3 Transform(Matrix3X3 value, Legacy.Quaternion rotation) - where T : INumberBase + public static Matrix3X3 Transform(Matrix3X3 value, Quaternion rotation) + where T : ITrigonometricFunctions { // Compute rotation matrix. T x2 = Scalar.Add(rotation.X, rotation.X); diff --git a/sources/Maths/Maths/Matrix4X4.Ops.cs b/sources/Maths/Maths/Matrix4X4.Ops.cs index f8c605f21c..fffd21652b 100644 --- a/sources/Maths/Maths/Matrix4X4.Ops.cs +++ b/sources/Maths/Maths/Matrix4X4.Ops.cs @@ -189,8 +189,8 @@ public static Matrix4X4 CreateFromAxisAngle(Vector3D axis, T angle) /// Creates a rotation matrix from the given Quaternion rotation value. /// The source Quaternion. /// The rotation matrix. - public static Matrix4X4 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quaternion quaternion) - where T : INumberBase + public static Matrix4X4 CreateFromQuaternion(Quaternion quaternion) + where T : ITrigonometricFunctions { Matrix4X4 result = Matrix4X4.Identity; @@ -227,9 +227,9 @@ public static Matrix4X4 CreateFromQuaternion(Silk.NET.Maths.Legacy.Quatern /// Angle of rotation, in radians, around the Z-axis. /// The rotation matrix. public static Matrix4X4 CreateFromYawPitchRoll(T yaw, T pitch, T roll) - where T : INumberBase + where T : ITrigonometricFunctions { - Legacy.Quaternion q = Legacy.Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); + var q = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(q); } @@ -1404,8 +1404,8 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out /// The source matrix to transform. /// The rotation to apply. /// The transformed matrix. - public static Matrix4X4 Transform(Matrix4X4 value, Legacy.Quaternion rotation) - where T : INumberBase + public static Matrix4X4 Transform(Matrix4X4 value, Quaternion rotation) + where T : ITrigonometricFunctions { // Compute rotation matrix. T x2 = Scalar.Add(rotation.X, rotation.X); diff --git a/sources/Maths/Maths/Plane.Ops.cs b/sources/Maths/Maths/Plane.Ops.cs index fff64125ca..279f4200bf 100644 --- a/sources/Maths/Maths/Plane.Ops.cs +++ b/sources/Maths/Maths/Plane.Ops.cs @@ -182,8 +182,8 @@ public static Plane Transform(Plane plane, Matrix4X4 matrix) /// The Quaternion rotation to apply to the Plane. /// A new Plane that results from applying the rotation. [MethodImpl((MethodImplOptions) 768)] - public static Plane Transform(Plane plane, Legacy.Quaternion rotation) - where T : INumberBase + public static Plane Transform(Plane plane, Quaternion rotation) + where T : ITrigonometricFunctions { // Compute rotation matrix. T x2 = Scalar.Add(rotation.X, rotation.X); diff --git a/sources/Maths/Maths/Legacy/Quaternion.cs b/sources/Maths/Maths/Quaternion.Old.cs similarity index 69% rename from sources/Maths/Maths/Legacy/Quaternion.cs rename to sources/Maths/Maths/Quaternion.Old.cs index 2694588fca..9a4c29648b 100644 --- a/sources/Maths/Maths/Legacy/Quaternion.cs +++ b/sources/Maths/Maths/Quaternion.Old.cs @@ -8,7 +8,7 @@ using System.Runtime.Serialization; using Silk.NET.Maths; -namespace Silk.NET.Maths.Legacy +namespace Silk.NET.Maths { /// /// Represents a vector that is used to encode three-dimensional physical rotations. @@ -16,41 +16,10 @@ namespace Silk.NET.Maths.Legacy /// The type used to store values. [Serializable] [DataContract] - public struct Quaternion - : IEquatable> - where T : INumberBase + public partial struct Quaternion { private const float SlerpEpsilon = 1e-6f; - /// Specifies the X-value of the vector component of the Quaternion. - [DataMember] - public T X; - - /// Specifies the Y-value of the vector component of the Quaternion. - [DataMember] - public T Y; - - /// Specifies the Z-value of the vector component of the Quaternion. - [DataMember] - public T Z; - - /// Specifies the rotation component of the Quaternion. - [DataMember] - public T W; - - /// Constructs a Quaternion from the given components. - /// The X component of the Quaternion. - /// The Y component of the Quaternion. - /// The Z component of the Quaternion. - /// The W component of the Quaternion. - public Quaternion(T x, T y, T z, T w) - { - X = x; - Y = y; - Z = z; - W = w; - } - /// Constructs a Quaternion from the given vector and rotation parts. /// The vector part of the Quaternion. /// The rotation part of the Quaternion. @@ -62,9 +31,6 @@ public Quaternion(Vector3D vectorPart, T scalarPart) W = scalarPart; } - /// Returns a Quaternion representing no rotation. - public static Quaternion Identity => new(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); - /// Returns whether the Quaternion is the identity Quaternion. [IgnoreDataMember] public readonly bool IsIdentity => this == Identity; @@ -104,22 +70,22 @@ public Quaternion(Vector3D vectorPart, T scalarPart) Scalar.Add( Scalar.Add(Scalar.Multiply(value2.X, value2.X), Scalar.Multiply(value2.Y, value2.Y)), Scalar.Multiply(value2.Z, value2.Z)), Scalar.Multiply(value2.W, value2.W)); - T invNorm = Scalar.Reciprocal(ls); + var invNorm = Scalar.Reciprocal(ls); - T q2x = Scalar.Negate(Scalar.Multiply(value2.X, invNorm)); - T q2y = Scalar.Negate(Scalar.Multiply(value2.Y, invNorm)); - T q2z = Scalar.Negate(Scalar.Multiply(value2.Z, invNorm)); - T q2w = Scalar.Multiply(value2.W, invNorm); + var q2x = Scalar.Negate(Scalar.Multiply(value2.X, invNorm)); + var q2y = Scalar.Negate(Scalar.Multiply(value2.Y, invNorm)); + var q2z = Scalar.Negate(Scalar.Multiply(value2.Z, invNorm)); + var q2w = Scalar.Multiply(value2.W, invNorm); //------------------------------------- // Multiply part. // cross(av, bv) - T cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); - T cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); - T cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); + var cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); + var cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); + var cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); - T dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), + var dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), Scalar.Multiply(q1z, q2z)); ans.X = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2w), Scalar.Multiply(q2x, q1w)), cx); @@ -130,23 +96,6 @@ public Quaternion(Vector3D vectorPart, T scalarPart) return ans; } - /// Returns a boolean indicating whether the two given Quaternions are equal. - /// The first Quaternion to compare. - /// The second Quaternion to compare. - /// True if the Quaternions are equal; False otherwise. - public static bool operator ==(Quaternion value1, Quaternion value2) - => Scalar.Equal(value1.X, value2.X) - && Scalar.Equal(value1.Y, value2.Y) - && Scalar.Equal(value1.Z, value2.Z) - && Scalar.Equal(value1.W, value2.W); - - /// Returns a boolean indicating whether the two given Quaternions are not equal. - /// The first Quaternion to compare. - /// The second Quaternion to compare. - /// True if the Quaternions are not equal; False if they are equal. - public static bool operator !=(Quaternion value1, Quaternion value2) - => !(value1 == value2); - /// Multiplies two Quaternions together. /// The Quaternion on the left side of the multiplication. /// The Quaternion on the right side of the multiplication. @@ -166,11 +115,11 @@ public Quaternion(Vector3D vectorPart, T scalarPart) T q2w = value2.W; // cross(av, bv) - T cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); - T cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); - T cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); + var cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); + var cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); + var cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); - T dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), + var dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), Scalar.Multiply(q1z, q2z)); ans.X = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2w), Scalar.Multiply(q2x, q1w)), cx); @@ -257,11 +206,11 @@ public static Quaternion Concatenate(Quaternion value1, Quaternion valu T q2w = value1.W; // cross(av, bv) - T cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); - T cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); - T cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); + var cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); + var cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); + var cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); - T dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), + var dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), Scalar.Multiply(q1z, q2z)); ans.X = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2w), Scalar.Multiply(q2x, q1w)), cx); @@ -296,9 +245,9 @@ public static Quaternion CreateFromAxisAngle(Vector3D axis, T angle) { Quaternion ans; - T halfAngle = Scalar.Divide(angle, Scalar.Two); - T s = Scalar.Sin(halfAngle); - T c = Scalar.Cos(halfAngle); + var halfAngle = Scalar.Divide(angle, Scalar.Two); + var s = Scalar.Sin(halfAngle); + var c = Scalar.Cos(halfAngle); ans.X = Scalar.Multiply(axis.X, s); ans.Y = Scalar.Multiply(axis.Y, s); @@ -313,13 +262,13 @@ public static Quaternion CreateFromAxisAngle(Vector3D axis, T angle) /// The created Quaternion. public static Quaternion CreateFromRotationMatrix(Matrix4X4 matrix) { - T trace = Scalar.Add(Scalar.Add(matrix.M11, matrix.M22), matrix.M33); + var trace = Scalar.Add(Scalar.Add(matrix.M11, matrix.M22), matrix.M33); Quaternion q = default; if (Scalar.GreaterThan(trace, Scalar.Zero)) { - T s = Scalar.Sqrt(Scalar.Add(trace, Scalar.One)); + var s = Scalar.Sqrt(Scalar.Add(trace, Scalar.One)); q.W = Scalar.Divide(s, Scalar.Two); s = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); q.X = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), s); @@ -330,8 +279,8 @@ public static Quaternion CreateFromRotationMatrix(Matrix4X4 matrix) { if (Scalar.GreaterThanOrEqual(matrix.M11, matrix.M22) && Scalar.GreaterThanOrEqual(matrix.M11, matrix.M33)) { - T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M11), matrix.M22), matrix.M33)); - T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + var s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M11), matrix.M22), matrix.M33)); + var invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); q.X = Scalar.Divide(s, Scalar.Two); q.Y = Scalar.Multiply(Scalar.Add(matrix.M12, matrix.M21), invS); q.Z = Scalar.Multiply(Scalar.Add(matrix.M13, matrix.M31), invS); @@ -339,8 +288,8 @@ public static Quaternion CreateFromRotationMatrix(Matrix4X4 matrix) } else if (Scalar.GreaterThan(matrix.M22, matrix.M33)) { - T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M22), matrix.M11), matrix.M33)); - T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + var s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M22), matrix.M11), matrix.M33)); + var invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); q.X = Scalar.Multiply(Scalar.Add(matrix.M21, matrix.M12), invS); q.Y = Scalar.Divide(s, Scalar.Two); q.Z = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); @@ -348,8 +297,8 @@ public static Quaternion CreateFromRotationMatrix(Matrix4X4 matrix) } else { - T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M33), matrix.M11), matrix.M22)); - T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + var s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M33), matrix.M11), matrix.M22)); + var invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); q.X = Scalar.Multiply(Scalar.Add(matrix.M31, matrix.M13), invS); q.Y = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); q.Z = Scalar.Divide(s, Scalar.Two); @@ -365,13 +314,13 @@ public static Quaternion CreateFromRotationMatrix(Matrix4X4 matrix) /// The created Quaternion. public static Quaternion CreateFromRotationMatrix(Matrix3X3 matrix) { - T trace = Scalar.Add(Scalar.Add(matrix.M11, matrix.M22), matrix.M33); + var trace = Scalar.Add(Scalar.Add(matrix.M11, matrix.M22), matrix.M33); Quaternion q = default; if (Scalar.GreaterThan(trace, Scalar.Zero)) { - T s = Scalar.Sqrt(Scalar.Add(trace, Scalar.One)); + var s = Scalar.Sqrt(Scalar.Add(trace, Scalar.One)); q.W = Scalar.Divide(s, Scalar.Two); s = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); q.X = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), s); @@ -382,8 +331,8 @@ public static Quaternion CreateFromRotationMatrix(Matrix3X3 matrix) { if (Scalar.GreaterThanOrEqual(matrix.M11, matrix.M22) && Scalar.GreaterThanOrEqual(matrix.M11, matrix.M33)) { - T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M11), matrix.M22), matrix.M33)); - T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + var s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M11), matrix.M22), matrix.M33)); + var invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); q.X = Scalar.Divide(s, Scalar.Two); q.Y = Scalar.Multiply(Scalar.Add(matrix.M12, matrix.M21), invS); q.Z = Scalar.Multiply(Scalar.Add(matrix.M13, matrix.M31), invS); @@ -391,8 +340,8 @@ public static Quaternion CreateFromRotationMatrix(Matrix3X3 matrix) } else if (Scalar.GreaterThan(matrix.M22, matrix.M33)) { - T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M22), matrix.M11), matrix.M33)); - T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + var s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M22), matrix.M11), matrix.M33)); + var invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); q.X = Scalar.Multiply(Scalar.Add(matrix.M21, matrix.M12), invS); q.Y = Scalar.Divide(s, Scalar.Two); q.Z = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); @@ -400,8 +349,8 @@ public static Quaternion CreateFromRotationMatrix(Matrix3X3 matrix) } else { - T s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M33), matrix.M11), matrix.M22)); - T invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); + var s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M33), matrix.M11), matrix.M22)); + var invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); q.X = Scalar.Multiply(Scalar.Add(matrix.M31, matrix.M13), invS); q.Y = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); q.Z = Scalar.Divide(s, Scalar.Two); @@ -423,15 +372,15 @@ public static Quaternion CreateFromYawPitchRoll(T yaw, T pitch, T roll) // pitch upward, then yaw to face into the new heading T sr, cr, sp, cp, sy, cy; - T halfRoll = Scalar.Divide(roll, Scalar.Two); + var halfRoll = Scalar.Divide(roll, Scalar.Two); sr = Scalar.Sin(halfRoll); cr = Scalar.Cos(halfRoll); - T halfPitch = Scalar.Divide(pitch, Scalar.Two); + var halfPitch = Scalar.Divide(pitch, Scalar.Two); sp = Scalar.Sin(halfPitch); cp = Scalar.Cos(halfPitch); - T halfYaw = Scalar.Divide(yaw, Scalar.Two); + var halfYaw = Scalar.Divide(yaw, Scalar.Two); sy = Scalar.Sin(halfYaw); cy = Scalar.Cos(halfYaw); @@ -477,7 +426,7 @@ public static Quaternion Inverse(Quaternion value) Quaternion ans; T ls = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, value.X), Scalar.Multiply(value.Y, value.Y)), Scalar.Multiply(value.Z, value.Z)), Scalar.Multiply(value.W, value.W)); - T invNorm = Scalar.Reciprocal(ls); + var invNorm = Scalar.Reciprocal(ls); ans.X = Scalar.Negate(Scalar.Multiply(value.X, invNorm)); ans.Y = Scalar.Negate(Scalar.Multiply(value.Y, invNorm)); @@ -494,8 +443,8 @@ public static Quaternion Inverse(Quaternion value) /// The interpolated Quaternion. public static Quaternion Lerp(Quaternion quaternion1, Quaternion quaternion2, T amount) { - T t = amount; - T t1 = Scalar.Subtract(Scalar.One, t); + var t = amount; + var t1 = Scalar.Subtract(Scalar.One, t); Quaternion r = default; @@ -523,7 +472,7 @@ public static Quaternion Lerp(Quaternion quaternion1, Quaternion quater // Normalize it. T ls = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(r.X, r.X), Scalar.Multiply(r.Y, r.Y)), Scalar.Multiply(r.Z, r.Z)), Scalar.Multiply(r.W, r.W)); - T invNorm = Scalar.Reciprocal(Scalar.Sqrt(ls)); + var invNorm = Scalar.Reciprocal(Scalar.Sqrt(ls)); r.X = Scalar.Multiply(r.X, invNorm); r.Y = Scalar.Multiply(r.Y, invNorm); @@ -564,7 +513,7 @@ public static Quaternion Normalize(Quaternion value) Quaternion ans; T ls = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, value.X), Scalar.Multiply(value.Y, value.Y)), Scalar.Multiply(value.Z, value.Z)), Scalar.Multiply(value.W, value.W)); - T invNorm = Scalar.Reciprocal(Scalar.Sqrt(ls)); + var invNorm = Scalar.Reciprocal(Scalar.Sqrt(ls)); ans.X = Scalar.Multiply(value.X, invNorm); ans.Y = Scalar.Multiply(value.Y, invNorm); @@ -581,11 +530,11 @@ public static Quaternion Normalize(Quaternion value) /// The interpolated Quaternion. public static Quaternion Slerp(Quaternion quaternion1, Quaternion quaternion2, T amount) { - T t = amount; + var t = amount; T cosOmega = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(quaternion1.X, quaternion2.X), Scalar.Multiply(quaternion1.Y, quaternion2.Y)), Scalar.Multiply(quaternion1.Z, quaternion2.Z)), Scalar.Multiply(quaternion1.W, quaternion2.W)); - bool flip = false; + var flip = false; if (!Scalar.GreaterThanOrEqual(cosOmega, Scalar.Zero)) { @@ -603,11 +552,11 @@ public static Quaternion Slerp(Quaternion quaternion1, Quaternion quate } else { - T omega = Scalar.Acos(cosOmega); - T invSinOmega = Scalar.Reciprocal(Scalar.Sin(omega)); + var omega = Scalar.Acos(cosOmega); + var invSinOmega = Scalar.Reciprocal(Scalar.Sin(omega)); s1 = Scalar.Multiply(Scalar.Sin(Scalar.Multiply(Scalar.Subtract(Scalar.One, t), omega)), invSinOmega); - s2 = (flip) + s2 = flip ? Scalar.Negate(Scalar.Multiply(Scalar.Sin(Scalar.Multiply(t, omega)), invSinOmega)) : Scalar.Multiply(Scalar.Sin(Scalar.Multiply(t, omega)), invSinOmega); } @@ -630,25 +579,6 @@ public static Quaternion Slerp(Quaternion quaternion1, Quaternion quate public static Quaternion Subtract(Quaternion value1, Quaternion value2) => value1 - value2; - /// Returns a boolean indicating whether the given Object is equal to this Quaternion instance. - /// The Object to compare against. - /// True if the Object is equal to this Quaternion; False otherwise. - public override readonly bool Equals(object? obj) - => (obj is Quaternion other) && Equals(other); - - /// Returns a boolean indicating whether the given Quaternion is equal to this Quaternion instance. - /// The Quaternion to compare this instance to. - /// True if the other Quaternion is equal to this instance; False otherwise. - public readonly bool Equals(Quaternion other) - => this == other; - - /// Returns the hash code for this instance. - /// The hash code. - public override readonly int GetHashCode() - { - return unchecked(X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode()); - } - /// Calculates the length of the Quaternion. /// The computed length of the Quaternion. public readonly T Length() @@ -685,14 +615,14 @@ public static explicit operator Quaternion(Quaternion from) Scalar.As(from.W)); /// - /// Converts a into + /// Converts a into /// /// The source quaternion /// The quaternion - public static explicit operator System.Numerics.Quaternion(Quaternion from) + public static explicit operator Quaternion(Quaternion from) => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), Scalar.As(from.W)); - + /// /// Converts a into one with a of /// @@ -702,93 +632,12 @@ public static explicit operator Quaternion(Quaternion from) => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), Scalar.As(from.W)); - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - - /// - /// Converts a into one with a of - /// - /// The source matrix - /// The matrix - public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); - /// /// Returns this quaternion casted to /// /// The type to cast to /// The casted quaternion - public Quaternion As() where TOther : INumberBase + public Quaternion As() where TOther : ITrigonometricFunctions { return new(Scalar.As(X), Scalar.As(Y), Scalar.As(Z), Scalar.As(W)); } diff --git a/sources/Maths/Maths/Quaternion.cs b/sources/Maths/Maths/Quaternion.cs index cbc9253039..16f3b69527 100644 --- a/sources/Maths/Maths/Quaternion.cs +++ b/sources/Maths/Maths/Quaternion.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Numerics; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; @@ -13,27 +14,31 @@ namespace Silk.NET.Maths /// /// Represents a four-dimensional vector used to encode 3D rotations. /// - public struct Quaternion : + public partial struct Quaternion : IEquatable> - where T : IFloatingPointIeee754 + where T : ITrigonometricFunctions { /// Specifies the X-value of the vector component of the Quaternion. + [DataMember] public T X; /// Specifies the Y-value of the vector component of the Quaternion. + [DataMember] public T Y; /// Specifies the Z-value of the vector component of the Quaternion. + [DataMember] public T Z; - /// Specifies the W-value of the scalar component of the Quaternion. + /// Specifies the rotation (W) component of the Quaternion. + [DataMember] public T W; /// Constructs a Quaternion from the given components. - /// The X component of the Quaternion. - /// The Y component of the Quaternion. - /// The Z component of the Quaternion. - /// The W component of the Quaternion. + /// The X-component of the Quaternion. + /// The Y-component of the Quaternion. + /// The Z-component of the Quaternion. + /// The rotation (W) component of the Quaternion. public Quaternion(T x, T y, T z, T w) { X = x; @@ -58,7 +63,7 @@ public Quaternion(T x, T y, T z, T w) // TODO: Vector4F/Vector3F constructors /// Returns a representing no rotation. - public static Quaternion Identity => new Quaternion(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); + public static Quaternion Identity { get; } = new Quaternion(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); /// Returns a boolean indicating whether the given Object is equal to this instance. public override bool Equals(object? obj) => @@ -69,15 +74,22 @@ public bool Equals(Quaternion other) => this == other; /// Returns the hash code for this instance. + /// The hash code. public override int GetHashCode() => HashCode.Combine(X, Y, Z, W); + /// Returns a boolean indicating whether the two given Quaternions are not equal. + /// The first Quaternion to compare. + /// The second Quaternion to compare. + /// True if the Quaternions are not equal; False if they are equal. + public static bool operator !=(Quaternion left, Quaternion right) => + !(left == right); - // Equality Operators + /// Returns a boolean indicating whether the two given Quaternions are equal. + /// The first Quaternion to compare. + /// The second Quaternion to compare. + /// True if the Quaternions are equal; False otherwise. public static bool operator ==(Quaternion left, Quaternion right) => left.X == right.X && left.Y == right.Y && left.Z == right.Z && left.W == right.W; - - public static bool operator !=(Quaternion left, Quaternion right) => - !(left == right); } } From 9aa76de914047ff21649e4836a53321e967d8535 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 20:22:50 -0700 Subject: [PATCH 50/67] Fix Obsolete warnings. --- sources/Maths/Maths/Box2D.cs | 36 +++++++++++++++++++++++++++- sources/Maths/Maths/Box3D.cs | 9 +++---- sources/Maths/Maths/Circle.cs | 3 ++- sources/Maths/Maths/Cube.cs | 11 +++++---- sources/Maths/Maths/Matrix2X2.gen.cs | 25 +++++++++++++++---- sources/Maths/Maths/Matrix2X3.gen.cs | 25 +++++++++++++++---- sources/Maths/Maths/Matrix2X4.gen.cs | 25 +++++++++++++++---- sources/Maths/Maths/Matrix3X2.gen.cs | 25 +++++++++++++++---- sources/Maths/Maths/Matrix3X3.gen.cs | 25 +++++++++++++++---- sources/Maths/Maths/Matrix3X4.gen.cs | 25 +++++++++++++++---- sources/Maths/Maths/Matrix4X2.gen.cs | 25 +++++++++++++++---- sources/Maths/Maths/Matrix4X3.gen.cs | 25 +++++++++++++++---- sources/Maths/Maths/Matrix4X4.gen.cs | 25 +++++++++++++++---- sources/Maths/Maths/Matrix5X4.gen.cs | 25 +++++++++++++++---- sources/Maths/Maths/Plane.cs | 3 ++- sources/Maths/Maths/Ray2D.cs | 3 ++- sources/Maths/Maths/Ray3D.cs | 3 ++- sources/Maths/Maths/Rectangle.cs | 11 +++++---- sources/Maths/Maths/Sphere.cs | 1 + sources/Maths/Maths/Vector2D.gen.cs | 18 +++++++++++++- sources/Maths/Maths/Vector3D.gen.cs | 18 +++++++++++++- sources/Maths/Maths/Vector4D.gen.cs | 18 +++++++++++++- 22 files changed, 312 insertions(+), 72 deletions(-) diff --git a/sources/Maths/Maths/Box2D.cs b/sources/Maths/Maths/Box2D.cs index f038fd5fd5..c468e2fa48 100644 --- a/sources/Maths/Maths/Box2D.cs +++ b/sources/Maths/Maths/Box2D.cs @@ -151,7 +151,7 @@ public Box2D GetScaled(Vector2D scale, Vector2D anchor) public Box2D GetScaled(Vector2D scale, Vector2D anchor) where TScale : INumber { - return this.As().GetScaled(scale, anchor.As()).As(); + return this.AsTruncating().GetScaled(scale, anchor.AsTruncating()).AsTruncating(); } /// @@ -210,10 +210,44 @@ public override int GetHashCode() /// /// The type to cast to /// The casted box + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Box2D As() where TOther : INumber { return new(Min.As(), Max.As()); } + + /// + /// Returns this box casted to + /// + /// The type to cast to + /// The casted box + public Box2D AsChecked() + where TOther : INumber + { + return new(Min.AsChecked(), Max.AsChecked()); + } + + /// + /// Returns this box casted to + /// + /// The type to cast to + /// The casted box + public Box2D AsSaturating() + where TOther : INumber + { + return new(Min.AsSaturating(), Max.AsSaturating()); + } + + /// + /// Returns this box casted to + /// + /// The type to cast to + /// The casted box + public Box2D AsTruncating() + where TOther : INumber + { + return new(Min.AsTruncating(), Max.AsTruncating()); + } } } diff --git a/sources/Maths/Maths/Box3D.cs b/sources/Maths/Maths/Box3D.cs index 040c2b0256..4e50cfb16a 100644 --- a/sources/Maths/Maths/Box3D.cs +++ b/sources/Maths/Maths/Box3D.cs @@ -160,10 +160,10 @@ public Box3D GetScaled(Vector3D scale, Vector3D anchor) public Box3D GetScaled(Vector3D scale, Vector3D anchor) where TScale : INumberBase { - var convertedAnchor = anchor.As(); - var min = (scale * (Min.As() - convertedAnchor)) + convertedAnchor; - var max = (scale * (Max.As() - convertedAnchor)) + convertedAnchor; - return new Box3D(min.As(), max.As()); + var convertedAnchor = anchor.AsTruncating(); + var min = (scale * (Min.AsTruncating() - convertedAnchor)) + convertedAnchor; + var max = (scale * (Max.AsTruncating() - convertedAnchor)) + convertedAnchor; + return new Box3D(min.AsTruncating(), max.AsTruncating()); } /// @@ -222,6 +222,7 @@ public override int GetHashCode() /// /// The type to cast to /// The casted box + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Box3D As() where TOther : INumber { diff --git a/sources/Maths/Maths/Circle.cs b/sources/Maths/Maths/Circle.cs index 4be7fcc35e..53e37c049e 100644 --- a/sources/Maths/Maths/Circle.cs +++ b/sources/Maths/Maths/Circle.cs @@ -168,12 +168,13 @@ public override int GetHashCode() { return !value1.Equals(value2); } - + /// /// Returns this circle casted to /// /// The type to cast to /// The casted circle + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Circle As() where TOther : IRootFunctions { return new(Center.As(), Scalar.As(Radius)); diff --git a/sources/Maths/Maths/Cube.cs b/sources/Maths/Maths/Cube.cs index 90bc620d49..bdc61f267e 100644 --- a/sources/Maths/Maths/Cube.cs +++ b/sources/Maths/Maths/Cube.cs @@ -172,10 +172,10 @@ public Cube GetScaled(Vector3D scale, Vector3D anchor) public Cube GetScaled(Vector3D scale, Vector3D anchor) where TScale : INumberBase { - var convertedAnchor = anchor.As(); - var min = (scale * (Origin.As() - convertedAnchor)) + convertedAnchor; - var max = (scale * (Max.As() - convertedAnchor)) + convertedAnchor; - return new(min.As(), (max - min).As()); + var convertedAnchor = anchor.AsTruncating(); + var min = (scale * (Origin.AsTruncating() - convertedAnchor)) + convertedAnchor; + var max = (scale * (Max.AsTruncating() - convertedAnchor)) + convertedAnchor; + return new(min.AsTruncating(), (max - min).AsTruncating()); } /// @@ -230,12 +230,13 @@ public override int GetHashCode() { return !value1.Equals(value2); } - + /// /// Returns this circle casted to /// /// The type to cast to /// The casted cube + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Cube As() where TOther : INumber { diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index 154f2572ba..c78d2f83c9 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -117,27 +117,42 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix2X2 CreateChecked(Matrix2X2 other) where TOther : INumberBase => new(Vector2D.CreateChecked(other.Row1), Vector2D.CreateChecked(other.Row2)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix2X2 CreateSaturating(Matrix2X2 other) where TOther : INumberBase => new(Vector2D.CreateSaturating(other.Row1), Vector2D.CreateSaturating(other.Row2)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix2X2 CreateTruncating(Matrix2X2 other) where TOther : INumberBase => new(Vector2D.CreateTruncating(other.Row1), Vector2D.CreateTruncating(other.Row2)); - /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + /// Converts the components of this matrix to another type. + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Matrix2X2 As() where TOther : INumberBase => new(Row1.As(), Row2.As()); + /// Converts the components of this matrix to another type. + public Matrix2X2 AsChecked() + where TOther : INumberBase => + Matrix2X2.CreateChecked(this); + + /// Converts the components of this matrix to another type. + public Matrix2X2 AsSaturating() + where TOther : INumberBase => + Matrix2X2.CreateSaturating(this); + + /// Converts the components of this matrix to another type. + public Matrix2X2 AsTruncating() + where TOther : INumberBase => + Matrix2X2.CreateTruncating(this); + /// Computes the transpose of the matrix. public Matrix2X2 Transpose() => new(new(M11, M21), diff --git a/sources/Maths/Maths/Matrix2X3.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs index c5d7f73970..f0a222eaae 100644 --- a/sources/Maths/Maths/Matrix2X3.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -122,27 +122,42 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix2X3 CreateChecked(Matrix2X3 other) where TOther : INumberBase => new(Vector3D.CreateChecked(other.Row1), Vector3D.CreateChecked(other.Row2)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix2X3 CreateSaturating(Matrix2X3 other) where TOther : INumberBase => new(Vector3D.CreateSaturating(other.Row1), Vector3D.CreateSaturating(other.Row2)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix2X3 CreateTruncating(Matrix2X3 other) where TOther : INumberBase => new(Vector3D.CreateTruncating(other.Row1), Vector3D.CreateTruncating(other.Row2)); - /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + /// Converts the components of this matrix to another type. + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Matrix2X3 As() where TOther : INumberBase => new(Row1.As(), Row2.As()); + /// Converts the components of this matrix to another type. + public Matrix2X3 AsChecked() + where TOther : INumberBase => + Matrix2X3.CreateChecked(this); + + /// Converts the components of this matrix to another type. + public Matrix2X3 AsSaturating() + where TOther : INumberBase => + Matrix2X3.CreateSaturating(this); + + /// Converts the components of this matrix to another type. + public Matrix2X3 AsTruncating() + where TOther : INumberBase => + Matrix2X3.CreateTruncating(this); + /// Computes the transpose of the matrix. public Matrix3X2 Transpose() => new(new(M11, M21), diff --git a/sources/Maths/Maths/Matrix2X4.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs index c9f0301392..ea7aed2896 100644 --- a/sources/Maths/Maths/Matrix2X4.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -136,27 +136,42 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix2X4 CreateChecked(Matrix2X4 other) where TOther : INumberBase => new(Vector4D.CreateChecked(other.Row1), Vector4D.CreateChecked(other.Row2)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix2X4 CreateSaturating(Matrix2X4 other) where TOther : INumberBase => new(Vector4D.CreateSaturating(other.Row1), Vector4D.CreateSaturating(other.Row2)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix2X4 CreateTruncating(Matrix2X4 other) where TOther : INumberBase => new(Vector4D.CreateTruncating(other.Row1), Vector4D.CreateTruncating(other.Row2)); - /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + /// Converts the components of this matrix to another type. + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Matrix2X4 As() where TOther : INumberBase => new(Row1.As(), Row2.As()); + /// Converts the components of this matrix to another type. + public Matrix2X4 AsChecked() + where TOther : INumberBase => + Matrix2X4.CreateChecked(this); + + /// Converts the components of this matrix to another type. + public Matrix2X4 AsSaturating() + where TOther : INumberBase => + Matrix2X4.CreateSaturating(this); + + /// Converts the components of this matrix to another type. + public Matrix2X4 AsTruncating() + where TOther : INumberBase => + Matrix2X4.CreateTruncating(this); + /// Computes the transpose of the matrix. public Matrix4X2 Transpose() => new(new(M11, M21), diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index 5f8f13123e..8f27467b3a 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -127,27 +127,42 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix3X2 CreateChecked(Matrix3X2 other) where TOther : INumberBase => new(Vector2D.CreateChecked(other.Row1), Vector2D.CreateChecked(other.Row2), Vector2D.CreateChecked(other.Row3)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix3X2 CreateSaturating(Matrix3X2 other) where TOther : INumberBase => new(Vector2D.CreateSaturating(other.Row1), Vector2D.CreateSaturating(other.Row2), Vector2D.CreateSaturating(other.Row3)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix3X2 CreateTruncating(Matrix3X2 other) where TOther : INumberBase => new(Vector2D.CreateTruncating(other.Row1), Vector2D.CreateTruncating(other.Row2), Vector2D.CreateTruncating(other.Row3)); - /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + /// Converts the components of this matrix to another type. + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Matrix3X2 As() where TOther : INumberBase => new(Row1.As(), Row2.As(), Row3.As()); + /// Converts the components of this matrix to another type. + public Matrix3X2 AsChecked() + where TOther : INumberBase => + Matrix3X2.CreateChecked(this); + + /// Converts the components of this matrix to another type. + public Matrix3X2 AsSaturating() + where TOther : INumberBase => + Matrix3X2.CreateSaturating(this); + + /// Converts the components of this matrix to another type. + public Matrix3X2 AsTruncating() + where TOther : INumberBase => + Matrix3X2.CreateTruncating(this); + /// Computes the transpose of the matrix. public Matrix2X3 Transpose() => new(new(M11, M21, M31), diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index adf07c2f0a..5718ab5f6c 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -156,27 +156,42 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix3X3 CreateChecked(Matrix3X3 other) where TOther : INumberBase => new(Vector3D.CreateChecked(other.Row1), Vector3D.CreateChecked(other.Row2), Vector3D.CreateChecked(other.Row3)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix3X3 CreateSaturating(Matrix3X3 other) where TOther : INumberBase => new(Vector3D.CreateSaturating(other.Row1), Vector3D.CreateSaturating(other.Row2), Vector3D.CreateSaturating(other.Row3)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix3X3 CreateTruncating(Matrix3X3 other) where TOther : INumberBase => new(Vector3D.CreateTruncating(other.Row1), Vector3D.CreateTruncating(other.Row2), Vector3D.CreateTruncating(other.Row3)); - /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + /// Converts the components of this matrix to another type. + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Matrix3X3 As() where TOther : INumberBase => new(Row1.As(), Row2.As(), Row3.As()); + /// Converts the components of this matrix to another type. + public Matrix3X3 AsChecked() + where TOther : INumberBase => + Matrix3X3.CreateChecked(this); + + /// Converts the components of this matrix to another type. + public Matrix3X3 AsSaturating() + where TOther : INumberBase => + Matrix3X3.CreateSaturating(this); + + /// Converts the components of this matrix to another type. + public Matrix3X3 AsTruncating() + where TOther : INumberBase => + Matrix3X3.CreateTruncating(this); + /// Computes the transpose of the matrix. public Matrix3X3 Transpose() => new(new(M11, M21, M31), diff --git a/sources/Maths/Maths/Matrix3X4.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs index 93e590bbcf..202f179523 100644 --- a/sources/Maths/Maths/Matrix3X4.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -165,27 +165,42 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix3X4 CreateChecked(Matrix3X4 other) where TOther : INumberBase => new(Vector4D.CreateChecked(other.Row1), Vector4D.CreateChecked(other.Row2), Vector4D.CreateChecked(other.Row3)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix3X4 CreateSaturating(Matrix3X4 other) where TOther : INumberBase => new(Vector4D.CreateSaturating(other.Row1), Vector4D.CreateSaturating(other.Row2), Vector4D.CreateSaturating(other.Row3)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix3X4 CreateTruncating(Matrix3X4 other) where TOther : INumberBase => new(Vector4D.CreateTruncating(other.Row1), Vector4D.CreateTruncating(other.Row2), Vector4D.CreateTruncating(other.Row3)); - /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + /// Converts the components of this matrix to another type. + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Matrix3X4 As() where TOther : INumberBase => new(Row1.As(), Row2.As(), Row3.As()); + /// Converts the components of this matrix to another type. + public Matrix3X4 AsChecked() + where TOther : INumberBase => + Matrix3X4.CreateChecked(this); + + /// Converts the components of this matrix to another type. + public Matrix3X4 AsSaturating() + where TOther : INumberBase => + Matrix3X4.CreateSaturating(this); + + /// Converts the components of this matrix to another type. + public Matrix3X4 AsTruncating() + where TOther : INumberBase => + Matrix3X4.CreateTruncating(this); + /// Computes the transpose of the matrix. public Matrix4X3 Transpose() => new(new(M11, M21, M31), diff --git a/sources/Maths/Maths/Matrix4X2.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs index eb6b0133c9..7fa9e127b0 100644 --- a/sources/Maths/Maths/Matrix4X2.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -146,27 +146,42 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix4X2 CreateChecked(Matrix4X2 other) where TOther : INumberBase => new(Vector2D.CreateChecked(other.Row1), Vector2D.CreateChecked(other.Row2), Vector2D.CreateChecked(other.Row3), Vector2D.CreateChecked(other.Row4)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix4X2 CreateSaturating(Matrix4X2 other) where TOther : INumberBase => new(Vector2D.CreateSaturating(other.Row1), Vector2D.CreateSaturating(other.Row2), Vector2D.CreateSaturating(other.Row3), Vector2D.CreateSaturating(other.Row4)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix4X2 CreateTruncating(Matrix4X2 other) where TOther : INumberBase => new(Vector2D.CreateTruncating(other.Row1), Vector2D.CreateTruncating(other.Row2), Vector2D.CreateTruncating(other.Row3), Vector2D.CreateTruncating(other.Row4)); - /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + /// Converts the components of this matrix to another type. + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Matrix4X2 As() where TOther : INumberBase => new(Row1.As(), Row2.As(), Row3.As(), Row4.As()); + /// Converts the components of this matrix to another type. + public Matrix4X2 AsChecked() + where TOther : INumberBase => + Matrix4X2.CreateChecked(this); + + /// Converts the components of this matrix to another type. + public Matrix4X2 AsSaturating() + where TOther : INumberBase => + Matrix4X2.CreateSaturating(this); + + /// Converts the components of this matrix to another type. + public Matrix4X2 AsTruncating() + where TOther : INumberBase => + Matrix4X2.CreateTruncating(this); + /// Computes the transpose of the matrix. public Matrix2X4 Transpose() => new(new(M11, M21, M31, M41), diff --git a/sources/Maths/Maths/Matrix4X3.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs index 5dbf30c452..47e77e6519 100644 --- a/sources/Maths/Maths/Matrix4X3.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -170,27 +170,42 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix4X3 CreateChecked(Matrix4X3 other) where TOther : INumberBase => new(Vector3D.CreateChecked(other.Row1), Vector3D.CreateChecked(other.Row2), Vector3D.CreateChecked(other.Row3), Vector3D.CreateChecked(other.Row4)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix4X3 CreateSaturating(Matrix4X3 other) where TOther : INumberBase => new(Vector3D.CreateSaturating(other.Row1), Vector3D.CreateSaturating(other.Row2), Vector3D.CreateSaturating(other.Row3), Vector3D.CreateSaturating(other.Row4)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix4X3 CreateTruncating(Matrix4X3 other) where TOther : INumberBase => new(Vector3D.CreateTruncating(other.Row1), Vector3D.CreateTruncating(other.Row2), Vector3D.CreateTruncating(other.Row3), Vector3D.CreateTruncating(other.Row4)); - /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + /// Converts the components of this matrix to another type. + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Matrix4X3 As() where TOther : INumberBase => new(Row1.As(), Row2.As(), Row3.As(), Row4.As()); + /// Converts the components of this matrix to another type. + public Matrix4X3 AsChecked() + where TOther : INumberBase => + Matrix4X3.CreateChecked(this); + + /// Converts the components of this matrix to another type. + public Matrix4X3 AsSaturating() + where TOther : INumberBase => + Matrix4X3.CreateSaturating(this); + + /// Converts the components of this matrix to another type. + public Matrix4X3 AsTruncating() + where TOther : INumberBase => + Matrix4X3.CreateTruncating(this); + /// Computes the transpose of the matrix. public Matrix3X4 Transpose() => new(new(M11, M21, M31, M41), diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index b2ffa73373..49bae4e98a 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -205,27 +205,42 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix4X4 CreateChecked(Matrix4X4 other) where TOther : INumberBase => new(Vector4D.CreateChecked(other.Row1), Vector4D.CreateChecked(other.Row2), Vector4D.CreateChecked(other.Row3), Vector4D.CreateChecked(other.Row4)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix4X4 CreateSaturating(Matrix4X4 other) where TOther : INumberBase => new(Vector4D.CreateSaturating(other.Row1), Vector4D.CreateSaturating(other.Row2), Vector4D.CreateSaturating(other.Row3), Vector4D.CreateSaturating(other.Row4)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix4X4 CreateTruncating(Matrix4X4 other) where TOther : INumberBase => new(Vector4D.CreateTruncating(other.Row1), Vector4D.CreateTruncating(other.Row2), Vector4D.CreateTruncating(other.Row3), Vector4D.CreateTruncating(other.Row4)); - /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + /// Converts the components of this matrix to another type. + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Matrix4X4 As() where TOther : INumberBase => new(Row1.As(), Row2.As(), Row3.As(), Row4.As()); + /// Converts the components of this matrix to another type. + public Matrix4X4 AsChecked() + where TOther : INumberBase => + Matrix4X4.CreateChecked(this); + + /// Converts the components of this matrix to another type. + public Matrix4X4 AsSaturating() + where TOther : INumberBase => + Matrix4X4.CreateSaturating(this); + + /// Converts the components of this matrix to another type. + public Matrix4X4 AsTruncating() + where TOther : INumberBase => + Matrix4X4.CreateTruncating(this); + /// Computes the transpose of the matrix. public Matrix4X4 Transpose() => new(new(M11, M21, M31, M41), diff --git a/sources/Maths/Maths/Matrix5X4.gen.cs b/sources/Maths/Maths/Matrix5X4.gen.cs index af2e8a312e..7d95ce484a 100644 --- a/sources/Maths/Maths/Matrix5X4.gen.cs +++ b/sources/Maths/Maths/Matrix5X4.gen.cs @@ -207,27 +207,42 @@ public override string ToString() => /// public override int GetHashCode() => HashCode.Combine(Row1, Row2, Row3, Row4, Row5); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix5X4 CreateChecked(Matrix5X4 other) where TOther : INumberBase => new(Vector4D.CreateChecked(other.Row1), Vector4D.CreateChecked(other.Row2), Vector4D.CreateChecked(other.Row3), Vector4D.CreateChecked(other.Row4), Vector4D.CreateChecked(other.Row5)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix5X4 CreateSaturating(Matrix5X4 other) where TOther : INumberBase => new(Vector4D.CreateSaturating(other.Row1), Vector4D.CreateSaturating(other.Row2), Vector4D.CreateSaturating(other.Row3), Vector4D.CreateSaturating(other.Row4), Vector4D.CreateSaturating(other.Row5)); - /// Converts the components of this vector to another type. + /// Converts the components of this matrix to another type. public static Matrix5X4 CreateTruncating(Matrix5X4 other) where TOther : INumberBase => new(Vector4D.CreateTruncating(other.Row1), Vector4D.CreateTruncating(other.Row2), Vector4D.CreateTruncating(other.Row3), Vector4D.CreateTruncating(other.Row4), Vector4D.CreateTruncating(other.Row5)); - /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating or cast instead.", error: false)] + /// Converts the components of this matrix to another type. + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Matrix5X4 As() where TOther : INumberBase => new(Row1.As(), Row2.As(), Row3.As(), Row4.As(), Row5.As()); + /// Converts the components of this matrix to another type. + public Matrix5X4 AsChecked() + where TOther : INumberBase => + Matrix5X4.CreateChecked(this); + + /// Converts the components of this matrix to another type. + public Matrix5X4 AsSaturating() + where TOther : INumberBase => + Matrix5X4.CreateSaturating(this); + + /// Converts the components of this matrix to another type. + public Matrix5X4 AsTruncating() + where TOther : INumberBase => + Matrix5X4.CreateTruncating(this); + /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. /// The second matrix to compare. diff --git a/sources/Maths/Maths/Plane.cs b/sources/Maths/Maths/Plane.cs index f14e3f989f..39a7164f86 100644 --- a/sources/Maths/Maths/Plane.cs +++ b/sources/Maths/Maths/Plane.cs @@ -175,7 +175,7 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new(from.Normal.As(), short.CreateSaturating(from.Distance)); + => new(from.Normal.AsSaturating(), short.CreateSaturating(from.Distance)); /// /// Converts a into one with a of @@ -214,6 +214,7 @@ public static explicit operator Plane(Plane from) /// /// The type to cast to /// The casted plane + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Plane As() where TOther : INumberBase { return new(Normal.As(), Scalar.As(Distance)); diff --git a/sources/Maths/Maths/Ray2D.cs b/sources/Maths/Maths/Ray2D.cs index 9980748f31..00b09dbcfe 100644 --- a/sources/Maths/Maths/Ray2D.cs +++ b/sources/Maths/Maths/Ray2D.cs @@ -124,12 +124,13 @@ public override int GetHashCode() { return !value1.Equals(value2); } - + /// /// Returns this ray casted to /// /// The type to cast to /// The casted ray + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Ray2D As() where TOther : INumberBase { diff --git a/sources/Maths/Maths/Ray3D.cs b/sources/Maths/Maths/Ray3D.cs index b73feceb17..44f14aab0f 100644 --- a/sources/Maths/Maths/Ray3D.cs +++ b/sources/Maths/Maths/Ray3D.cs @@ -128,12 +128,13 @@ public override int GetHashCode() { return !value1.Equals(value2); } - + /// /// Returns this ray casted to /// /// The type to cast to /// The casted ray + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Ray3D As() where TOther : INumberBase { return new(Origin.As(), Direction.As()); diff --git a/sources/Maths/Maths/Rectangle.cs b/sources/Maths/Maths/Rectangle.cs index db90d7032b..86198c30b8 100644 --- a/sources/Maths/Maths/Rectangle.cs +++ b/sources/Maths/Maths/Rectangle.cs @@ -164,10 +164,10 @@ public Rectangle GetScaled(Vector2D scale, Vector2D anchor) public Rectangle GetScaled(Vector2D scale, Vector2D anchor) where TScale : INumberBase { - var convertedAnchor = anchor.As(); - var min = (scale * (Origin.As() - convertedAnchor)) + convertedAnchor; - var max = (scale * (Max.As() - convertedAnchor)) + convertedAnchor; - return new(min.As(), (max - min).As()); + var convertedAnchor = anchor.AsTruncating(); + var min = (scale * (Origin.AsTruncating() - convertedAnchor)) + convertedAnchor; + var max = (scale * (Max.AsTruncating() - convertedAnchor)) + convertedAnchor; + return new(min.AsTruncating(), (max - min).AsTruncating()); } /// @@ -222,12 +222,13 @@ public override int GetHashCode() { return !value1.Equals(value2); } - + /// /// Returns this rectangle casted to /// /// The type to cast to /// The casted rectangle + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Rectangle As() where TOther : INumber { diff --git a/sources/Maths/Maths/Sphere.cs b/sources/Maths/Maths/Sphere.cs index 759a13290a..7c44cf801c 100644 --- a/sources/Maths/Maths/Sphere.cs +++ b/sources/Maths/Maths/Sphere.cs @@ -170,6 +170,7 @@ public override int GetHashCode() /// /// The type to cast to /// The casted sphere + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Sphere As() where TOther : IRootFunctions { diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index 3d7286547d..45d3b22c9e 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -316,11 +316,26 @@ public static Vector2D CreateTruncating(Vector2D source) new(T.CreateTruncating(source.X), T.CreateTruncating(source.Y)); /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating, or a cast instead.", error: false)] + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Vector2D As() where TOther : INumberBase => Vector2D.CreateTruncating(this); + /// Converts the components of this vector to another type. + public Vector2D AsChecked() + where TOther : INumberBase => + Vector2D.CreateChecked(this); + + /// Converts the components of this vector to another type. + public Vector2D AsSaturating() + where TOther : INumberBase => + Vector2D.CreateSaturating(this); + + /// Converts the components of this vector to another type. + public Vector2D AsTruncating() + where TOther : INumberBase => + Vector2D.CreateTruncating(this); + /// Implicitly casts a to a . public static implicit operator Vector2D((T X, T Y) v) => new(v.X, v.Y); @@ -572,6 +587,7 @@ public static partial class Vector2D } /// Desconstructs a vector into its components. + /// The vector to deconstruct. /// The X component. /// The Y component. public static void Deconstruct(this Vector2D vector, out T x, out T y) diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index b6572cd47f..2cf015c394 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -353,11 +353,26 @@ public static Vector3D CreateTruncating(Vector3D source) new(T.CreateTruncating(source.X), T.CreateTruncating(source.Y), T.CreateTruncating(source.Z)); /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating, or a cast instead.", error: false)] + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Vector3D As() where TOther : INumberBase => Vector3D.CreateTruncating(this); + /// Converts the components of this vector to another type. + public Vector3D AsChecked() + where TOther : INumberBase => + Vector3D.CreateChecked(this); + + /// Converts the components of this vector to another type. + public Vector3D AsSaturating() + where TOther : INumberBase => + Vector3D.CreateSaturating(this); + + /// Converts the components of this vector to another type. + public Vector3D AsTruncating() + where TOther : INumberBase => + Vector3D.CreateTruncating(this); + /// Implicitly casts a to a . public static implicit operator Vector3D((T X, T Y, T Z) v) => new(v.X, v.Y, v.Z); @@ -609,6 +624,7 @@ public static partial class Vector3D } /// Desconstructs a vector into its components. + /// The vector to deconstruct. /// The X component. /// The Y component. /// The Z component. diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index ed84851eb8..ecd849ca15 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -390,11 +390,26 @@ public static Vector4D CreateTruncating(Vector4D source) new(T.CreateTruncating(source.X), T.CreateTruncating(source.Y), T.CreateTruncating(source.Z), T.CreateTruncating(source.W)); /// Converts the components of this vector to another type. - [Obsolete("Use CreateChecked, CreateSaturating, CreateTruncating, or a cast instead.", error: false)] + [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Vector4D As() where TOther : INumberBase => Vector4D.CreateTruncating(this); + /// Converts the components of this vector to another type. + public Vector4D AsChecked() + where TOther : INumberBase => + Vector4D.CreateChecked(this); + + /// Converts the components of this vector to another type. + public Vector4D AsSaturating() + where TOther : INumberBase => + Vector4D.CreateSaturating(this); + + /// Converts the components of this vector to another type. + public Vector4D AsTruncating() + where TOther : INumberBase => + Vector4D.CreateTruncating(this); + /// Implicitly casts a to a . public static implicit operator Vector4D((T X, T Y, T Z, T W) v) => new(v.X, v.Y, v.Z, v.W); @@ -646,6 +661,7 @@ public static partial class Vector4D } /// Desconstructs a vector into its components. + /// The vector to deconstruct. /// The X component. /// The Y component. /// The Z component. From 2d6c95bee1de0bb6d09eb97e9ee8dc2a3ec2bef4 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 20:59:46 -0700 Subject: [PATCH 51/67] XML Doc Comments. --- sources/Maths/Maths/Matrix2X2.gen.cs | 2 +- sources/Maths/Maths/Matrix2X3.gen.cs | 2 +- sources/Maths/Maths/Matrix2X4.gen.cs | 2 +- sources/Maths/Maths/Matrix3X2.gen.cs | 2 +- sources/Maths/Maths/Matrix3X3.gen.cs | 2 +- sources/Maths/Maths/Matrix3X4.gen.cs | 2 +- sources/Maths/Maths/Matrix4X2.gen.cs | 2 +- sources/Maths/Maths/Matrix4X3.gen.cs | 2 +- sources/Maths/Maths/Matrix4X4.gen.cs | 2 +- sources/Maths/Maths/Matrix5X4.gen.cs | 2 +- sources/Maths/Maths/Vector2D.gen.cs | 54 ++++++++++++++++++++++++++++ sources/Maths/Maths/Vector3D.gen.cs | 54 ++++++++++++++++++++++++++++ sources/Maths/Maths/Vector4D.gen.cs | 54 ++++++++++++++++++++++++++++ 13 files changed, 172 insertions(+), 10 deletions(-) diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index c78d2f83c9..36d8a000cb 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -451,7 +451,7 @@ public static explicit operator checked Matrix2X2(Matrix2X2 from) => } /// - /// Methods for working with + /// Methods for working with . /// public static partial class Matrix2X2 { diff --git a/sources/Maths/Maths/Matrix2X3.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs index f0a222eaae..bff4862b07 100644 --- a/sources/Maths/Maths/Matrix2X3.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -465,7 +465,7 @@ public static explicit operator checked Matrix2X3(Matrix2X3 from) => } /// - /// Methods for working with + /// Methods for working with . /// public static partial class Matrix2X3 { diff --git a/sources/Maths/Maths/Matrix2X4.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs index ea7aed2896..708458f69b 100644 --- a/sources/Maths/Maths/Matrix2X4.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -489,7 +489,7 @@ public static explicit operator checked Matrix2X4(Matrix2X4 from) => } /// - /// Methods for working with + /// Methods for working with . /// public static partial class Matrix2X4 { diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index 8f27467b3a..792f84ebaa 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -501,7 +501,7 @@ public static explicit operator checked Matrix3X2(Matrix3X2 from) => } /// - /// Methods for working with + /// Methods for working with . /// public static partial class Matrix3X2 { diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index 5718ab5f6c..8bc8ec7c86 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -539,7 +539,7 @@ public static explicit operator checked Matrix3X3(Matrix3X3 from) => } /// - /// Methods for working with + /// Methods for working with . /// public static partial class Matrix3X3 { diff --git a/sources/Maths/Maths/Matrix3X4.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs index 202f179523..2df43ee04c 100644 --- a/sources/Maths/Maths/Matrix3X4.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -558,7 +558,7 @@ public static explicit operator checked Matrix3X4(Matrix3X4 from) => } /// - /// Methods for working with + /// Methods for working with . /// public static partial class Matrix3X4 { diff --git a/sources/Maths/Maths/Matrix4X2.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs index 7fa9e127b0..3b147c1b97 100644 --- a/sources/Maths/Maths/Matrix4X2.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -562,7 +562,7 @@ public static explicit operator checked Matrix4X2(Matrix4X2 from) => } /// - /// Methods for working with + /// Methods for working with . /// public static partial class Matrix4X2 { diff --git a/sources/Maths/Maths/Matrix4X3.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs index 47e77e6519..85ef245f27 100644 --- a/sources/Maths/Maths/Matrix4X3.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -595,7 +595,7 @@ public static explicit operator checked Matrix4X3(Matrix4X3 from) => } /// - /// Methods for working with + /// Methods for working with . /// public static partial class Matrix4X3 { diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index 49bae4e98a..0fcdce95cf 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -640,7 +640,7 @@ public static explicit operator checked Matrix4X4(Matrix4X4 from) => } /// - /// Methods for working with + /// Methods for working with . /// public static partial class Matrix4X4 { diff --git a/sources/Maths/Maths/Matrix5X4.gen.cs b/sources/Maths/Maths/Matrix5X4.gen.cs index 7d95ce484a..6da344fa18 100644 --- a/sources/Maths/Maths/Matrix5X4.gen.cs +++ b/sources/Maths/Maths/Matrix5X4.gen.cs @@ -615,7 +615,7 @@ public static explicit operator checked Matrix5X4(Matrix5X4 from) => } /// - /// Methods for working with + /// Methods for working with . /// public static partial class Matrix5X4 { diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index 45d3b22c9e..79b4f1297d 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -344,36 +344,78 @@ public static implicit operator Vector2D((T X, T Y) v) => public static implicit operator (T X, T Y)(Vector2D v) => (v.X, v.Y); + /// Returns the given vector. + /// The source vector. + /// The source vector. public static Vector2D operator +(Vector2D vector) => vector; + /// Negates a given vector. + /// The source vector. + /// The negated vector. public static Vector2D operator -(Vector2D vector) => new(-vector.X, -vector.Y); + /// Adds two vectors together. + /// The first source vector. + /// The second source vector. + /// The summed vector. public static Vector2D operator +(Vector2D left, Vector2D right) => new(left.X + right.X, left.Y + right.Y); + /// Subtracts the second vector from the first. + /// The first source vector. + /// The second source vector. + /// The difference vector. public static Vector2D operator -(Vector2D left, Vector2D right) => new(left.X - right.X, left.Y - right.Y); + /// Multiplies two vectors together. + /// The first source vector. + /// The second source vector. + /// The product vector. public static Vector2D operator *(Vector2D left, Vector2D right) => new(left.X * right.X, left.Y * right.Y); + /// Divides the first vector by the second. + /// The first source vector. + /// The second source vector. + /// The vector resulting from the division. public static Vector2D operator /(Vector2D left, Vector2D right) => new(left.X / right.X, left.Y / right.Y); + /// Adds a scalar to the components of a vector. + /// The source vector. + /// The scalar value. + /// The offset vector. public static Vector2D operator +(Vector2D vector, T scalar) => new(vector.X + scalar, vector.Y + scalar); + /// Subtracts a scalar from the components of a vector. + /// The source vector. + /// The scalar value. + /// The offset vector. public static Vector2D operator -(Vector2D vector, T scalar) => new(vector.X - scalar, vector.Y - scalar); + /// Multiplies a vector by the given scalar. + /// The source vector. + /// The scalar value. + /// The scaled vector. public static Vector2D operator *(Vector2D vector, T scalar) => new(vector.X * scalar, vector.Y * scalar); + /// Multiplies a vector by the given scalar. + /// The scalar value. + /// The source vector. + /// The scaled vector. public static Vector2D operator *(T scalar, Vector2D vector) => new(scalar * vector.X, scalar * vector.Y); + /// Divides the vector by the given scalar. + /// The source vector. + /// The scalar value. + /// The result of the division. public static Vector2D operator /(Vector2D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar); @@ -570,8 +612,12 @@ public static explicit operator checked Vector2D(Vector2D from) => Vector2D.CreateChecked(from); } + /// + /// Methods for working with . + /// public static partial class Vector2D { + /// Extensions for vectors with elements implementing . extension(Vector2D vector) where T : IRootFunctions { @@ -579,6 +625,7 @@ public static partial class Vector2D public T Length => T.Sqrt(vector.LengthSquared); } + /// Extensions for vectors with elements implementing . extension(Vector2D vector) where T : INumberBase { @@ -648,14 +695,21 @@ public static Vector2D LerpClamped(Vector2D a, Vector2D b, Vector2D< new(T.Lerp(a.X, b.X, T.Clamp(amount.X, T.Zero, T.One)), T.Lerp(a.Y, b.Y, T.Clamp(amount.Y, T.Zero, T.One))); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static (Vector2D Sin, Vector2D Cos) SinCos(this Vector2D x) where T : ITrigonometricFunctions => (new(T.Sin(x.X), T.Sin(x.Y)), new(T.Cos(x.X), T.Cos(x.Y))); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static (Vector2D SinPi, Vector2D CosPi) SinCosPi(this Vector2D x) where T : ITrigonometricFunctions => (new(T.SinPi(x.X), T.SinPi(x.Y)), new(T.CosPi(x.X), T.CosPi(x.Y))); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . public static (Vector2D Quotient, Vector2D Remainder) DivRem(Vector2D left, Vector2D right) where T : IBinaryInteger { diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index 2cf015c394..769dd516b2 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -381,36 +381,78 @@ public static implicit operator Vector3D((T X, T Y, T Z) v) => public static implicit operator (T X, T Y, T Z)(Vector3D v) => (v.X, v.Y, v.Z); + /// Returns the given vector. + /// The source vector. + /// The source vector. public static Vector3D operator +(Vector3D vector) => vector; + /// Negates a given vector. + /// The source vector. + /// The negated vector. public static Vector3D operator -(Vector3D vector) => new(-vector.X, -vector.Y, -vector.Z); + /// Adds two vectors together. + /// The first source vector. + /// The second source vector. + /// The summed vector. public static Vector3D operator +(Vector3D left, Vector3D right) => new(left.X + right.X, left.Y + right.Y, left.Z + right.Z); + /// Subtracts the second vector from the first. + /// The first source vector. + /// The second source vector. + /// The difference vector. public static Vector3D operator -(Vector3D left, Vector3D right) => new(left.X - right.X, left.Y - right.Y, left.Z - right.Z); + /// Multiplies two vectors together. + /// The first source vector. + /// The second source vector. + /// The product vector. public static Vector3D operator *(Vector3D left, Vector3D right) => new(left.X * right.X, left.Y * right.Y, left.Z * right.Z); + /// Divides the first vector by the second. + /// The first source vector. + /// The second source vector. + /// The vector resulting from the division. public static Vector3D operator /(Vector3D left, Vector3D right) => new(left.X / right.X, left.Y / right.Y, left.Z / right.Z); + /// Adds a scalar to the components of a vector. + /// The source vector. + /// The scalar value. + /// The offset vector. public static Vector3D operator +(Vector3D vector, T scalar) => new(vector.X + scalar, vector.Y + scalar, vector.Z + scalar); + /// Subtracts a scalar from the components of a vector. + /// The source vector. + /// The scalar value. + /// The offset vector. public static Vector3D operator -(Vector3D vector, T scalar) => new(vector.X - scalar, vector.Y - scalar, vector.Z - scalar); + /// Multiplies a vector by the given scalar. + /// The source vector. + /// The scalar value. + /// The scaled vector. public static Vector3D operator *(Vector3D vector, T scalar) => new(vector.X * scalar, vector.Y * scalar, vector.Z * scalar); + /// Multiplies a vector by the given scalar. + /// The scalar value. + /// The source vector. + /// The scaled vector. public static Vector3D operator *(T scalar, Vector3D vector) => new(scalar * vector.X, scalar * vector.Y, scalar * vector.Z); + /// Divides the vector by the given scalar. + /// The source vector. + /// The scalar value. + /// The result of the division. public static Vector3D operator /(Vector3D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); @@ -607,8 +649,12 @@ public static explicit operator checked Vector3D(Vector3D from) => Vector3D.CreateChecked(from); } + /// + /// Methods for working with . + /// public static partial class Vector3D { + /// Extensions for vectors with elements implementing . extension(Vector3D vector) where T : IRootFunctions { @@ -616,6 +662,7 @@ public static partial class Vector3D public T Length => T.Sqrt(vector.LengthSquared); } + /// Extensions for vectors with elements implementing . extension(Vector3D vector) where T : INumberBase { @@ -688,14 +735,21 @@ public static Vector3D LerpClamped(Vector3D a, Vector3D b, Vector3D< T.Lerp(a.Y, b.Y, T.Clamp(amount.Y, T.Zero, T.One)), T.Lerp(a.Z, b.Z, T.Clamp(amount.Z, T.Zero, T.One))); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static (Vector3D Sin, Vector3D Cos) SinCos(this Vector3D x) where T : ITrigonometricFunctions => (new(T.Sin(x.X), T.Sin(x.Y), T.Sin(x.Z)), new(T.Cos(x.X), T.Cos(x.Y), T.Cos(x.Z))); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static (Vector3D SinPi, Vector3D CosPi) SinCosPi(this Vector3D x) where T : ITrigonometricFunctions => (new(T.SinPi(x.X), T.SinPi(x.Y), T.SinPi(x.Z)), new(T.CosPi(x.X), T.CosPi(x.Y), T.CosPi(x.Z))); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . public static (Vector3D Quotient, Vector3D Remainder) DivRem(Vector3D left, Vector3D right) where T : IBinaryInteger { diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index ecd849ca15..6f7e2d978c 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -418,36 +418,78 @@ public static implicit operator Vector4D((T X, T Y, T Z, T W) v) => public static implicit operator (T X, T Y, T Z, T W)(Vector4D v) => (v.X, v.Y, v.Z, v.W); + /// Returns the given vector. + /// The source vector. + /// The source vector. public static Vector4D operator +(Vector4D vector) => vector; + /// Negates a given vector. + /// The source vector. + /// The negated vector. public static Vector4D operator -(Vector4D vector) => new(-vector.X, -vector.Y, -vector.Z, -vector.W); + /// Adds two vectors together. + /// The first source vector. + /// The second source vector. + /// The summed vector. public static Vector4D operator +(Vector4D left, Vector4D right) => new(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); + /// Subtracts the second vector from the first. + /// The first source vector. + /// The second source vector. + /// The difference vector. public static Vector4D operator -(Vector4D left, Vector4D right) => new(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); + /// Multiplies two vectors together. + /// The first source vector. + /// The second source vector. + /// The product vector. public static Vector4D operator *(Vector4D left, Vector4D right) => new(left.X * right.X, left.Y * right.Y, left.Z * right.Z, left.W * right.W); + /// Divides the first vector by the second. + /// The first source vector. + /// The second source vector. + /// The vector resulting from the division. public static Vector4D operator /(Vector4D left, Vector4D right) => new(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W); + /// Adds a scalar to the components of a vector. + /// The source vector. + /// The scalar value. + /// The offset vector. public static Vector4D operator +(Vector4D vector, T scalar) => new(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar); + /// Subtracts a scalar from the components of a vector. + /// The source vector. + /// The scalar value. + /// The offset vector. public static Vector4D operator -(Vector4D vector, T scalar) => new(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar); + /// Multiplies a vector by the given scalar. + /// The source vector. + /// The scalar value. + /// The scaled vector. public static Vector4D operator *(Vector4D vector, T scalar) => new(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar); + /// Multiplies a vector by the given scalar. + /// The scalar value. + /// The source vector. + /// The scaled vector. public static Vector4D operator *(T scalar, Vector4D vector) => new(scalar * vector.X, scalar * vector.Y, scalar * vector.Z, scalar * vector.W); + /// Divides the vector by the given scalar. + /// The source vector. + /// The scalar value. + /// The result of the division. public static Vector4D operator /(Vector4D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); @@ -644,8 +686,12 @@ public static explicit operator checked Vector4D(Vector4D from) => Vector4D.CreateChecked(from); } + /// + /// Methods for working with . + /// public static partial class Vector4D { + /// Extensions for vectors with elements implementing . extension(Vector4D vector) where T : IRootFunctions { @@ -653,6 +699,7 @@ public static partial class Vector4D public T Length => T.Sqrt(vector.LengthSquared); } + /// Extensions for vectors with elements implementing . extension(Vector4D vector) where T : INumberBase { @@ -728,14 +775,21 @@ public static Vector4D LerpClamped(Vector4D a, Vector4D b, Vector4D< T.Lerp(a.Z, b.Z, T.Clamp(amount.Z, T.Zero, T.One)), T.Lerp(a.W, b.W, T.Clamp(amount.W, T.Zero, T.One))); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static (Vector4D Sin, Vector4D Cos) SinCos(this Vector4D x) where T : ITrigonometricFunctions => (new(T.Sin(x.X), T.Sin(x.Y), T.Sin(x.Z), T.Sin(x.W)), new(T.Cos(x.X), T.Cos(x.Y), T.Cos(x.Z), T.Cos(x.W))); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . public static (Vector4D SinPi, Vector4D CosPi) SinCosPi(this Vector4D x) where T : ITrigonometricFunctions => (new(T.SinPi(x.X), T.SinPi(x.Y), T.SinPi(x.Z), T.SinPi(x.W)), new(T.CosPi(x.X), T.CosPi(x.Y), T.CosPi(x.Z), T.CosPi(x.W))); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . public static (Vector4D Quotient, Vector4D Remainder) DivRem(Vector4D left, Vector4D right) where T : IBinaryInteger { From 1c2b6f87becb358dd0c44f1e2c79437c490ec684 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Wed, 2 Jul 2025 21:15:23 -0700 Subject: [PATCH 52/67] Reset APIs. --- .../PublicAPI/net8.0/PublicAPI.Shipped.txt | 1418 ------------- .../PublicAPI/net8.0/PublicAPI.Unshipped.txt | 1872 +++++++++++++++++ 2 files changed, 1872 insertions(+), 1418 deletions(-) diff --git a/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Shipped.txt b/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Shipped.txt index 3552eec334..7dc5c58110 100644 --- a/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Shipped.txt +++ b/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Shipped.txt @@ -1,1419 +1 @@ #nullable enable -override Silk.NET.Maths.Box2D.Equals(object? obj) -> bool -override Silk.NET.Maths.Box2D.GetHashCode() -> int -override Silk.NET.Maths.Box3D.Equals(object? obj) -> bool -override Silk.NET.Maths.Box3D.GetHashCode() -> int -override Silk.NET.Maths.Circle.Equals(object? obj) -> bool -override Silk.NET.Maths.Circle.GetHashCode() -> int -override Silk.NET.Maths.Cube.Equals(object? obj) -> bool -override Silk.NET.Maths.Cube.GetHashCode() -> int -override Silk.NET.Maths.Matrix2X2.Equals(object? obj) -> bool -override Silk.NET.Maths.Matrix2X2.GetHashCode() -> int -override Silk.NET.Maths.Matrix2X2.ToString() -> string! -override Silk.NET.Maths.Matrix2X3.Equals(object? obj) -> bool -override Silk.NET.Maths.Matrix2X3.GetHashCode() -> int -override Silk.NET.Maths.Matrix2X3.ToString() -> string! -override Silk.NET.Maths.Matrix2X4.Equals(object? obj) -> bool -override Silk.NET.Maths.Matrix2X4.GetHashCode() -> int -override Silk.NET.Maths.Matrix2X4.ToString() -> string! -override Silk.NET.Maths.Matrix3X2.Equals(object? obj) -> bool -override Silk.NET.Maths.Matrix3X2.GetHashCode() -> int -override Silk.NET.Maths.Matrix3X2.ToString() -> string! -override Silk.NET.Maths.Matrix3X3.Equals(object? obj) -> bool -override Silk.NET.Maths.Matrix3X3.GetHashCode() -> int -override Silk.NET.Maths.Matrix3X3.ToString() -> string! -override Silk.NET.Maths.Matrix3X4.Equals(object? obj) -> bool -override Silk.NET.Maths.Matrix3X4.GetHashCode() -> int -override Silk.NET.Maths.Matrix3X4.ToString() -> string! -override Silk.NET.Maths.Matrix4X2.Equals(object? obj) -> bool -override Silk.NET.Maths.Matrix4X2.GetHashCode() -> int -override Silk.NET.Maths.Matrix4X2.ToString() -> string! -override Silk.NET.Maths.Matrix4X3.Equals(object? obj) -> bool -override Silk.NET.Maths.Matrix4X3.GetHashCode() -> int -override Silk.NET.Maths.Matrix4X3.ToString() -> string! -override Silk.NET.Maths.Matrix4X4.Equals(object? obj) -> bool -override Silk.NET.Maths.Matrix4X4.GetHashCode() -> int -override Silk.NET.Maths.Matrix4X4.ToString() -> string! -override Silk.NET.Maths.Matrix5X4.Equals(object? obj) -> bool -override Silk.NET.Maths.Matrix5X4.GetHashCode() -> int -override Silk.NET.Maths.Matrix5X4.ToString() -> string! -override Silk.NET.Maths.Plane.Equals(object? obj) -> bool -override Silk.NET.Maths.Plane.GetHashCode() -> int -override Silk.NET.Maths.Plane.ToString() -> string! -override Silk.NET.Maths.Quaternion.Equals(object? obj) -> bool -override Silk.NET.Maths.Quaternion.GetHashCode() -> int -override Silk.NET.Maths.Quaternion.ToString() -> string! -override Silk.NET.Maths.Ray2D.Equals(object? obj) -> bool -override Silk.NET.Maths.Ray2D.GetHashCode() -> int -override Silk.NET.Maths.Ray3D.Equals(object? obj) -> bool -override Silk.NET.Maths.Ray3D.GetHashCode() -> int -override Silk.NET.Maths.Rectangle.Equals(object? obj) -> bool -override Silk.NET.Maths.Rectangle.GetHashCode() -> int -override Silk.NET.Maths.Sphere.Equals(object? obj) -> bool -override Silk.NET.Maths.Sphere.GetHashCode() -> int -override Silk.NET.Maths.Vector2D.Equals(object? obj) -> bool -override Silk.NET.Maths.Vector2D.GetHashCode() -> int -override Silk.NET.Maths.Vector2D.ToString() -> string! -override Silk.NET.Maths.Vector3D.Equals(object? obj) -> bool -override Silk.NET.Maths.Vector3D.GetHashCode() -> int -override Silk.NET.Maths.Vector3D.ToString() -> string! -override Silk.NET.Maths.Vector4D.Equals(object? obj) -> bool -override Silk.NET.Maths.Vector4D.GetHashCode() -> int -override Silk.NET.Maths.Vector4D.ToString() -> string! -Silk.NET.Maths.Box2D -Silk.NET.Maths.Box2D.As() -> Silk.NET.Maths.Box2D -Silk.NET.Maths.Box2D.Box2D() -> void -Silk.NET.Maths.Box2D.Box2D(Silk.NET.Maths.Vector2D min, Silk.NET.Maths.Vector2D max) -> void -Silk.NET.Maths.Box2D.Box2D(Silk.NET.Maths.Vector2D min, T maxX, T maxY) -> void -Silk.NET.Maths.Box2D.Box2D(T minX, T minY, Silk.NET.Maths.Vector2D max) -> void -Silk.NET.Maths.Box2D.Box2D(T minX, T minY, T maxX, T maxY) -> void -Silk.NET.Maths.Box2D.Center.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Box2D.Contains(Silk.NET.Maths.Box2D other) -> bool -Silk.NET.Maths.Box2D.Contains(Silk.NET.Maths.Vector2D point) -> bool -Silk.NET.Maths.Box2D.Equals(Silk.NET.Maths.Box2D other) -> bool -Silk.NET.Maths.Box2D.GetDistanceToNearestEdge(Silk.NET.Maths.Vector2D point) -> T -Silk.NET.Maths.Box2D.GetInflated(Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Box2D -Silk.NET.Maths.Box2D.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Box2D -Silk.NET.Maths.Box2D.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Box2D -Silk.NET.Maths.Box2D.GetTranslated(Silk.NET.Maths.Vector2D distance) -> Silk.NET.Maths.Box2D -Silk.NET.Maths.Box2D.Max -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Box2D.Min -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Box2D.Size.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Box3D -Silk.NET.Maths.Box3D.As() -> Silk.NET.Maths.Box3D -Silk.NET.Maths.Box3D.Box3D() -> void -Silk.NET.Maths.Box3D.Box3D(Silk.NET.Maths.Vector3D min, Silk.NET.Maths.Vector3D max) -> void -Silk.NET.Maths.Box3D.Box3D(Silk.NET.Maths.Vector3D min, T maxX, T maxY, T maxZ) -> void -Silk.NET.Maths.Box3D.Box3D(T minX, T minY, T minZ, Silk.NET.Maths.Vector3D max) -> void -Silk.NET.Maths.Box3D.Box3D(T minX, T minY, T minZ, T maxX, T maxY, T maxZ) -> void -Silk.NET.Maths.Box3D.Center.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Box3D.Contains(Silk.NET.Maths.Box3D other) -> bool -Silk.NET.Maths.Box3D.Contains(Silk.NET.Maths.Vector3D point) -> bool -Silk.NET.Maths.Box3D.Equals(Silk.NET.Maths.Box3D other) -> bool -Silk.NET.Maths.Box3D.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D point) -> T -Silk.NET.Maths.Box3D.GetInflated(Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Box3D -Silk.NET.Maths.Box3D.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Box3D -Silk.NET.Maths.Box3D.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Box3D -Silk.NET.Maths.Box3D.GetTranslated(Silk.NET.Maths.Vector3D distance) -> Silk.NET.Maths.Box3D -Silk.NET.Maths.Box3D.Max -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Box3D.Min -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Box3D.Size.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Circle -Silk.NET.Maths.Circle.As() -> Silk.NET.Maths.Circle -Silk.NET.Maths.Circle.Center -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Circle.Circle() -> void -Silk.NET.Maths.Circle.Circle(Silk.NET.Maths.Vector2D center, T radius) -> void -Silk.NET.Maths.Circle.Circle(T centerX, T centerY, T radius) -> void -Silk.NET.Maths.Circle.Circumference.get -> T -Silk.NET.Maths.Circle.Contains(Silk.NET.Maths.Circle other) -> bool -Silk.NET.Maths.Circle.Contains(Silk.NET.Maths.Vector2D point) -> bool -Silk.NET.Maths.Circle.Diameter.get -> T -Silk.NET.Maths.Circle.Equals(Silk.NET.Maths.Circle other) -> bool -Silk.NET.Maths.Circle.GetDistanceToNearestEdge(Silk.NET.Maths.Vector2D point) -> T -Silk.NET.Maths.Circle.GetDistanceToNearestEdgeSquared(Silk.NET.Maths.Vector2D point) -> T -Silk.NET.Maths.Circle.GetInflated(Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Circle -Silk.NET.Maths.Circle.GetTranslated(Silk.NET.Maths.Vector2D distance) -> Silk.NET.Maths.Circle -Silk.NET.Maths.Circle.Radius -> T -Silk.NET.Maths.Circle.SquaredRadius.get -> T -Silk.NET.Maths.Cube -Silk.NET.Maths.Cube.As() -> Silk.NET.Maths.Cube -Silk.NET.Maths.Cube.Center.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Cube.Contains(Silk.NET.Maths.Cube other) -> bool -Silk.NET.Maths.Cube.Contains(Silk.NET.Maths.Vector3D point) -> bool -Silk.NET.Maths.Cube.Cube() -> void -Silk.NET.Maths.Cube.Cube(Silk.NET.Maths.Vector3D origin, Silk.NET.Maths.Vector3D size) -> void -Silk.NET.Maths.Cube.Cube(Silk.NET.Maths.Vector3D origin, T sizeX, T sizeY, T sizeZ) -> void -Silk.NET.Maths.Cube.Cube(T originX, T originY, T originZ, Silk.NET.Maths.Vector3D size) -> void -Silk.NET.Maths.Cube.Cube(T originX, T originY, T originZ, T sizeX, T sizeY, T sizeZ) -> void -Silk.NET.Maths.Cube.Equals(Silk.NET.Maths.Cube other) -> bool -Silk.NET.Maths.Cube.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D point) -> T -Silk.NET.Maths.Cube.GetInflated(Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Cube -Silk.NET.Maths.Cube.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Cube -Silk.NET.Maths.Cube.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Cube -Silk.NET.Maths.Cube.GetTranslated(Silk.NET.Maths.Vector3D distance) -> Silk.NET.Maths.Cube -Silk.NET.Maths.Cube.HalfSize.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Cube.Max.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Cube.Origin -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Cube.Size -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix2X2 -Silk.NET.Maths.Matrix2X2 -Silk.NET.Maths.Matrix2X2.As() -> Silk.NET.Maths.Matrix2X2 -Silk.NET.Maths.Matrix2X2.Column1.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X2.Column2.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X2.Equals(Silk.NET.Maths.Matrix2X2 other) -> bool -Silk.NET.Maths.Matrix2X2.GetDeterminant() -> T -Silk.NET.Maths.Matrix2X2.IsIdentity.get -> bool -Silk.NET.Maths.Matrix2X2.M11.get -> T -Silk.NET.Maths.Matrix2X2.M11.set -> void -Silk.NET.Maths.Matrix2X2.M12.get -> T -Silk.NET.Maths.Matrix2X2.M12.set -> void -Silk.NET.Maths.Matrix2X2.M21.get -> T -Silk.NET.Maths.Matrix2X2.M21.set -> void -Silk.NET.Maths.Matrix2X2.M22.get -> T -Silk.NET.Maths.Matrix2X2.M22.set -> void -Silk.NET.Maths.Matrix2X2.Matrix2X2() -> void -Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Matrix2X4 value) -> void -Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Matrix3X2 value) -> void -Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Matrix3X4 value) -> void -Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Matrix4X2 value) -> void -Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Matrix4X3 value) -> void -Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Vector2D row1, Silk.NET.Maths.Vector2D row2) -> void -Silk.NET.Maths.Matrix2X2.Matrix2X2(T m11, T m12, T m21, T m22) -> void -Silk.NET.Maths.Matrix2X2.Row1 -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X2.Row2 -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X2.this[int x, int y].get -> T -Silk.NET.Maths.Matrix2X2.this[int x].get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X3 -Silk.NET.Maths.Matrix2X3 -Silk.NET.Maths.Matrix2X3.As() -> Silk.NET.Maths.Matrix2X3 -Silk.NET.Maths.Matrix2X3.Column1.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X3.Column2.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X3.Column3.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X3.Equals(Silk.NET.Maths.Matrix2X3 other) -> bool -Silk.NET.Maths.Matrix2X3.IsIdentity.get -> bool -Silk.NET.Maths.Matrix2X3.M11.get -> T -Silk.NET.Maths.Matrix2X3.M11.set -> void -Silk.NET.Maths.Matrix2X3.M12.get -> T -Silk.NET.Maths.Matrix2X3.M12.set -> void -Silk.NET.Maths.Matrix2X3.M13.get -> T -Silk.NET.Maths.Matrix2X3.M13.set -> void -Silk.NET.Maths.Matrix2X3.M21.get -> T -Silk.NET.Maths.Matrix2X3.M21.set -> void -Silk.NET.Maths.Matrix2X3.M22.get -> T -Silk.NET.Maths.Matrix2X3.M22.set -> void -Silk.NET.Maths.Matrix2X3.M23.get -> T -Silk.NET.Maths.Matrix2X3.M23.set -> void -Silk.NET.Maths.Matrix2X3.Matrix2X3() -> void -Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Matrix2X4 value) -> void -Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Matrix3X2 value) -> void -Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Matrix3X4 value) -> void -Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Matrix4X2 value) -> void -Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Matrix4X3 value) -> void -Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Vector3D row1, Silk.NET.Maths.Vector3D row2) -> void -Silk.NET.Maths.Matrix2X3.Matrix2X3(T m11, T m12, T m13, T m21, T m22, T m23) -> void -Silk.NET.Maths.Matrix2X3.Row1 -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix2X3.Row2 -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix2X3.this[int x, int y].get -> T -Silk.NET.Maths.Matrix2X3.this[int x].get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix2X4 -Silk.NET.Maths.Matrix2X4 -Silk.NET.Maths.Matrix2X4.As() -> Silk.NET.Maths.Matrix2X4 -Silk.NET.Maths.Matrix2X4.Column1.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X4.Column2.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X4.Column3.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X4.Column4.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X4.Equals(Silk.NET.Maths.Matrix2X4 other) -> bool -Silk.NET.Maths.Matrix2X4.IsIdentity.get -> bool -Silk.NET.Maths.Matrix2X4.M11.get -> T -Silk.NET.Maths.Matrix2X4.M11.set -> void -Silk.NET.Maths.Matrix2X4.M12.get -> T -Silk.NET.Maths.Matrix2X4.M12.set -> void -Silk.NET.Maths.Matrix2X4.M13.get -> T -Silk.NET.Maths.Matrix2X4.M13.set -> void -Silk.NET.Maths.Matrix2X4.M14.get -> T -Silk.NET.Maths.Matrix2X4.M14.set -> void -Silk.NET.Maths.Matrix2X4.M21.get -> T -Silk.NET.Maths.Matrix2X4.M21.set -> void -Silk.NET.Maths.Matrix2X4.M22.get -> T -Silk.NET.Maths.Matrix2X4.M22.set -> void -Silk.NET.Maths.Matrix2X4.M23.get -> T -Silk.NET.Maths.Matrix2X4.M23.set -> void -Silk.NET.Maths.Matrix2X4.M24.get -> T -Silk.NET.Maths.Matrix2X4.M24.set -> void -Silk.NET.Maths.Matrix2X4.Matrix2X4() -> void -Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Matrix3X2 value) -> void -Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Matrix3X3 value) -> void -Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Matrix3X4 value) -> void -Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Matrix4X2 value) -> void -Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Matrix4X3 value) -> void -Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Vector4D row1, Silk.NET.Maths.Vector4D row2) -> void -Silk.NET.Maths.Matrix2X4.Matrix2X4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24) -> void -Silk.NET.Maths.Matrix2X4.Row1 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix2X4.Row2 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix2X4.this[int x, int j].get -> T -Silk.NET.Maths.Matrix2X4.this[int x].get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix3X2 -Silk.NET.Maths.Matrix3X2 -Silk.NET.Maths.Matrix3X2.As() -> Silk.NET.Maths.Matrix3X2 -Silk.NET.Maths.Matrix3X2.Column1.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X2.Column2.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X2.Equals(Silk.NET.Maths.Matrix3X2 other) -> bool -Silk.NET.Maths.Matrix3X2.GetDeterminant() -> T -Silk.NET.Maths.Matrix3X2.IsIdentity.get -> bool -Silk.NET.Maths.Matrix3X2.M11.get -> T -Silk.NET.Maths.Matrix3X2.M11.set -> void -Silk.NET.Maths.Matrix3X2.M12.get -> T -Silk.NET.Maths.Matrix3X2.M12.set -> void -Silk.NET.Maths.Matrix3X2.M21.get -> T -Silk.NET.Maths.Matrix3X2.M21.set -> void -Silk.NET.Maths.Matrix3X2.M22.get -> T -Silk.NET.Maths.Matrix3X2.M22.set -> void -Silk.NET.Maths.Matrix3X2.M31.get -> T -Silk.NET.Maths.Matrix3X2.M31.set -> void -Silk.NET.Maths.Matrix3X2.M32.get -> T -Silk.NET.Maths.Matrix3X2.M32.set -> void -Silk.NET.Maths.Matrix3X2.Matrix3X2() -> void -Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Matrix2X4 value) -> void -Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Matrix3X3 value) -> void -Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Matrix3X4 value) -> void -Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Matrix4X2 value) -> void -Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Matrix4X3 value) -> void -Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Vector2D row1, Silk.NET.Maths.Vector2D row2, Silk.NET.Maths.Vector2D row3) -> void -Silk.NET.Maths.Matrix3X2.Matrix3X2(T m11, T m12, T m21, T m22, T m31, T m32) -> void -Silk.NET.Maths.Matrix3X2.Row1 -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix3X2.Row2 -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix3X2.Row3 -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix3X2.this[int x, int y].get -> T -Silk.NET.Maths.Matrix3X2.this[int x].get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix3X3 -Silk.NET.Maths.Matrix3X3 -Silk.NET.Maths.Matrix3X3.As() -> Silk.NET.Maths.Matrix3X3 -Silk.NET.Maths.Matrix3X3.Column1.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X3.Column2.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X3.Column3.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X3.Equals(Silk.NET.Maths.Matrix3X3 other) -> bool -Silk.NET.Maths.Matrix3X3.GetDeterminant() -> T -Silk.NET.Maths.Matrix3X3.IsIdentity.get -> bool -Silk.NET.Maths.Matrix3X3.M11.get -> T -Silk.NET.Maths.Matrix3X3.M11.set -> void -Silk.NET.Maths.Matrix3X3.M12.get -> T -Silk.NET.Maths.Matrix3X3.M12.set -> void -Silk.NET.Maths.Matrix3X3.M13.get -> T -Silk.NET.Maths.Matrix3X3.M13.set -> void -Silk.NET.Maths.Matrix3X3.M21.get -> T -Silk.NET.Maths.Matrix3X3.M21.set -> void -Silk.NET.Maths.Matrix3X3.M22.get -> T -Silk.NET.Maths.Matrix3X3.M22.set -> void -Silk.NET.Maths.Matrix3X3.M23.get -> T -Silk.NET.Maths.Matrix3X3.M23.set -> void -Silk.NET.Maths.Matrix3X3.M31.get -> T -Silk.NET.Maths.Matrix3X3.M31.set -> void -Silk.NET.Maths.Matrix3X3.M32.get -> T -Silk.NET.Maths.Matrix3X3.M32.set -> void -Silk.NET.Maths.Matrix3X3.M33.get -> T -Silk.NET.Maths.Matrix3X3.M33.set -> void -Silk.NET.Maths.Matrix3X3.Matrix3X3() -> void -Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix2X4 value) -> void -Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix3X2 value) -> void -Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix3X3 value) -> void -Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix3X4 value) -> void -Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix4X2 value) -> void -Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix4X3 value) -> void -Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix4X4 value) -> void -Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Vector3D row1, Silk.NET.Maths.Vector3D row2, Silk.NET.Maths.Vector3D row3) -> void -Silk.NET.Maths.Matrix3X3.Matrix3X3(T m11, T m12, T m13, T m21, T m22, T m23, T m31, T m32, T m33) -> void -Silk.NET.Maths.Matrix3X3.Row1 -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X3.Row2 -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X3.Row3 -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X3.this[int x, int i].get -> T -Silk.NET.Maths.Matrix3X3.this[int x].get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X4 -Silk.NET.Maths.Matrix3X4 -Silk.NET.Maths.Matrix3X4.As() -> Silk.NET.Maths.Matrix3X4 -Silk.NET.Maths.Matrix3X4.Column1.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X4.Column2.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X4.Column3.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X4.Column4.get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X4.Equals(Silk.NET.Maths.Matrix3X4 other) -> bool -Silk.NET.Maths.Matrix3X4.IsIdentity.get -> bool -Silk.NET.Maths.Matrix3X4.M11.get -> T -Silk.NET.Maths.Matrix3X4.M11.set -> void -Silk.NET.Maths.Matrix3X4.M12.get -> T -Silk.NET.Maths.Matrix3X4.M12.set -> void -Silk.NET.Maths.Matrix3X4.M13.get -> T -Silk.NET.Maths.Matrix3X4.M13.set -> void -Silk.NET.Maths.Matrix3X4.M14.get -> T -Silk.NET.Maths.Matrix3X4.M14.set -> void -Silk.NET.Maths.Matrix3X4.M21.get -> T -Silk.NET.Maths.Matrix3X4.M21.set -> void -Silk.NET.Maths.Matrix3X4.M22.get -> T -Silk.NET.Maths.Matrix3X4.M22.set -> void -Silk.NET.Maths.Matrix3X4.M23.get -> T -Silk.NET.Maths.Matrix3X4.M23.set -> void -Silk.NET.Maths.Matrix3X4.M24.get -> T -Silk.NET.Maths.Matrix3X4.M24.set -> void -Silk.NET.Maths.Matrix3X4.M31.get -> T -Silk.NET.Maths.Matrix3X4.M31.set -> void -Silk.NET.Maths.Matrix3X4.M32.get -> T -Silk.NET.Maths.Matrix3X4.M32.set -> void -Silk.NET.Maths.Matrix3X4.M33.get -> T -Silk.NET.Maths.Matrix3X4.M33.set -> void -Silk.NET.Maths.Matrix3X4.M34.get -> T -Silk.NET.Maths.Matrix3X4.M34.set -> void -Silk.NET.Maths.Matrix3X4.Matrix3X4() -> void -Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix2X4 value) -> void -Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix3X2 value) -> void -Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix3X3 value) -> void -Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix3X4 value) -> void -Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix4X2 value) -> void -Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix4X3 value) -> void -Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Vector4D row1, Silk.NET.Maths.Vector4D row2, Silk.NET.Maths.Vector4D row3) -> void -Silk.NET.Maths.Matrix3X4.Matrix3X4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24, T m31, T m32, T m33, T m34) -> void -Silk.NET.Maths.Matrix3X4.Row1 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix3X4.Row2 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix3X4.Row3 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix3X4.this[int x, int y].get -> T -Silk.NET.Maths.Matrix3X4.this[int x].get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X2 -Silk.NET.Maths.Matrix4X2 -Silk.NET.Maths.Matrix4X2.As() -> Silk.NET.Maths.Matrix4X2 -Silk.NET.Maths.Matrix4X2.Column1.get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X2.Column2.get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X2.Equals(Silk.NET.Maths.Matrix4X2 other) -> bool -Silk.NET.Maths.Matrix4X2.IsIdentity.get -> bool -Silk.NET.Maths.Matrix4X2.M11.get -> T -Silk.NET.Maths.Matrix4X2.M11.set -> void -Silk.NET.Maths.Matrix4X2.M12.get -> T -Silk.NET.Maths.Matrix4X2.M12.set -> void -Silk.NET.Maths.Matrix4X2.M21.get -> T -Silk.NET.Maths.Matrix4X2.M21.set -> void -Silk.NET.Maths.Matrix4X2.M22.get -> T -Silk.NET.Maths.Matrix4X2.M22.set -> void -Silk.NET.Maths.Matrix4X2.M31.get -> T -Silk.NET.Maths.Matrix4X2.M31.set -> void -Silk.NET.Maths.Matrix4X2.M32.get -> T -Silk.NET.Maths.Matrix4X2.M32.set -> void -Silk.NET.Maths.Matrix4X2.M41.get -> T -Silk.NET.Maths.Matrix4X2.M41.set -> void -Silk.NET.Maths.Matrix4X2.M42.get -> T -Silk.NET.Maths.Matrix4X2.M42.set -> void -Silk.NET.Maths.Matrix4X2.Matrix4X2() -> void -Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Matrix2X4 value) -> void -Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Matrix3X2 value) -> void -Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Matrix3X3 value) -> void -Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Matrix3X4 value) -> void -Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Matrix4X3 value) -> void -Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Vector2D row1, Silk.NET.Maths.Vector2D row2, Silk.NET.Maths.Vector2D row3, Silk.NET.Maths.Vector2D row4) -> void -Silk.NET.Maths.Matrix4X2.Matrix4X2(T m11, T m12, T m21, T m22, T m31, T m32, T m41, T m42) -> void -Silk.NET.Maths.Matrix4X2.Row1 -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix4X2.Row2 -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix4X2.Row3 -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix4X2.Row4 -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix4X2.this[int x, int y].get -> T -Silk.NET.Maths.Matrix4X2.this[int x].get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix4X3 -Silk.NET.Maths.Matrix4X3 -Silk.NET.Maths.Matrix4X3.As() -> Silk.NET.Maths.Matrix4X3 -Silk.NET.Maths.Matrix4X3.Column1.get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X3.Column2.get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X3.Column3.get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X3.Equals(Silk.NET.Maths.Matrix4X3 other) -> bool -Silk.NET.Maths.Matrix4X3.IsIdentity.get -> bool -Silk.NET.Maths.Matrix4X3.M11.get -> T -Silk.NET.Maths.Matrix4X3.M11.set -> void -Silk.NET.Maths.Matrix4X3.M12.get -> T -Silk.NET.Maths.Matrix4X3.M12.set -> void -Silk.NET.Maths.Matrix4X3.M13.get -> T -Silk.NET.Maths.Matrix4X3.M13.set -> void -Silk.NET.Maths.Matrix4X3.M21.get -> T -Silk.NET.Maths.Matrix4X3.M21.set -> void -Silk.NET.Maths.Matrix4X3.M22.get -> T -Silk.NET.Maths.Matrix4X3.M22.set -> void -Silk.NET.Maths.Matrix4X3.M23.get -> T -Silk.NET.Maths.Matrix4X3.M23.set -> void -Silk.NET.Maths.Matrix4X3.M31.get -> T -Silk.NET.Maths.Matrix4X3.M31.set -> void -Silk.NET.Maths.Matrix4X3.M32.get -> T -Silk.NET.Maths.Matrix4X3.M32.set -> void -Silk.NET.Maths.Matrix4X3.M33.get -> T -Silk.NET.Maths.Matrix4X3.M33.set -> void -Silk.NET.Maths.Matrix4X3.M41.get -> T -Silk.NET.Maths.Matrix4X3.M41.set -> void -Silk.NET.Maths.Matrix4X3.M42.get -> T -Silk.NET.Maths.Matrix4X3.M42.set -> void -Silk.NET.Maths.Matrix4X3.M43.get -> T -Silk.NET.Maths.Matrix4X3.M43.set -> void -Silk.NET.Maths.Matrix4X3.Matrix4X3() -> void -Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix2X4 value) -> void -Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix3X2 value) -> void -Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix3X3 value) -> void -Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix3X4 value) -> void -Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix4X2 value) -> void -Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix4X3 value) -> void -Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix4X4 value) -> void -Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Vector3D row1, Silk.NET.Maths.Vector3D row2, Silk.NET.Maths.Vector3D row3, Silk.NET.Maths.Vector3D row4) -> void -Silk.NET.Maths.Matrix4X3.Matrix4X3(T m11, T m12, T m13, T m21, T m22, T m23, T m31, T m32, T m33, T m41, T m42, T m43) -> void -Silk.NET.Maths.Matrix4X3.Row1 -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix4X3.Row2 -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix4X3.Row3 -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix4X3.Row4 -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix4X3.this[int x, int i].get -> T -Silk.NET.Maths.Matrix4X3.this[int x].get -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix4X4 -Silk.NET.Maths.Matrix4X4 -Silk.NET.Maths.Matrix4X4.As() -> Silk.NET.Maths.Matrix4X4 -Silk.NET.Maths.Matrix4X4.Column1.get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X4.Column2.get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X4.Column3.get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X4.Column4.get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X4.Equals(Silk.NET.Maths.Matrix4X4 other) -> bool -Silk.NET.Maths.Matrix4X4.GetDeterminant() -> T -Silk.NET.Maths.Matrix4X4.IsIdentity.get -> bool -Silk.NET.Maths.Matrix4X4.M11.get -> T -Silk.NET.Maths.Matrix4X4.M11.set -> void -Silk.NET.Maths.Matrix4X4.M12.get -> T -Silk.NET.Maths.Matrix4X4.M12.set -> void -Silk.NET.Maths.Matrix4X4.M13.get -> T -Silk.NET.Maths.Matrix4X4.M13.set -> void -Silk.NET.Maths.Matrix4X4.M14.get -> T -Silk.NET.Maths.Matrix4X4.M14.set -> void -Silk.NET.Maths.Matrix4X4.M21.get -> T -Silk.NET.Maths.Matrix4X4.M21.set -> void -Silk.NET.Maths.Matrix4X4.M22.get -> T -Silk.NET.Maths.Matrix4X4.M22.set -> void -Silk.NET.Maths.Matrix4X4.M23.get -> T -Silk.NET.Maths.Matrix4X4.M23.set -> void -Silk.NET.Maths.Matrix4X4.M24.get -> T -Silk.NET.Maths.Matrix4X4.M24.set -> void -Silk.NET.Maths.Matrix4X4.M31.get -> T -Silk.NET.Maths.Matrix4X4.M31.set -> void -Silk.NET.Maths.Matrix4X4.M32.get -> T -Silk.NET.Maths.Matrix4X4.M32.set -> void -Silk.NET.Maths.Matrix4X4.M33.get -> T -Silk.NET.Maths.Matrix4X4.M33.set -> void -Silk.NET.Maths.Matrix4X4.M34.get -> T -Silk.NET.Maths.Matrix4X4.M34.set -> void -Silk.NET.Maths.Matrix4X4.M41.get -> T -Silk.NET.Maths.Matrix4X4.M41.set -> void -Silk.NET.Maths.Matrix4X4.M42.get -> T -Silk.NET.Maths.Matrix4X4.M42.set -> void -Silk.NET.Maths.Matrix4X4.M43.get -> T -Silk.NET.Maths.Matrix4X4.M43.set -> void -Silk.NET.Maths.Matrix4X4.M44.get -> T -Silk.NET.Maths.Matrix4X4.M44.set -> void -Silk.NET.Maths.Matrix4X4.Matrix4X4() -> void -Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix2X4 value) -> void -Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix3X2 value) -> void -Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix3X3 value) -> void -Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix3X4 value) -> void -Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix4X2 value) -> void -Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix4X3 value) -> void -Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Vector4D row1, Silk.NET.Maths.Vector4D row2, Silk.NET.Maths.Vector4D row3, Silk.NET.Maths.Vector4D row4) -> void -Silk.NET.Maths.Matrix4X4.Matrix4X4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24, T m31, T m32, T m33, T m34, T m41, T m42, T m43, T m44) -> void -Silk.NET.Maths.Matrix4X4.Row1 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X4.Row2 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X4.Row3 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X4.Row4 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X4.this[int x, int y].get -> T -Silk.NET.Maths.Matrix4X4.this[int x].get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix5X4 -Silk.NET.Maths.Matrix5X4 -Silk.NET.Maths.Matrix5X4.As() -> Silk.NET.Maths.Matrix5X4 -Silk.NET.Maths.Matrix5X4.Equals(Silk.NET.Maths.Matrix5X4 other) -> bool -Silk.NET.Maths.Matrix5X4.IsIdentity.get -> bool -Silk.NET.Maths.Matrix5X4.M11.get -> T -Silk.NET.Maths.Matrix5X4.M11.set -> void -Silk.NET.Maths.Matrix5X4.M12.get -> T -Silk.NET.Maths.Matrix5X4.M12.set -> void -Silk.NET.Maths.Matrix5X4.M13.get -> T -Silk.NET.Maths.Matrix5X4.M13.set -> void -Silk.NET.Maths.Matrix5X4.M14.get -> T -Silk.NET.Maths.Matrix5X4.M14.set -> void -Silk.NET.Maths.Matrix5X4.M21.get -> T -Silk.NET.Maths.Matrix5X4.M21.set -> void -Silk.NET.Maths.Matrix5X4.M22.get -> T -Silk.NET.Maths.Matrix5X4.M22.set -> void -Silk.NET.Maths.Matrix5X4.M23.get -> T -Silk.NET.Maths.Matrix5X4.M23.set -> void -Silk.NET.Maths.Matrix5X4.M24.get -> T -Silk.NET.Maths.Matrix5X4.M24.set -> void -Silk.NET.Maths.Matrix5X4.M31.get -> T -Silk.NET.Maths.Matrix5X4.M31.set -> void -Silk.NET.Maths.Matrix5X4.M32.get -> T -Silk.NET.Maths.Matrix5X4.M32.set -> void -Silk.NET.Maths.Matrix5X4.M33.get -> T -Silk.NET.Maths.Matrix5X4.M33.set -> void -Silk.NET.Maths.Matrix5X4.M34.get -> T -Silk.NET.Maths.Matrix5X4.M34.set -> void -Silk.NET.Maths.Matrix5X4.M41.get -> T -Silk.NET.Maths.Matrix5X4.M41.set -> void -Silk.NET.Maths.Matrix5X4.M42.get -> T -Silk.NET.Maths.Matrix5X4.M42.set -> void -Silk.NET.Maths.Matrix5X4.M43.get -> T -Silk.NET.Maths.Matrix5X4.M43.set -> void -Silk.NET.Maths.Matrix5X4.M44.get -> T -Silk.NET.Maths.Matrix5X4.M44.set -> void -Silk.NET.Maths.Matrix5X4.M51.get -> T -Silk.NET.Maths.Matrix5X4.M51.set -> void -Silk.NET.Maths.Matrix5X4.M52.get -> T -Silk.NET.Maths.Matrix5X4.M52.set -> void -Silk.NET.Maths.Matrix5X4.M53.get -> T -Silk.NET.Maths.Matrix5X4.M53.set -> void -Silk.NET.Maths.Matrix5X4.M54.get -> T -Silk.NET.Maths.Matrix5X4.M54.set -> void -Silk.NET.Maths.Matrix5X4.Matrix5X4() -> void -Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix2X4 value) -> void -Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix3X2 value) -> void -Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix3X3 value) -> void -Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix3X4 value) -> void -Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix4X2 value) -> void -Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix4X3 value) -> void -Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix4X4 value) -> void -Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Vector4D row1, Silk.NET.Maths.Vector4D row2, Silk.NET.Maths.Vector4D row3, Silk.NET.Maths.Vector4D row4, Silk.NET.Maths.Vector4D row5) -> void -Silk.NET.Maths.Matrix5X4.Matrix5X4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24, T m31, T m32, T m33, T m34, T m41, T m42, T m43, T m44, T m51, T m52, T m53, T m54) -> void -Silk.NET.Maths.Matrix5X4.Row1 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix5X4.Row2 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix5X4.Row3 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix5X4.Row4 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix5X4.Row5 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix5X4.this[int x, int y].get -> T -Silk.NET.Maths.Matrix5X4.this[int x].get -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Plane -Silk.NET.Maths.Plane -Silk.NET.Maths.Plane.As() -> Silk.NET.Maths.Plane -Silk.NET.Maths.Plane.Distance -> T -Silk.NET.Maths.Plane.Equals(Silk.NET.Maths.Plane other) -> bool -Silk.NET.Maths.Plane.Normal -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Plane.Plane() -> void -Silk.NET.Maths.Plane.Plane(Silk.NET.Maths.Vector3D normal, T distance) -> void -Silk.NET.Maths.Plane.Plane(Silk.NET.Maths.Vector4D value) -> void -Silk.NET.Maths.Plane.Plane(T x, T y, T z, T distance) -> void -Silk.NET.Maths.Quaternion -Silk.NET.Maths.Quaternion.As() -> Silk.NET.Maths.Quaternion -Silk.NET.Maths.Quaternion.Equals(Silk.NET.Maths.Quaternion other) -> bool -Silk.NET.Maths.Quaternion.IsIdentity.get -> bool -Silk.NET.Maths.Quaternion.Length() -> T -Silk.NET.Maths.Quaternion.LengthSquared() -> T -Silk.NET.Maths.Quaternion.Quaternion() -> void -Silk.NET.Maths.Quaternion.Quaternion(Silk.NET.Maths.Vector3D vectorPart, T scalarPart) -> void -Silk.NET.Maths.Quaternion.Quaternion(T x, T y, T z, T w) -> void -Silk.NET.Maths.Quaternion.W -> T -Silk.NET.Maths.Quaternion.X -> T -Silk.NET.Maths.Quaternion.Y -> T -Silk.NET.Maths.Quaternion.Z -> T -Silk.NET.Maths.Ray2D -Silk.NET.Maths.Ray2D.As() -> Silk.NET.Maths.Ray2D -Silk.NET.Maths.Ray2D.Direction -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Ray2D.Equals(Silk.NET.Maths.Ray2D other) -> bool -Silk.NET.Maths.Ray2D.GetPoint(T distance) -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Ray2D.Origin -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Ray2D.Ray2D() -> void -Silk.NET.Maths.Ray2D.Ray2D(Silk.NET.Maths.Vector2D origin, Silk.NET.Maths.Vector2D direction) -> void -Silk.NET.Maths.Ray2D.Ray2D(Silk.NET.Maths.Vector2D origin, T directionX, T directionY) -> void -Silk.NET.Maths.Ray2D.Ray2D(T originX, T originY, Silk.NET.Maths.Vector2D direction) -> void -Silk.NET.Maths.Ray2D.Ray2D(T originX, T originY, T directionX, T directionY) -> void -Silk.NET.Maths.Ray3D -Silk.NET.Maths.Ray3D.As() -> Silk.NET.Maths.Ray3D -Silk.NET.Maths.Ray3D.Direction -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Ray3D.Equals(Silk.NET.Maths.Ray3D other) -> bool -Silk.NET.Maths.Ray3D.GetPoint(T distance) -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Ray3D.Origin -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Ray3D.Ray3D() -> void -Silk.NET.Maths.Ray3D.Ray3D(Silk.NET.Maths.Vector3D origin, Silk.NET.Maths.Vector3D direction) -> void -Silk.NET.Maths.Ray3D.Ray3D(Silk.NET.Maths.Vector3D origin, T directionX, T directionY, T directionZ) -> void -Silk.NET.Maths.Ray3D.Ray3D(T originX, T originY, T originZ, Silk.NET.Maths.Vector3D direction) -> void -Silk.NET.Maths.Ray3D.Ray3D(T originX, T originY, T originZ, T directionX, T directionY, T directionZ) -> void -Silk.NET.Maths.Rectangle -Silk.NET.Maths.Rectangle -Silk.NET.Maths.Rectangle.As() -> Silk.NET.Maths.Rectangle -Silk.NET.Maths.Rectangle.Center.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Rectangle.Contains(Silk.NET.Maths.Rectangle other) -> bool -Silk.NET.Maths.Rectangle.Contains(Silk.NET.Maths.Vector2D point) -> bool -Silk.NET.Maths.Rectangle.Equals(Silk.NET.Maths.Rectangle other) -> bool -Silk.NET.Maths.Rectangle.GetDistanceToNearestEdge(Silk.NET.Maths.Vector2D point) -> T -Silk.NET.Maths.Rectangle.GetInflated(Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Rectangle -Silk.NET.Maths.Rectangle.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Rectangle -Silk.NET.Maths.Rectangle.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Rectangle -Silk.NET.Maths.Rectangle.GetTranslated(Silk.NET.Maths.Vector2D distance) -> Silk.NET.Maths.Rectangle -Silk.NET.Maths.Rectangle.HalfSize.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Rectangle.Max.get -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Rectangle.Origin -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Rectangle.Rectangle() -> void -Silk.NET.Maths.Rectangle.Rectangle(Silk.NET.Maths.Vector2D origin, Silk.NET.Maths.Vector2D size) -> void -Silk.NET.Maths.Rectangle.Rectangle(Silk.NET.Maths.Vector2D origin, T sizeX, T sizeY) -> void -Silk.NET.Maths.Rectangle.Rectangle(T originX, T originY, Silk.NET.Maths.Vector2D size) -> void -Silk.NET.Maths.Rectangle.Rectangle(T originX, T originY, T sizeX, T sizeY) -> void -Silk.NET.Maths.Rectangle.Size -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Scalar -Silk.NET.Maths.Scalar -Silk.NET.Maths.Sphere -Silk.NET.Maths.Sphere.As() -> Silk.NET.Maths.Sphere -Silk.NET.Maths.Sphere.Center -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Sphere.Contains(Silk.NET.Maths.Sphere other) -> bool -Silk.NET.Maths.Sphere.Contains(Silk.NET.Maths.Vector3D point) -> bool -Silk.NET.Maths.Sphere.Diameter.get -> T -Silk.NET.Maths.Sphere.Equals(Silk.NET.Maths.Sphere other) -> bool -Silk.NET.Maths.Sphere.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D point) -> T -Silk.NET.Maths.Sphere.GetDistanceToNearestEdgeSquared(Silk.NET.Maths.Vector3D point) -> T -Silk.NET.Maths.Sphere.GetInflated(Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Sphere -Silk.NET.Maths.Sphere.GetTranslated(Silk.NET.Maths.Vector3D distance) -> Silk.NET.Maths.Sphere -Silk.NET.Maths.Sphere.Radius -> T -Silk.NET.Maths.Sphere.Sphere() -> void -Silk.NET.Maths.Sphere.Sphere(Silk.NET.Maths.Vector3D center, T radius) -> void -Silk.NET.Maths.Sphere.Sphere(T centerX, T centerY, T centerZ, T radius) -> void -Silk.NET.Maths.Sphere.SquaredRadius.get -> T -Silk.NET.Maths.SystemNumericsExtensions -Silk.NET.Maths.Vector2D -Silk.NET.Maths.Vector2D -Silk.NET.Maths.Vector2D.As() -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Vector2D.CopyTo(T[]? array) -> void -Silk.NET.Maths.Vector2D.CopyTo(T[]? array, int index) -> void -Silk.NET.Maths.Vector2D.Equals(Silk.NET.Maths.Vector2D other) -> bool -Silk.NET.Maths.Vector2D.Length.get -> T -Silk.NET.Maths.Vector2D.LengthSquared.get -> T -Silk.NET.Maths.Vector2D.this[int i].get -> T -Silk.NET.Maths.Vector2D.ToString(string? format) -> string! -Silk.NET.Maths.Vector2D.ToString(string? format, System.IFormatProvider? formatProvider) -> string! -Silk.NET.Maths.Vector2D.Vector2D() -> void -Silk.NET.Maths.Vector2D.Vector2D(T value) -> void -Silk.NET.Maths.Vector2D.Vector2D(T x, T y) -> void -Silk.NET.Maths.Vector2D.X -> T -Silk.NET.Maths.Vector2D.Y -> T -Silk.NET.Maths.Vector3D -Silk.NET.Maths.Vector3D -Silk.NET.Maths.Vector3D.As() -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Vector3D.CopyTo(T[]? array) -> void -Silk.NET.Maths.Vector3D.CopyTo(T[]? array, int index) -> void -Silk.NET.Maths.Vector3D.Equals(Silk.NET.Maths.Vector3D other) -> bool -Silk.NET.Maths.Vector3D.Length.get -> T -Silk.NET.Maths.Vector3D.LengthSquared.get -> T -Silk.NET.Maths.Vector3D.this[int i].get -> T -Silk.NET.Maths.Vector3D.ToString(string? format) -> string! -Silk.NET.Maths.Vector3D.ToString(string? format, System.IFormatProvider? formatProvider) -> string! -Silk.NET.Maths.Vector3D.Vector3D() -> void -Silk.NET.Maths.Vector3D.Vector3D(Silk.NET.Maths.Vector2D value, T z) -> void -Silk.NET.Maths.Vector3D.Vector3D(T value) -> void -Silk.NET.Maths.Vector3D.Vector3D(T x, T y, T z) -> void -Silk.NET.Maths.Vector3D.X -> T -Silk.NET.Maths.Vector3D.Y -> T -Silk.NET.Maths.Vector3D.Z -> T -Silk.NET.Maths.Vector4D -Silk.NET.Maths.Vector4D -Silk.NET.Maths.Vector4D.As() -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Vector4D.CopyTo(T[]? array) -> void -Silk.NET.Maths.Vector4D.CopyTo(T[]? array, int index) -> void -Silk.NET.Maths.Vector4D.Equals(Silk.NET.Maths.Vector4D other) -> bool -Silk.NET.Maths.Vector4D.Length.get -> T -Silk.NET.Maths.Vector4D.LengthSquared.get -> T -Silk.NET.Maths.Vector4D.this[int i].get -> T -Silk.NET.Maths.Vector4D.ToString(string? format) -> string! -Silk.NET.Maths.Vector4D.ToString(string? format, System.IFormatProvider? formatProvider) -> string! -Silk.NET.Maths.Vector4D.Vector4D() -> void -Silk.NET.Maths.Vector4D.Vector4D(Silk.NET.Maths.Vector2D value, T z, T w) -> void -Silk.NET.Maths.Vector4D.Vector4D(Silk.NET.Maths.Vector3D value, T w) -> void -Silk.NET.Maths.Vector4D.Vector4D(T value) -> void -Silk.NET.Maths.Vector4D.Vector4D(T x, T y, T z, T w) -> void -Silk.NET.Maths.Vector4D.W -> T -Silk.NET.Maths.Vector4D.X -> T -Silk.NET.Maths.Vector4D.Y -> T -Silk.NET.Maths.Vector4D.Z -> T -static readonly Silk.NET.Maths.Scalar.DegreesPerRadian -> T -static readonly Silk.NET.Maths.Scalar.E -> T -static readonly Silk.NET.Maths.Scalar.Epsilon -> T -static readonly Silk.NET.Maths.Scalar.MaxValue -> T -static readonly Silk.NET.Maths.Scalar.MinusOne -> T -static readonly Silk.NET.Maths.Scalar.MinusTwo -> T -static readonly Silk.NET.Maths.Scalar.MinValue -> T -static readonly Silk.NET.Maths.Scalar.NaN -> T -static readonly Silk.NET.Maths.Scalar.NegativeInfinity -> T -static readonly Silk.NET.Maths.Scalar.One -> T -static readonly Silk.NET.Maths.Scalar.Pi -> T -static readonly Silk.NET.Maths.Scalar.PiOver2 -> T -static readonly Silk.NET.Maths.Scalar.PositiveInfinity -> T -static readonly Silk.NET.Maths.Scalar.RadiansPerDegree -> T -static readonly Silk.NET.Maths.Scalar.Tau -> T -static readonly Silk.NET.Maths.Scalar.Two -> T -static readonly Silk.NET.Maths.Scalar.Zero -> T -static Silk.NET.Maths.Box2D.operator !=(Silk.NET.Maths.Box2D value1, Silk.NET.Maths.Box2D value2) -> bool -static Silk.NET.Maths.Box2D.operator ==(Silk.NET.Maths.Box2D value1, Silk.NET.Maths.Box2D value2) -> bool -static Silk.NET.Maths.Box3D.operator !=(Silk.NET.Maths.Box3D value1, Silk.NET.Maths.Box3D value2) -> bool -static Silk.NET.Maths.Box3D.operator ==(Silk.NET.Maths.Box3D value1, Silk.NET.Maths.Box3D value2) -> bool -static Silk.NET.Maths.Circle.operator !=(Silk.NET.Maths.Circle value1, Silk.NET.Maths.Circle value2) -> bool -static Silk.NET.Maths.Circle.operator ==(Silk.NET.Maths.Circle value1, Silk.NET.Maths.Circle value2) -> bool -static Silk.NET.Maths.Cube.operator !=(Silk.NET.Maths.Cube value1, Silk.NET.Maths.Cube value2) -> bool -static Silk.NET.Maths.Cube.operator ==(Silk.NET.Maths.Cube value1, Silk.NET.Maths.Cube value2) -> bool -static Silk.NET.Maths.Matrix2X2.Add(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.Lerp(Silk.NET.Maths.Matrix2X2 matrix1, Silk.NET.Maths.Matrix2X2 matrix2, T amount) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 value1, T value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Matrix2X2.Negate(Silk.NET.Maths.Matrix2X2 value) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.Subtract(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.Identity.get -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.operator !=(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> bool -static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Matrix2X2 value1, T value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Matrix2X2.operator +(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.operator -(Silk.NET.Maths.Matrix2X2 value) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.operator -(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.operator ==(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> bool -static Silk.NET.Maths.Matrix2X3.Add(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.CreateBillboard(Silk.NET.Maths.Vector3D objectPosition, Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D cameraUpVector, Silk.NET.Maths.Vector3D cameraForwardVector) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.CreateFromAxisAngle(Silk.NET.Maths.Vector3D axis, T angle) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.CreateFromQuaternion(Silk.NET.Maths.Quaternion quaternion) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.CreateFromYawPitchRoll(T yaw, T pitch, T roll) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Lerp(Silk.NET.Maths.Matrix2X3 matrix1, Silk.NET.Maths.Matrix2X3 matrix2, T amount) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 value1, T value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Matrix2X3.Negate(Silk.NET.Maths.Matrix2X3 value) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Subtract(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Transform(Silk.NET.Maths.Matrix2X3 value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Identity.get -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator !=(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2) -> bool -static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X3 value1, T value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Matrix2X3.operator +(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator -(Silk.NET.Maths.Matrix2X3 value) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator -(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator ==(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2) -> bool -static Silk.NET.Maths.Matrix2X4.Add(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.Lerp(Silk.NET.Maths.Matrix2X4 matrix1, Silk.NET.Maths.Matrix2X4 matrix2, T amount) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.Identity.get -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator !=(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix2X4 value2) -> bool -static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X4 value1, T value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Matrix2X4.operator +(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator -(Silk.NET.Maths.Matrix2X4 value) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator -(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator ==(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix2X4 value2) -> bool -static Silk.NET.Maths.Matrix3X2.Add(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.CreateRotation(T radians) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.CreateRotation(T radians, Silk.NET.Maths.Vector2D centerPoint) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.CreateScale(Silk.NET.Maths.Vector2D scales) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.CreateScale(Silk.NET.Maths.Vector2D scales, Silk.NET.Maths.Vector2D centerPoint) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.CreateScale(T scale) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.CreateScale(T scale, Silk.NET.Maths.Vector2D centerPoint) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.CreateScale(T xScale, T yScale) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.CreateScale(T xScale, T yScale, Silk.NET.Maths.Vector2D centerPoint) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.CreateSkew(T radiansX, T radiansY) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.CreateSkew(T radiansX, T radiansY, Silk.NET.Maths.Vector2D centerPoint) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.CreateTranslation(Silk.NET.Maths.Vector2D position) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.CreateTranslation(T xPosition, T yPosition) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.Invert(Silk.NET.Maths.Matrix3X2 matrix, out Silk.NET.Maths.Matrix3X2 result) -> bool -static Silk.NET.Maths.Matrix3X2.Lerp(Silk.NET.Maths.Matrix3X2 matrix1, Silk.NET.Maths.Matrix3X2 matrix2, T amount) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 value1, T value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Matrix3X2.Negate(Silk.NET.Maths.Matrix3X2 value) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.Subtract(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.explicit operator System.Numerics.Matrix3x2(Silk.NET.Maths.Matrix3X2 from) -> System.Numerics.Matrix3x2 -static Silk.NET.Maths.Matrix3X2.Identity.get -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator !=(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2) -> bool -static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 value1, T value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Matrix3X2.operator +(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator -(Silk.NET.Maths.Matrix3X2 value) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator -(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator ==(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2) -> bool -static Silk.NET.Maths.Matrix3X3.Add(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.CreateBillboard(Silk.NET.Maths.Vector3D objectPosition, Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D cameraUpVector, Silk.NET.Maths.Vector3D cameraForwardVector) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.CreateFromAxisAngle(Silk.NET.Maths.Vector3D axis, T angle) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.CreateFromQuaternion(Silk.NET.Maths.Quaternion quaternion) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.CreateFromYawPitchRoll(T yaw, T pitch, T roll) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.CreateRotationX(T radians) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.CreateRotationY(T radians) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.CreateRotationZ(T radians) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.CreateScale(Silk.NET.Maths.Vector3D scales) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.CreateScale(T scale) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.CreateScale(T xScale, T yScale, T zScale) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Decompose(Silk.NET.Maths.Matrix3X3 matrix, out Silk.NET.Maths.Vector3D scale, out Silk.NET.Maths.Quaternion rotation) -> bool -static Silk.NET.Maths.Matrix3X3.Lerp(Silk.NET.Maths.Matrix3X3 matrix1, Silk.NET.Maths.Matrix3X3 matrix2, T amount) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 value1, T value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Matrix3X3.Negate(Silk.NET.Maths.Matrix3X3 value) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Subtract(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Transform(Silk.NET.Maths.Matrix3X3 value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Transpose(Silk.NET.Maths.Matrix3X3 matrix) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Identity.get -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.operator !=(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> bool -static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix3X3 value1, T value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Matrix3X3.operator +(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.operator -(Silk.NET.Maths.Matrix3X3 value) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.operator -(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.operator ==(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> bool -static Silk.NET.Maths.Matrix3X4.Add(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Lerp(Silk.NET.Maths.Matrix3X4 matrix1, Silk.NET.Maths.Matrix3X4 matrix2, T amount) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 value1, T value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Matrix3X4.Negate(Silk.NET.Maths.Matrix3X4 value) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Subtract(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Identity.get -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.operator !=(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2) -> bool -static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X4 value1, T value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Matrix3X4.operator +(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.operator -(Silk.NET.Maths.Matrix3X4 value) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.operator -(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.operator ==(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2) -> bool -static Silk.NET.Maths.Matrix4X2.Add(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.Lerp(Silk.NET.Maths.Matrix4X2 matrix1, Silk.NET.Maths.Matrix4X2 matrix2, T amount) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Matrix4X2.Negate(Silk.NET.Maths.Matrix4X2 value) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.Subtract(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.Identity.get -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator !=(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2) -> bool -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 value1, T value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Matrix4X2.operator +(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator -(Silk.NET.Maths.Matrix4X2 value) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator -(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator ==(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2) -> bool -static Silk.NET.Maths.Matrix4X3.Add(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Lerp(Silk.NET.Maths.Matrix4X3 matrix1, Silk.NET.Maths.Matrix4X3 matrix2, T amount) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 value1, T value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Matrix4X3.Negate(Silk.NET.Maths.Matrix4X3 value) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Subtract(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Identity.get -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.operator !=(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2) -> bool -static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 value1, T value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Matrix4X3.operator +(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.operator -(Silk.NET.Maths.Matrix4X3 value) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.operator -(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.operator ==(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2) -> bool -static Silk.NET.Maths.Matrix4X4.Add(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateBillboard(Silk.NET.Maths.Vector3D objectPosition, Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D cameraUpVector, Silk.NET.Maths.Vector3D cameraForwardVector) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateConstrainedBillboard(Silk.NET.Maths.Vector3D objectPosition, Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D rotateAxis, Silk.NET.Maths.Vector3D cameraForwardVector, Silk.NET.Maths.Vector3D objectForwardVector) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateFromAxisAngle(Silk.NET.Maths.Vector3D axis, T angle) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateFromQuaternion(Silk.NET.Maths.Quaternion quaternion) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateFromYawPitchRoll(T yaw, T pitch, T roll) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateLookAt(Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D cameraTarget, Silk.NET.Maths.Vector3D cameraUpVector) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateOrthographic(T width, T height, T zNearPlane, T zFarPlane) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateOrthographicOffCenter(T left, T right, T bottom, T top, T zNearPlane, T zFarPlane) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreatePerspective(T width, T height, T nearPlaneDistance, T farPlaneDistance) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreatePerspectiveFieldOfView(T fieldOfView, T aspectRatio, T nearPlaneDistance, T farPlaneDistance) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreatePerspectiveOffCenter(T left, T right, T bottom, T top, T nearPlaneDistance, T farPlaneDistance) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateReflection(Silk.NET.Maths.Plane value) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateRotationX(T radians) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateRotationX(T radians, Silk.NET.Maths.Vector3D centerPoint) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateRotationY(T radians) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateRotationY(T radians, Silk.NET.Maths.Vector3D centerPoint) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateRotationZ(T radians) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateRotationZ(T radians, Silk.NET.Maths.Vector3D centerPoint) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateScale(Silk.NET.Maths.Vector3D scales) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateScale(Silk.NET.Maths.Vector3D scales, Silk.NET.Maths.Vector3D centerPoint) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateScale(T scale) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateScale(T scale, Silk.NET.Maths.Vector3D centerPoint) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateScale(T xScale, T yScale, T zScale) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateScale(T xScale, T yScale, T zScale, Silk.NET.Maths.Vector3D centerPoint) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateShadow(Silk.NET.Maths.Vector3D lightDirection, Silk.NET.Maths.Plane plane) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateTranslation(Silk.NET.Maths.Vector3D position) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateTranslation(T xPosition, T yPosition, T zPosition) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.CreateWorld(Silk.NET.Maths.Vector3D position, Silk.NET.Maths.Vector3D forward, Silk.NET.Maths.Vector3D up) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Decompose(Silk.NET.Maths.Matrix4X4 matrix, out Silk.NET.Maths.Vector3D scale, out Silk.NET.Maths.Quaternion rotation, out Silk.NET.Maths.Vector3D translation) -> bool -static Silk.NET.Maths.Matrix4X4.Invert(Silk.NET.Maths.Matrix4X4 matrix, out Silk.NET.Maths.Matrix4X4 result) -> bool -static Silk.NET.Maths.Matrix4X4.Lerp(Silk.NET.Maths.Matrix4X4 matrix1, Silk.NET.Maths.Matrix4X4 matrix2, T amount) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 value1, T value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Matrix4X4.Negate(Silk.NET.Maths.Matrix4X4 value) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Subtract(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Transform(Silk.NET.Maths.Matrix4X4 value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Transpose(Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Identity.get -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.operator !=(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> bool -static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 value1, T value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Matrix4X4.operator +(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.operator -(Silk.NET.Maths.Matrix4X4 value) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.operator -(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.operator ==(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> bool -static Silk.NET.Maths.Matrix5X4.Add(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.Lerp(Silk.NET.Maths.Matrix5X4 matrix1, Silk.NET.Maths.Matrix5X4 matrix2, T amount) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.Multiply(Silk.NET.Maths.Matrix5X4 value1, T value2) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Matrix5X4.Negate(Silk.NET.Maths.Matrix5X4 value) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.Subtract(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.Identity.get -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.operator !=(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2) -> bool -static Silk.NET.Maths.Matrix5X4.operator *(Silk.NET.Maths.Matrix5X4 value1, T value2) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.operator *(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Matrix5X4.operator +(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.operator -(Silk.NET.Maths.Matrix5X4 value) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.operator -(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.operator ==(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2) -> bool -static Silk.NET.Maths.Plane.CreateFromVertices(Silk.NET.Maths.Vector3D point1, Silk.NET.Maths.Vector3D point2, Silk.NET.Maths.Vector3D point3) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.Dot(Silk.NET.Maths.Plane plane, Silk.NET.Maths.Vector4D value) -> T -static Silk.NET.Maths.Plane.DotCoordinate(Silk.NET.Maths.Plane plane, Silk.NET.Maths.Vector3D value) -> T -static Silk.NET.Maths.Plane.DotNormal(Silk.NET.Maths.Plane plane, Silk.NET.Maths.Vector3D value) -> T -static Silk.NET.Maths.Plane.Normalize(Silk.NET.Maths.Plane value) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.Transform(Silk.NET.Maths.Plane plane, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.Transform(Silk.NET.Maths.Plane plane, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.Plane.explicit operator System.Numerics.Plane(Silk.NET.Maths.Plane from) -> System.Numerics.Plane -static Silk.NET.Maths.Plane.operator !=(Silk.NET.Maths.Plane value1, Silk.NET.Maths.Plane value2) -> bool -static Silk.NET.Maths.Plane.operator ==(Silk.NET.Maths.Plane value1, Silk.NET.Maths.Plane value2) -> bool -static Silk.NET.Maths.Quaternion.Add(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.Concatenate(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.Conjugate(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.CreateFromAxisAngle(Silk.NET.Maths.Vector3D axis, T angle) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.CreateFromRotationMatrix(Silk.NET.Maths.Matrix3X3 matrix) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.CreateFromRotationMatrix(Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.CreateFromYawPitchRoll(T yaw, T pitch, T roll) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.Divide(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.Dot(Silk.NET.Maths.Quaternion quaternion1, Silk.NET.Maths.Quaternion quaternion2) -> T -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator System.Numerics.Quaternion(Silk.NET.Maths.Quaternion from) -> System.Numerics.Quaternion -static Silk.NET.Maths.Quaternion.Identity.get -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.Inverse(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.Lerp(Silk.NET.Maths.Quaternion quaternion1, Silk.NET.Maths.Quaternion quaternion2, T amount) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.Multiply(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.Multiply(Silk.NET.Maths.Quaternion value1, T value2) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.Negate(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.Normalize(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.operator !=(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> bool -static Silk.NET.Maths.Quaternion.operator *(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.operator *(Silk.NET.Maths.Quaternion value1, T value2) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.operator +(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.operator -(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.operator -(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.operator /(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.operator ==(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> bool -static Silk.NET.Maths.Quaternion.Slerp(Silk.NET.Maths.Quaternion quaternion1, Silk.NET.Maths.Quaternion quaternion2, T amount) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.Subtract(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Ray2D.operator !=(Silk.NET.Maths.Ray2D value1, Silk.NET.Maths.Ray2D value2) -> bool -static Silk.NET.Maths.Ray2D.operator ==(Silk.NET.Maths.Ray2D value1, Silk.NET.Maths.Ray2D value2) -> bool -static Silk.NET.Maths.Ray3D.operator !=(Silk.NET.Maths.Ray3D value1, Silk.NET.Maths.Ray3D value2) -> bool -static Silk.NET.Maths.Ray3D.operator ==(Silk.NET.Maths.Ray3D value1, Silk.NET.Maths.Ray3D value2) -> bool -static Silk.NET.Maths.Rectangle.FromLTRB(T left, T top, T right, T bottom) -> Silk.NET.Maths.Rectangle -static Silk.NET.Maths.Rectangle.operator !=(Silk.NET.Maths.Rectangle value1, Silk.NET.Maths.Rectangle value2) -> bool -static Silk.NET.Maths.Rectangle.operator ==(Silk.NET.Maths.Rectangle value1, Silk.NET.Maths.Rectangle value2) -> bool -static Silk.NET.Maths.Scalar.Abs(T x) -> T -static Silk.NET.Maths.Scalar.Acos(T x) -> T -static Silk.NET.Maths.Scalar.Acosh(T x) -> T -static Silk.NET.Maths.Scalar.Add(T left, T right) -> T -static Silk.NET.Maths.Scalar.And(T left, T right) -> T -static Silk.NET.Maths.Scalar.As(TFrom val) -> TTo -static Silk.NET.Maths.Scalar.Asin(T x) -> T -static Silk.NET.Maths.Scalar.Asinh(T x) -> T -static Silk.NET.Maths.Scalar.Atan2(T y, T x) -> T -static Silk.NET.Maths.Scalar.Atan(T x) -> T -static Silk.NET.Maths.Scalar.Atanh(T x) -> T -static Silk.NET.Maths.Scalar.Cbrt(T x) -> T -static Silk.NET.Maths.Scalar.Ceiling(T x) -> T -static Silk.NET.Maths.Scalar.Cos(T x) -> T -static Silk.NET.Maths.Scalar.Cosh(T x) -> T -static Silk.NET.Maths.Scalar.DegreesToRadians(T degrees) -> T -static Silk.NET.Maths.Scalar.Divide(T left, T right) -> T -static Silk.NET.Maths.Scalar.Equal(T left, T right) -> bool -static Silk.NET.Maths.Scalar.Exp(T x) -> T -static Silk.NET.Maths.Scalar.Floor(T x) -> T -static Silk.NET.Maths.Scalar.GreaterThan(T left, T right) -> bool -static Silk.NET.Maths.Scalar.GreaterThanOrEqual(T left, T right) -> bool -static Silk.NET.Maths.Scalar.IEEERemainder(T x, T y) -> T -static Silk.NET.Maths.Scalar.IsFinite(T f) -> bool -static Silk.NET.Maths.Scalar.IsHardwareAccelerated.get -> bool -static Silk.NET.Maths.Scalar.IsInfinity(T f) -> bool -static Silk.NET.Maths.Scalar.IsNaN(T f) -> bool -static Silk.NET.Maths.Scalar.IsNegative(T f) -> bool -static Silk.NET.Maths.Scalar.IsNegativeInfinity(T f) -> bool -static Silk.NET.Maths.Scalar.IsNormal(T f) -> bool -static Silk.NET.Maths.Scalar.IsPositiveInfinity(T f) -> bool -static Silk.NET.Maths.Scalar.IsSubnormal(T f) -> bool -static Silk.NET.Maths.Scalar.LessThan(T left, T right) -> bool -static Silk.NET.Maths.Scalar.LessThanOrEqual(T left, T right) -> bool -static Silk.NET.Maths.Scalar.Log10(T x) -> T -static Silk.NET.Maths.Scalar.Log(T x) -> T -static Silk.NET.Maths.Scalar.Log(T x, T y) -> T -static Silk.NET.Maths.Scalar.Max(T x, T y) -> T -static Silk.NET.Maths.Scalar.Min(T x, T y) -> T -static Silk.NET.Maths.Scalar.Multiply(T left, T right) -> T -static Silk.NET.Maths.Scalar.Negate(T x) -> T -static Silk.NET.Maths.Scalar.Not(T value) -> T -static Silk.NET.Maths.Scalar.NotEqual(T left, T right) -> bool -static Silk.NET.Maths.Scalar.Or(T left, T right) -> T -static Silk.NET.Maths.Scalar.Pow(T x, T y) -> T -static Silk.NET.Maths.Scalar.RadiansToDegrees(T radians) -> T -static Silk.NET.Maths.Scalar.Reciprocal(T x) -> T -static Silk.NET.Maths.Scalar.RotateLeft(T value, int offset) -> T -static Silk.NET.Maths.Scalar.RotateRight(T value, int offset) -> T -static Silk.NET.Maths.Scalar.Round(T x) -> T -static Silk.NET.Maths.Scalar.Round(T x, int digits) -> T -static Silk.NET.Maths.Scalar.Round(T x, int digits, System.MidpointRounding mode) -> T -static Silk.NET.Maths.Scalar.Round(T x, System.MidpointRounding mode) -> T -static Silk.NET.Maths.Scalar.ShiftLeft(T value, int offset) -> T -static Silk.NET.Maths.Scalar.ShiftRight(T value, int offset) -> T -static Silk.NET.Maths.Scalar.Sign(T x) -> int -static Silk.NET.Maths.Scalar.Sin(T x) -> T -static Silk.NET.Maths.Scalar.Sinh(T x) -> T -static Silk.NET.Maths.Scalar.Sqrt(T x) -> T -static Silk.NET.Maths.Scalar.Subtract(T left, T right) -> T -static Silk.NET.Maths.Scalar.Tan(T x) -> T -static Silk.NET.Maths.Scalar.Tanh(T x) -> T -static Silk.NET.Maths.Scalar.Truncate(T x) -> T -static Silk.NET.Maths.Scalar.Xor(T left, T right) -> T -static Silk.NET.Maths.Sphere.operator !=(Silk.NET.Maths.Sphere value1, Silk.NET.Maths.Sphere value2) -> bool -static Silk.NET.Maths.Sphere.operator ==(Silk.NET.Maths.Sphere value1, Silk.NET.Maths.Sphere value2) -> bool -static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Matrix3x2 value) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Matrix4x4 value) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Plane value) -> Silk.NET.Maths.Plane -static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Quaternion value) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Vector2 value) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Vector3 value) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Vector4 value) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Matrix3X2 value) -> System.Numerics.Matrix3x2 -static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Matrix4X4 value) -> System.Numerics.Matrix4x4 -static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Plane value) -> System.Numerics.Plane -static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Quaternion value) -> System.Numerics.Quaternion -static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Vector2D value) -> System.Numerics.Vector2 -static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Vector3D value) -> System.Numerics.Vector3 -static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Vector4D value) -> System.Numerics.Vector4 -static Silk.NET.Maths.Vector2D.Abs(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Add(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Clamp(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D min, Silk.NET.Maths.Vector2D max) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Distance(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2) -> T -static Silk.NET.Maths.Vector2D.DistanceSquared(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2) -> T -static Silk.NET.Maths.Vector2D.Divide(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Divide(Silk.NET.Maths.Vector2D left, T divisor) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Dot(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2) -> T -static Silk.NET.Maths.Vector2D.Lerp(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2, T amount) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Max(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Min(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Multiply(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Multiply(Silk.NET.Maths.Vector2D left, T right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Multiply(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Multiply(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector2D.Multiply(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector2D.Multiply(T left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Negate(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Normalize(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Reflect(Silk.NET.Maths.Vector2D vector, Silk.NET.Maths.Vector2D normal) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.SquareRoot(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Subtract(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Transform(Silk.NET.Maths.Vector2D position, Silk.NET.Maths.Matrix3X2 matrix) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Transform(Silk.NET.Maths.Vector2D position, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Transform(Silk.NET.Maths.Vector2D value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.TransformNormal(Silk.NET.Maths.Vector2D normal, Silk.NET.Maths.Matrix3X2 matrix) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.TransformNormal(Silk.NET.Maths.Vector2D normal, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator System.Numerics.Vector2(Silk.NET.Maths.Vector2D from) -> System.Numerics.Vector2 -static Silk.NET.Maths.Vector2D.One.get -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator !=(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> bool -static Silk.NET.Maths.Vector2D.operator *(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator *(Silk.NET.Maths.Vector2D left, T right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator *(T left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator +(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator -(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator -(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator /(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator /(Silk.NET.Maths.Vector2D value1, T value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator ==(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> bool -static Silk.NET.Maths.Vector2D.UnitX.get -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.UnitY.get -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Zero.get -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector3D.Abs(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Add(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Clamp(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D min, Silk.NET.Maths.Vector3D max) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Cross(Silk.NET.Maths.Vector3D vector1, Silk.NET.Maths.Vector3D vector2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Distance(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2) -> T -static Silk.NET.Maths.Vector3D.DistanceSquared(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2) -> T -static Silk.NET.Maths.Vector3D.Divide(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Divide(Silk.NET.Maths.Vector3D left, T divisor) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Dot(Silk.NET.Maths.Vector3D vector1, Silk.NET.Maths.Vector3D vector2) -> T -static Silk.NET.Maths.Vector3D.Lerp(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2, T amount) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Max(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Min(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Multiply(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Multiply(Silk.NET.Maths.Vector3D left, T right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Multiply(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector3D.Multiply(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Multiply(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector3D.Multiply(T left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Negate(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Normalize(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Reflect(Silk.NET.Maths.Vector3D vector, Silk.NET.Maths.Vector3D normal) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.SquareRoot(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Subtract(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Transform(Silk.NET.Maths.Vector3D position, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Transform(Silk.NET.Maths.Vector3D value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.TransformNormal(Silk.NET.Maths.Vector3D normal, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator System.Numerics.Vector3(Silk.NET.Maths.Vector3D from) -> System.Numerics.Vector3 -static Silk.NET.Maths.Vector3D.One.get -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator !=(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> bool -static Silk.NET.Maths.Vector3D.operator *(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator *(Silk.NET.Maths.Vector3D left, T right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator *(T left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator +(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator -(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator -(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator /(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator /(Silk.NET.Maths.Vector3D value1, T value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator ==(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> bool -static Silk.NET.Maths.Vector3D.UnitX.get -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.UnitY.get -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.UnitZ.get -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Zero.get -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector4D.Abs(Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Add(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Clamp(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D min, Silk.NET.Maths.Vector4D max) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Distance(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2) -> T -static Silk.NET.Maths.Vector4D.DistanceSquared(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2) -> T -static Silk.NET.Maths.Vector4D.Divide(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Divide(Silk.NET.Maths.Vector4D left, T divisor) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Dot(Silk.NET.Maths.Vector4D vector1, Silk.NET.Maths.Vector4D vector2) -> T -static Silk.NET.Maths.Vector4D.Lerp(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2, T amount) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Max(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Min(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Multiply(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Multiply(Silk.NET.Maths.Vector4D left, T right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector4D.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector4D.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Multiply(T left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Negate(Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Normalize(Silk.NET.Maths.Vector4D vector) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.SquareRoot(Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Subtract(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Transform(Silk.NET.Maths.Vector2D position, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Transform(Silk.NET.Maths.Vector2D value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Transform(Silk.NET.Maths.Vector3D position, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Transform(Silk.NET.Maths.Vector3D value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Transform(Silk.NET.Maths.Vector4D value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Transform(Silk.NET.Maths.Vector4D vector, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator System.Numerics.Vector4(Silk.NET.Maths.Vector4D from) -> System.Numerics.Vector4 -static Silk.NET.Maths.Vector4D.One.get -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator !=(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> bool -static Silk.NET.Maths.Vector4D.operator *(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator *(Silk.NET.Maths.Vector4D left, T right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator *(T left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator +(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator -(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator -(Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator /(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator /(Silk.NET.Maths.Vector4D value1, T value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator ==(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> bool -static Silk.NET.Maths.Vector4D.UnitW.get -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.UnitX.get -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.UnitY.get -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.UnitZ.get -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Zero.get -> Silk.NET.Maths.Vector4D diff --git a/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt index 7dc5c58110..47ef53fa1c 100644 --- a/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -1 +1,1873 @@ #nullable enable +override Silk.NET.Maths.Box2D.Equals(object? obj) -> bool +override Silk.NET.Maths.Box2D.GetHashCode() -> int +override Silk.NET.Maths.Box3D.Equals(object? obj) -> bool +override Silk.NET.Maths.Box3D.GetHashCode() -> int +override Silk.NET.Maths.Circle.Equals(object? obj) -> bool +override Silk.NET.Maths.Circle.GetHashCode() -> int +override Silk.NET.Maths.Cube.Equals(object? obj) -> bool +override Silk.NET.Maths.Cube.GetHashCode() -> int +override Silk.NET.Maths.Matrix2X2.Equals(object? obj) -> bool +override Silk.NET.Maths.Matrix2X2.GetHashCode() -> int +override Silk.NET.Maths.Matrix2X2.ToString() -> string! +override Silk.NET.Maths.Matrix2X3.Equals(object? obj) -> bool +override Silk.NET.Maths.Matrix2X3.GetHashCode() -> int +override Silk.NET.Maths.Matrix2X3.ToString() -> string! +override Silk.NET.Maths.Matrix2X4.Equals(object? obj) -> bool +override Silk.NET.Maths.Matrix2X4.GetHashCode() -> int +override Silk.NET.Maths.Matrix2X4.ToString() -> string! +override Silk.NET.Maths.Matrix3X2.Equals(object? obj) -> bool +override Silk.NET.Maths.Matrix3X2.GetHashCode() -> int +override Silk.NET.Maths.Matrix3X2.ToString() -> string! +override Silk.NET.Maths.Matrix3X3.Equals(object? obj) -> bool +override Silk.NET.Maths.Matrix3X3.GetHashCode() -> int +override Silk.NET.Maths.Matrix3X3.ToString() -> string! +override Silk.NET.Maths.Matrix3X4.Equals(object? obj) -> bool +override Silk.NET.Maths.Matrix3X4.GetHashCode() -> int +override Silk.NET.Maths.Matrix3X4.ToString() -> string! +override Silk.NET.Maths.Matrix4X2.Equals(object? obj) -> bool +override Silk.NET.Maths.Matrix4X2.GetHashCode() -> int +override Silk.NET.Maths.Matrix4X2.ToString() -> string! +override Silk.NET.Maths.Matrix4X3.Equals(object? obj) -> bool +override Silk.NET.Maths.Matrix4X3.GetHashCode() -> int +override Silk.NET.Maths.Matrix4X3.ToString() -> string! +override Silk.NET.Maths.Matrix4X4.Equals(object? obj) -> bool +override Silk.NET.Maths.Matrix4X4.GetHashCode() -> int +override Silk.NET.Maths.Matrix4X4.ToString() -> string! +override Silk.NET.Maths.Matrix5X4.Equals(object? obj) -> bool +override Silk.NET.Maths.Matrix5X4.GetHashCode() -> int +override Silk.NET.Maths.Matrix5X4.ToString() -> string! +override Silk.NET.Maths.Plane.Equals(object? obj) -> bool +override Silk.NET.Maths.Plane.GetHashCode() -> int +override Silk.NET.Maths.Plane.ToString() -> string! +override Silk.NET.Maths.Quaternion.Equals(object? obj) -> bool +override Silk.NET.Maths.Quaternion.GetHashCode() -> int +override Silk.NET.Maths.Quaternion.ToString() -> string! +override Silk.NET.Maths.Ray2D.Equals(object? obj) -> bool +override Silk.NET.Maths.Ray2D.GetHashCode() -> int +override Silk.NET.Maths.Ray3D.Equals(object? obj) -> bool +override Silk.NET.Maths.Ray3D.GetHashCode() -> int +override Silk.NET.Maths.Rectangle.Equals(object? obj) -> bool +override Silk.NET.Maths.Rectangle.GetHashCode() -> int +override Silk.NET.Maths.Sphere.Equals(object? obj) -> bool +override Silk.NET.Maths.Sphere.GetHashCode() -> int +override Silk.NET.Maths.Vector2D.Equals(object? obj) -> bool +override Silk.NET.Maths.Vector2D.GetHashCode() -> int +override Silk.NET.Maths.Vector2D.ToString() -> string! +override Silk.NET.Maths.Vector3D.Equals(object? obj) -> bool +override Silk.NET.Maths.Vector3D.GetHashCode() -> int +override Silk.NET.Maths.Vector3D.ToString() -> string! +override Silk.NET.Maths.Vector4D.Equals(object? obj) -> bool +override Silk.NET.Maths.Vector4D.GetHashCode() -> int +override Silk.NET.Maths.Vector4D.ToString() -> string! +Silk.NET.Maths.Box2D +Silk.NET.Maths.Box2D.As() -> Silk.NET.Maths.Box2D +Silk.NET.Maths.Box2D.AsChecked() -> Silk.NET.Maths.Box2D +Silk.NET.Maths.Box2D.AsSaturating() -> Silk.NET.Maths.Box2D +Silk.NET.Maths.Box2D.AsTruncating() -> Silk.NET.Maths.Box2D +Silk.NET.Maths.Box2D.Box2D() -> void +Silk.NET.Maths.Box2D.Box2D(Silk.NET.Maths.Vector2D min, Silk.NET.Maths.Vector2D max) -> void +Silk.NET.Maths.Box2D.Box2D(Silk.NET.Maths.Vector2D min, T maxX, T maxY) -> void +Silk.NET.Maths.Box2D.Box2D(T minX, T minY, Silk.NET.Maths.Vector2D max) -> void +Silk.NET.Maths.Box2D.Box2D(T minX, T minY, T maxX, T maxY) -> void +Silk.NET.Maths.Box2D.Center.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Box2D.Contains(Silk.NET.Maths.Box2D other) -> bool +Silk.NET.Maths.Box2D.Contains(Silk.NET.Maths.Vector2D point) -> bool +Silk.NET.Maths.Box2D.Equals(Silk.NET.Maths.Box2D other) -> bool +Silk.NET.Maths.Box2D.GetDistanceToNearestEdge(Silk.NET.Maths.Vector2D point) -> T +Silk.NET.Maths.Box2D.GetInflated(Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Box2D +Silk.NET.Maths.Box2D.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Box2D +Silk.NET.Maths.Box2D.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Box2D +Silk.NET.Maths.Box2D.GetTranslated(Silk.NET.Maths.Vector2D distance) -> Silk.NET.Maths.Box2D +Silk.NET.Maths.Box2D.Max -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Box2D.Min -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Box2D.Size.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Box3D +Silk.NET.Maths.Box3D.As() -> Silk.NET.Maths.Box3D +Silk.NET.Maths.Box3D.Box3D() -> void +Silk.NET.Maths.Box3D.Box3D(Silk.NET.Maths.Vector3D min, Silk.NET.Maths.Vector3D max) -> void +Silk.NET.Maths.Box3D.Box3D(Silk.NET.Maths.Vector3D min, T maxX, T maxY, T maxZ) -> void +Silk.NET.Maths.Box3D.Box3D(T minX, T minY, T minZ, Silk.NET.Maths.Vector3D max) -> void +Silk.NET.Maths.Box3D.Box3D(T minX, T minY, T minZ, T maxX, T maxY, T maxZ) -> void +Silk.NET.Maths.Box3D.Center.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Box3D.Contains(Silk.NET.Maths.Box3D other) -> bool +Silk.NET.Maths.Box3D.Contains(Silk.NET.Maths.Vector3D point) -> bool +Silk.NET.Maths.Box3D.Equals(Silk.NET.Maths.Box3D other) -> bool +Silk.NET.Maths.Box3D.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D point) -> T +Silk.NET.Maths.Box3D.GetInflated(Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Box3D +Silk.NET.Maths.Box3D.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Box3D +Silk.NET.Maths.Box3D.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Box3D +Silk.NET.Maths.Box3D.GetTranslated(Silk.NET.Maths.Vector3D distance) -> Silk.NET.Maths.Box3D +Silk.NET.Maths.Box3D.Max -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Box3D.Min -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Box3D.Size.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Circle +Silk.NET.Maths.Circle.As() -> Silk.NET.Maths.Circle +Silk.NET.Maths.Circle.Center -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Circle.Circle() -> void +Silk.NET.Maths.Circle.Circle(Silk.NET.Maths.Vector2D center, T radius) -> void +Silk.NET.Maths.Circle.Circle(T centerX, T centerY, T radius) -> void +Silk.NET.Maths.Circle.Circumference.get -> T +Silk.NET.Maths.Circle.Contains(Silk.NET.Maths.Circle other) -> bool +Silk.NET.Maths.Circle.Contains(Silk.NET.Maths.Vector2D point) -> bool +Silk.NET.Maths.Circle.Diameter.get -> T +Silk.NET.Maths.Circle.Equals(Silk.NET.Maths.Circle other) -> bool +Silk.NET.Maths.Circle.GetDistanceToNearestEdge(Silk.NET.Maths.Vector2D point) -> T +Silk.NET.Maths.Circle.GetDistanceToNearestEdgeSquared(Silk.NET.Maths.Vector2D point) -> T +Silk.NET.Maths.Circle.GetInflated(Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Circle +Silk.NET.Maths.Circle.GetTranslated(Silk.NET.Maths.Vector2D distance) -> Silk.NET.Maths.Circle +Silk.NET.Maths.Circle.Radius -> T +Silk.NET.Maths.Circle.SquaredRadius.get -> T +Silk.NET.Maths.Cube +Silk.NET.Maths.Cube.As() -> Silk.NET.Maths.Cube +Silk.NET.Maths.Cube.Center.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Cube.Contains(Silk.NET.Maths.Cube other) -> bool +Silk.NET.Maths.Cube.Contains(Silk.NET.Maths.Vector3D point) -> bool +Silk.NET.Maths.Cube.Cube() -> void +Silk.NET.Maths.Cube.Cube(Silk.NET.Maths.Vector3D origin, Silk.NET.Maths.Vector3D size) -> void +Silk.NET.Maths.Cube.Cube(Silk.NET.Maths.Vector3D origin, T sizeX, T sizeY, T sizeZ) -> void +Silk.NET.Maths.Cube.Cube(T originX, T originY, T originZ, Silk.NET.Maths.Vector3D size) -> void +Silk.NET.Maths.Cube.Cube(T originX, T originY, T originZ, T sizeX, T sizeY, T sizeZ) -> void +Silk.NET.Maths.Cube.Equals(Silk.NET.Maths.Cube other) -> bool +Silk.NET.Maths.Cube.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D point) -> T +Silk.NET.Maths.Cube.GetInflated(Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Cube +Silk.NET.Maths.Cube.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Cube +Silk.NET.Maths.Cube.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Cube +Silk.NET.Maths.Cube.GetTranslated(Silk.NET.Maths.Vector3D distance) -> Silk.NET.Maths.Cube +Silk.NET.Maths.Cube.HalfSize.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Cube.Max.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Cube.Origin -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Cube.Size -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix2X2 +Silk.NET.Maths.Matrix2X2 +Silk.NET.Maths.Matrix2X2.As() -> Silk.NET.Maths.Matrix2X2 +Silk.NET.Maths.Matrix2X2.AsChecked() -> Silk.NET.Maths.Matrix2X2 +Silk.NET.Maths.Matrix2X2.AsSaturating() -> Silk.NET.Maths.Matrix2X2 +Silk.NET.Maths.Matrix2X2.AsTruncating() -> Silk.NET.Maths.Matrix2X2 +Silk.NET.Maths.Matrix2X2.Column1.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X2.Column2.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X2.Equals(Silk.NET.Maths.Matrix2X2 other) -> bool +Silk.NET.Maths.Matrix2X2.GetDeterminant() -> T +Silk.NET.Maths.Matrix2X2.IsIdentity.get -> bool +Silk.NET.Maths.Matrix2X2.M11.get -> T +Silk.NET.Maths.Matrix2X2.M12.get -> T +Silk.NET.Maths.Matrix2X2.M21.get -> T +Silk.NET.Maths.Matrix2X2.M22.get -> T +Silk.NET.Maths.Matrix2X2.Matrix2X2() -> void +Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Matrix2X4 value) -> void +Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Matrix3X2 value) -> void +Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Matrix3X4 value) -> void +Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Matrix4X2 value) -> void +Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Matrix4X3 value) -> void +Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Vector2D row1, Silk.NET.Maths.Vector2D row2) -> void +Silk.NET.Maths.Matrix2X2.Matrix2X2(T m11, T m12, T m21, T m22) -> void +Silk.NET.Maths.Matrix2X2.Row1 -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X2.Row2 -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X2.this[int row, int column].get -> T +Silk.NET.Maths.Matrix2X2.this[int row].get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X2.Transpose() -> Silk.NET.Maths.Matrix2X2 +Silk.NET.Maths.Matrix2X3 +Silk.NET.Maths.Matrix2X3 +Silk.NET.Maths.Matrix2X3.As() -> Silk.NET.Maths.Matrix2X3 +Silk.NET.Maths.Matrix2X3.AsChecked() -> Silk.NET.Maths.Matrix2X3 +Silk.NET.Maths.Matrix2X3.AsSaturating() -> Silk.NET.Maths.Matrix2X3 +Silk.NET.Maths.Matrix2X3.AsTruncating() -> Silk.NET.Maths.Matrix2X3 +Silk.NET.Maths.Matrix2X3.Column1.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X3.Column2.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X3.Column3.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X3.Equals(Silk.NET.Maths.Matrix2X3 other) -> bool +Silk.NET.Maths.Matrix2X3.IsIdentity.get -> bool +Silk.NET.Maths.Matrix2X3.M11.get -> T +Silk.NET.Maths.Matrix2X3.M12.get -> T +Silk.NET.Maths.Matrix2X3.M13.get -> T +Silk.NET.Maths.Matrix2X3.M21.get -> T +Silk.NET.Maths.Matrix2X3.M22.get -> T +Silk.NET.Maths.Matrix2X3.M23.get -> T +Silk.NET.Maths.Matrix2X3.Matrix2X3() -> void +Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Matrix2X4 value) -> void +Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Matrix3X2 value) -> void +Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Matrix3X4 value) -> void +Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Matrix4X2 value) -> void +Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Matrix4X3 value) -> void +Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Vector3D row1, Silk.NET.Maths.Vector3D row2) -> void +Silk.NET.Maths.Matrix2X3.Matrix2X3(T m11, T m12, T m13, T m21, T m22, T m23) -> void +Silk.NET.Maths.Matrix2X3.Row1 -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix2X3.Row2 -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix2X3.this[int row, int column].get -> T +Silk.NET.Maths.Matrix2X3.this[int row].get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix2X3.Transpose() -> Silk.NET.Maths.Matrix3X2 +Silk.NET.Maths.Matrix2X4 +Silk.NET.Maths.Matrix2X4 +Silk.NET.Maths.Matrix2X4.As() -> Silk.NET.Maths.Matrix2X4 +Silk.NET.Maths.Matrix2X4.AsChecked() -> Silk.NET.Maths.Matrix2X4 +Silk.NET.Maths.Matrix2X4.AsSaturating() -> Silk.NET.Maths.Matrix2X4 +Silk.NET.Maths.Matrix2X4.AsTruncating() -> Silk.NET.Maths.Matrix2X4 +Silk.NET.Maths.Matrix2X4.Column1.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X4.Column2.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X4.Column3.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X4.Column4.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X4.Equals(Silk.NET.Maths.Matrix2X4 other) -> bool +Silk.NET.Maths.Matrix2X4.IsIdentity.get -> bool +Silk.NET.Maths.Matrix2X4.M11.get -> T +Silk.NET.Maths.Matrix2X4.M12.get -> T +Silk.NET.Maths.Matrix2X4.M13.get -> T +Silk.NET.Maths.Matrix2X4.M14.get -> T +Silk.NET.Maths.Matrix2X4.M21.get -> T +Silk.NET.Maths.Matrix2X4.M22.get -> T +Silk.NET.Maths.Matrix2X4.M23.get -> T +Silk.NET.Maths.Matrix2X4.M24.get -> T +Silk.NET.Maths.Matrix2X4.Matrix2X4() -> void +Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Matrix3X2 value) -> void +Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Matrix3X3 value) -> void +Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Matrix3X4 value) -> void +Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Matrix4X2 value) -> void +Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Matrix4X3 value) -> void +Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Vector4D row1, Silk.NET.Maths.Vector4D row2) -> void +Silk.NET.Maths.Matrix2X4.Matrix2X4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24) -> void +Silk.NET.Maths.Matrix2X4.Row1 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix2X4.Row2 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix2X4.this[int row, int column].get -> T +Silk.NET.Maths.Matrix2X4.this[int row].get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix2X4.Transpose() -> Silk.NET.Maths.Matrix4X2 +Silk.NET.Maths.Matrix3X2 +Silk.NET.Maths.Matrix3X2 +Silk.NET.Maths.Matrix3X2.As() -> Silk.NET.Maths.Matrix3X2 +Silk.NET.Maths.Matrix3X2.AsChecked() -> Silk.NET.Maths.Matrix3X2 +Silk.NET.Maths.Matrix3X2.AsSaturating() -> Silk.NET.Maths.Matrix3X2 +Silk.NET.Maths.Matrix3X2.AsTruncating() -> Silk.NET.Maths.Matrix3X2 +Silk.NET.Maths.Matrix3X2.Column1.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X2.Column2.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X2.Equals(Silk.NET.Maths.Matrix3X2 other) -> bool +Silk.NET.Maths.Matrix3X2.GetDeterminant() -> T +Silk.NET.Maths.Matrix3X2.IsIdentity.get -> bool +Silk.NET.Maths.Matrix3X2.M11.get -> T +Silk.NET.Maths.Matrix3X2.M12.get -> T +Silk.NET.Maths.Matrix3X2.M21.get -> T +Silk.NET.Maths.Matrix3X2.M22.get -> T +Silk.NET.Maths.Matrix3X2.M31.get -> T +Silk.NET.Maths.Matrix3X2.M32.get -> T +Silk.NET.Maths.Matrix3X2.Matrix3X2() -> void +Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Matrix2X4 value) -> void +Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Matrix3X3 value) -> void +Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Matrix3X4 value) -> void +Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Matrix4X2 value) -> void +Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Matrix4X3 value) -> void +Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Vector2D row1, Silk.NET.Maths.Vector2D row2, Silk.NET.Maths.Vector2D row3) -> void +Silk.NET.Maths.Matrix3X2.Matrix3X2(T m11, T m12, T m21, T m22, T m31, T m32) -> void +Silk.NET.Maths.Matrix3X2.Row1 -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix3X2.Row2 -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix3X2.Row3 -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix3X2.this[int row, int column].get -> T +Silk.NET.Maths.Matrix3X2.this[int row].get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix3X2.Transpose() -> Silk.NET.Maths.Matrix2X3 +Silk.NET.Maths.Matrix3X3 +Silk.NET.Maths.Matrix3X3 +Silk.NET.Maths.Matrix3X3.As() -> Silk.NET.Maths.Matrix3X3 +Silk.NET.Maths.Matrix3X3.AsChecked() -> Silk.NET.Maths.Matrix3X3 +Silk.NET.Maths.Matrix3X3.AsSaturating() -> Silk.NET.Maths.Matrix3X3 +Silk.NET.Maths.Matrix3X3.AsTruncating() -> Silk.NET.Maths.Matrix3X3 +Silk.NET.Maths.Matrix3X3.Column1.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X3.Column2.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X3.Column3.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X3.Equals(Silk.NET.Maths.Matrix3X3 other) -> bool +Silk.NET.Maths.Matrix3X3.GetDeterminant() -> T +Silk.NET.Maths.Matrix3X3.IsIdentity.get -> bool +Silk.NET.Maths.Matrix3X3.M11.get -> T +Silk.NET.Maths.Matrix3X3.M12.get -> T +Silk.NET.Maths.Matrix3X3.M13.get -> T +Silk.NET.Maths.Matrix3X3.M21.get -> T +Silk.NET.Maths.Matrix3X3.M22.get -> T +Silk.NET.Maths.Matrix3X3.M23.get -> T +Silk.NET.Maths.Matrix3X3.M31.get -> T +Silk.NET.Maths.Matrix3X3.M32.get -> T +Silk.NET.Maths.Matrix3X3.M33.get -> T +Silk.NET.Maths.Matrix3X3.Matrix3X3() -> void +Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix2X4 value) -> void +Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix3X2 value) -> void +Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix3X3 value) -> void +Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix3X4 value) -> void +Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix4X2 value) -> void +Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix4X3 value) -> void +Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix4X4 value) -> void +Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Vector3D row1, Silk.NET.Maths.Vector3D row2, Silk.NET.Maths.Vector3D row3) -> void +Silk.NET.Maths.Matrix3X3.Matrix3X3(T m11, T m12, T m13, T m21, T m22, T m23, T m31, T m32, T m33) -> void +Silk.NET.Maths.Matrix3X3.Row1 -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X3.Row2 -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X3.Row3 -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X3.this[int row, int column].get -> T +Silk.NET.Maths.Matrix3X3.this[int row].get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X3.Transpose() -> Silk.NET.Maths.Matrix3X3 +Silk.NET.Maths.Matrix3X4 +Silk.NET.Maths.Matrix3X4 +Silk.NET.Maths.Matrix3X4.As() -> Silk.NET.Maths.Matrix3X4 +Silk.NET.Maths.Matrix3X4.AsChecked() -> Silk.NET.Maths.Matrix3X4 +Silk.NET.Maths.Matrix3X4.AsSaturating() -> Silk.NET.Maths.Matrix3X4 +Silk.NET.Maths.Matrix3X4.AsTruncating() -> Silk.NET.Maths.Matrix3X4 +Silk.NET.Maths.Matrix3X4.Column1.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X4.Column2.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X4.Column3.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X4.Column4.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X4.Equals(Silk.NET.Maths.Matrix3X4 other) -> bool +Silk.NET.Maths.Matrix3X4.IsIdentity.get -> bool +Silk.NET.Maths.Matrix3X4.M11.get -> T +Silk.NET.Maths.Matrix3X4.M12.get -> T +Silk.NET.Maths.Matrix3X4.M13.get -> T +Silk.NET.Maths.Matrix3X4.M14.get -> T +Silk.NET.Maths.Matrix3X4.M21.get -> T +Silk.NET.Maths.Matrix3X4.M22.get -> T +Silk.NET.Maths.Matrix3X4.M23.get -> T +Silk.NET.Maths.Matrix3X4.M24.get -> T +Silk.NET.Maths.Matrix3X4.M31.get -> T +Silk.NET.Maths.Matrix3X4.M32.get -> T +Silk.NET.Maths.Matrix3X4.M33.get -> T +Silk.NET.Maths.Matrix3X4.M34.get -> T +Silk.NET.Maths.Matrix3X4.Matrix3X4() -> void +Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix2X4 value) -> void +Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix3X2 value) -> void +Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix3X3 value) -> void +Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix3X4 value) -> void +Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix4X2 value) -> void +Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix4X3 value) -> void +Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Vector4D row1, Silk.NET.Maths.Vector4D row2, Silk.NET.Maths.Vector4D row3) -> void +Silk.NET.Maths.Matrix3X4.Matrix3X4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24, T m31, T m32, T m33, T m34) -> void +Silk.NET.Maths.Matrix3X4.Row1 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix3X4.Row2 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix3X4.Row3 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix3X4.this[int row, int column].get -> T +Silk.NET.Maths.Matrix3X4.this[int row].get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix3X4.Transpose() -> Silk.NET.Maths.Matrix4X3 +Silk.NET.Maths.Matrix4X2 +Silk.NET.Maths.Matrix4X2 +Silk.NET.Maths.Matrix4X2.As() -> Silk.NET.Maths.Matrix4X2 +Silk.NET.Maths.Matrix4X2.AsChecked() -> Silk.NET.Maths.Matrix4X2 +Silk.NET.Maths.Matrix4X2.AsSaturating() -> Silk.NET.Maths.Matrix4X2 +Silk.NET.Maths.Matrix4X2.AsTruncating() -> Silk.NET.Maths.Matrix4X2 +Silk.NET.Maths.Matrix4X2.Column1.get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X2.Column2.get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X2.Equals(Silk.NET.Maths.Matrix4X2 other) -> bool +Silk.NET.Maths.Matrix4X2.IsIdentity.get -> bool +Silk.NET.Maths.Matrix4X2.M11.get -> T +Silk.NET.Maths.Matrix4X2.M12.get -> T +Silk.NET.Maths.Matrix4X2.M21.get -> T +Silk.NET.Maths.Matrix4X2.M22.get -> T +Silk.NET.Maths.Matrix4X2.M31.get -> T +Silk.NET.Maths.Matrix4X2.M32.get -> T +Silk.NET.Maths.Matrix4X2.M41.get -> T +Silk.NET.Maths.Matrix4X2.M42.get -> T +Silk.NET.Maths.Matrix4X2.Matrix4X2() -> void +Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Matrix2X4 value) -> void +Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Matrix3X2 value) -> void +Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Matrix3X3 value) -> void +Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Matrix3X4 value) -> void +Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Matrix4X3 value) -> void +Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Vector2D row1, Silk.NET.Maths.Vector2D row2, Silk.NET.Maths.Vector2D row3, Silk.NET.Maths.Vector2D row4) -> void +Silk.NET.Maths.Matrix4X2.Matrix4X2(T m11, T m12, T m21, T m22, T m31, T m32, T m41, T m42) -> void +Silk.NET.Maths.Matrix4X2.Row1 -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix4X2.Row2 -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix4X2.Row3 -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix4X2.Row4 -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix4X2.this[int row, int column].get -> T +Silk.NET.Maths.Matrix4X2.this[int row].get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix4X2.Transpose() -> Silk.NET.Maths.Matrix2X4 +Silk.NET.Maths.Matrix4X3 +Silk.NET.Maths.Matrix4X3 +Silk.NET.Maths.Matrix4X3.As() -> Silk.NET.Maths.Matrix4X3 +Silk.NET.Maths.Matrix4X3.AsChecked() -> Silk.NET.Maths.Matrix4X3 +Silk.NET.Maths.Matrix4X3.AsSaturating() -> Silk.NET.Maths.Matrix4X3 +Silk.NET.Maths.Matrix4X3.AsTruncating() -> Silk.NET.Maths.Matrix4X3 +Silk.NET.Maths.Matrix4X3.Column1.get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X3.Column2.get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X3.Column3.get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X3.Equals(Silk.NET.Maths.Matrix4X3 other) -> bool +Silk.NET.Maths.Matrix4X3.IsIdentity.get -> bool +Silk.NET.Maths.Matrix4X3.M11.get -> T +Silk.NET.Maths.Matrix4X3.M12.get -> T +Silk.NET.Maths.Matrix4X3.M13.get -> T +Silk.NET.Maths.Matrix4X3.M21.get -> T +Silk.NET.Maths.Matrix4X3.M22.get -> T +Silk.NET.Maths.Matrix4X3.M23.get -> T +Silk.NET.Maths.Matrix4X3.M31.get -> T +Silk.NET.Maths.Matrix4X3.M32.get -> T +Silk.NET.Maths.Matrix4X3.M33.get -> T +Silk.NET.Maths.Matrix4X3.M41.get -> T +Silk.NET.Maths.Matrix4X3.M42.get -> T +Silk.NET.Maths.Matrix4X3.M43.get -> T +Silk.NET.Maths.Matrix4X3.Matrix4X3() -> void +Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix2X4 value) -> void +Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix3X2 value) -> void +Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix3X3 value) -> void +Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix3X4 value) -> void +Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix4X2 value) -> void +Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix4X3 value) -> void +Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix4X4 value) -> void +Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Vector3D row1, Silk.NET.Maths.Vector3D row2, Silk.NET.Maths.Vector3D row3, Silk.NET.Maths.Vector3D row4) -> void +Silk.NET.Maths.Matrix4X3.Matrix4X3(T m11, T m12, T m13, T m21, T m22, T m23, T m31, T m32, T m33, T m41, T m42, T m43) -> void +Silk.NET.Maths.Matrix4X3.Row1 -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix4X3.Row2 -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix4X3.Row3 -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix4X3.Row4 -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix4X3.this[int row, int column].get -> T +Silk.NET.Maths.Matrix4X3.this[int row].get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix4X3.Transpose() -> Silk.NET.Maths.Matrix3X4 +Silk.NET.Maths.Matrix4X4 +Silk.NET.Maths.Matrix4X4 +Silk.NET.Maths.Matrix4X4.As() -> Silk.NET.Maths.Matrix4X4 +Silk.NET.Maths.Matrix4X4.AsChecked() -> Silk.NET.Maths.Matrix4X4 +Silk.NET.Maths.Matrix4X4.AsSaturating() -> Silk.NET.Maths.Matrix4X4 +Silk.NET.Maths.Matrix4X4.AsTruncating() -> Silk.NET.Maths.Matrix4X4 +Silk.NET.Maths.Matrix4X4.Column1.get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X4.Column2.get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X4.Column3.get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X4.Column4.get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X4.Equals(Silk.NET.Maths.Matrix4X4 other) -> bool +Silk.NET.Maths.Matrix4X4.GetDeterminant() -> T +Silk.NET.Maths.Matrix4X4.IsIdentity.get -> bool +Silk.NET.Maths.Matrix4X4.M11.get -> T +Silk.NET.Maths.Matrix4X4.M12.get -> T +Silk.NET.Maths.Matrix4X4.M13.get -> T +Silk.NET.Maths.Matrix4X4.M14.get -> T +Silk.NET.Maths.Matrix4X4.M21.get -> T +Silk.NET.Maths.Matrix4X4.M22.get -> T +Silk.NET.Maths.Matrix4X4.M23.get -> T +Silk.NET.Maths.Matrix4X4.M24.get -> T +Silk.NET.Maths.Matrix4X4.M31.get -> T +Silk.NET.Maths.Matrix4X4.M32.get -> T +Silk.NET.Maths.Matrix4X4.M33.get -> T +Silk.NET.Maths.Matrix4X4.M34.get -> T +Silk.NET.Maths.Matrix4X4.M41.get -> T +Silk.NET.Maths.Matrix4X4.M42.get -> T +Silk.NET.Maths.Matrix4X4.M43.get -> T +Silk.NET.Maths.Matrix4X4.M44.get -> T +Silk.NET.Maths.Matrix4X4.Matrix4X4() -> void +Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix2X4 value) -> void +Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix3X2 value) -> void +Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix3X3 value) -> void +Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix3X4 value) -> void +Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix4X2 value) -> void +Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix4X3 value) -> void +Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Vector4D row1, Silk.NET.Maths.Vector4D row2, Silk.NET.Maths.Vector4D row3, Silk.NET.Maths.Vector4D row4) -> void +Silk.NET.Maths.Matrix4X4.Matrix4X4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24, T m31, T m32, T m33, T m34, T m41, T m42, T m43, T m44) -> void +Silk.NET.Maths.Matrix4X4.Row1 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X4.Row2 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X4.Row3 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X4.Row4 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X4.this[int row, int column].get -> T +Silk.NET.Maths.Matrix4X4.this[int row].get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X4.Transpose() -> Silk.NET.Maths.Matrix4X4 +Silk.NET.Maths.Matrix5X4 +Silk.NET.Maths.Matrix5X4 +Silk.NET.Maths.Matrix5X4.As() -> Silk.NET.Maths.Matrix5X4 +Silk.NET.Maths.Matrix5X4.AsChecked() -> Silk.NET.Maths.Matrix5X4 +Silk.NET.Maths.Matrix5X4.AsSaturating() -> Silk.NET.Maths.Matrix5X4 +Silk.NET.Maths.Matrix5X4.AsTruncating() -> Silk.NET.Maths.Matrix5X4 +Silk.NET.Maths.Matrix5X4.Equals(Silk.NET.Maths.Matrix5X4 other) -> bool +Silk.NET.Maths.Matrix5X4.IsIdentity.get -> bool +Silk.NET.Maths.Matrix5X4.M11.get -> T +Silk.NET.Maths.Matrix5X4.M12.get -> T +Silk.NET.Maths.Matrix5X4.M13.get -> T +Silk.NET.Maths.Matrix5X4.M14.get -> T +Silk.NET.Maths.Matrix5X4.M21.get -> T +Silk.NET.Maths.Matrix5X4.M22.get -> T +Silk.NET.Maths.Matrix5X4.M23.get -> T +Silk.NET.Maths.Matrix5X4.M24.get -> T +Silk.NET.Maths.Matrix5X4.M31.get -> T +Silk.NET.Maths.Matrix5X4.M32.get -> T +Silk.NET.Maths.Matrix5X4.M33.get -> T +Silk.NET.Maths.Matrix5X4.M34.get -> T +Silk.NET.Maths.Matrix5X4.M41.get -> T +Silk.NET.Maths.Matrix5X4.M42.get -> T +Silk.NET.Maths.Matrix5X4.M43.get -> T +Silk.NET.Maths.Matrix5X4.M44.get -> T +Silk.NET.Maths.Matrix5X4.M51.get -> T +Silk.NET.Maths.Matrix5X4.M52.get -> T +Silk.NET.Maths.Matrix5X4.M53.get -> T +Silk.NET.Maths.Matrix5X4.M54.get -> T +Silk.NET.Maths.Matrix5X4.Matrix5X4() -> void +Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix2X4 value) -> void +Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix3X2 value) -> void +Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix3X3 value) -> void +Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix3X4 value) -> void +Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix4X2 value) -> void +Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix4X3 value) -> void +Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix4X4 value) -> void +Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Vector4D row1, Silk.NET.Maths.Vector4D row2, Silk.NET.Maths.Vector4D row3, Silk.NET.Maths.Vector4D row4, Silk.NET.Maths.Vector4D row5) -> void +Silk.NET.Maths.Matrix5X4.Matrix5X4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24, T m31, T m32, T m33, T m34, T m41, T m42, T m43, T m44, T m51, T m52, T m53, T m54) -> void +Silk.NET.Maths.Matrix5X4.Row1 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix5X4.Row2 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix5X4.Row3 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix5X4.Row4 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix5X4.Row5 -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix5X4.this[int row, int column].get -> T +Silk.NET.Maths.Matrix5X4.this[int row].get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Plane +Silk.NET.Maths.Plane +Silk.NET.Maths.Plane.As() -> Silk.NET.Maths.Plane +Silk.NET.Maths.Plane.Distance -> T +Silk.NET.Maths.Plane.Equals(Silk.NET.Maths.Plane other) -> bool +Silk.NET.Maths.Plane.Normal -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Plane.Plane() -> void +Silk.NET.Maths.Plane.Plane(Silk.NET.Maths.Vector3D normal, T distance) -> void +Silk.NET.Maths.Plane.Plane(Silk.NET.Maths.Vector4D value) -> void +Silk.NET.Maths.Plane.Plane(T x, T y, T z, T distance) -> void +Silk.NET.Maths.Quaternion +Silk.NET.Maths.Quaternion.Angle.get -> T +Silk.NET.Maths.Quaternion.As() -> Silk.NET.Maths.Quaternion +Silk.NET.Maths.Quaternion.Equals(Silk.NET.Maths.Quaternion other) -> bool +Silk.NET.Maths.Quaternion.IsIdentity.get -> bool +Silk.NET.Maths.Quaternion.Length() -> T +Silk.NET.Maths.Quaternion.LengthSquared() -> T +Silk.NET.Maths.Quaternion.Quaternion() -> void +Silk.NET.Maths.Quaternion.Quaternion(Silk.NET.Maths.Vector3D vectorPart, T scalarPart) -> void +Silk.NET.Maths.Quaternion.Quaternion(T x, T y, T z, T w) -> void +Silk.NET.Maths.Quaternion.this[int index].get -> T +Silk.NET.Maths.Quaternion.W -> T +Silk.NET.Maths.Quaternion.X -> T +Silk.NET.Maths.Quaternion.Y -> T +Silk.NET.Maths.Quaternion.Z -> T +Silk.NET.Maths.Ray2D +Silk.NET.Maths.Ray2D.As() -> Silk.NET.Maths.Ray2D +Silk.NET.Maths.Ray2D.Direction -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Ray2D.Equals(Silk.NET.Maths.Ray2D other) -> bool +Silk.NET.Maths.Ray2D.GetPoint(T distance) -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Ray2D.Origin -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Ray2D.Ray2D() -> void +Silk.NET.Maths.Ray2D.Ray2D(Silk.NET.Maths.Vector2D origin, Silk.NET.Maths.Vector2D direction) -> void +Silk.NET.Maths.Ray2D.Ray2D(Silk.NET.Maths.Vector2D origin, T directionX, T directionY) -> void +Silk.NET.Maths.Ray2D.Ray2D(T originX, T originY, Silk.NET.Maths.Vector2D direction) -> void +Silk.NET.Maths.Ray2D.Ray2D(T originX, T originY, T directionX, T directionY) -> void +Silk.NET.Maths.Ray3D +Silk.NET.Maths.Ray3D.As() -> Silk.NET.Maths.Ray3D +Silk.NET.Maths.Ray3D.Direction -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Ray3D.Equals(Silk.NET.Maths.Ray3D other) -> bool +Silk.NET.Maths.Ray3D.GetPoint(T distance) -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Ray3D.Origin -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Ray3D.Ray3D() -> void +Silk.NET.Maths.Ray3D.Ray3D(Silk.NET.Maths.Vector3D origin, Silk.NET.Maths.Vector3D direction) -> void +Silk.NET.Maths.Ray3D.Ray3D(Silk.NET.Maths.Vector3D origin, T directionX, T directionY, T directionZ) -> void +Silk.NET.Maths.Ray3D.Ray3D(T originX, T originY, T originZ, Silk.NET.Maths.Vector3D direction) -> void +Silk.NET.Maths.Ray3D.Ray3D(T originX, T originY, T originZ, T directionX, T directionY, T directionZ) -> void +Silk.NET.Maths.Rectangle +Silk.NET.Maths.Rectangle +Silk.NET.Maths.Rectangle.As() -> Silk.NET.Maths.Rectangle +Silk.NET.Maths.Rectangle.Center.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Rectangle.Contains(Silk.NET.Maths.Rectangle other) -> bool +Silk.NET.Maths.Rectangle.Contains(Silk.NET.Maths.Vector2D point) -> bool +Silk.NET.Maths.Rectangle.Equals(Silk.NET.Maths.Rectangle other) -> bool +Silk.NET.Maths.Rectangle.GetDistanceToNearestEdge(Silk.NET.Maths.Vector2D point) -> T +Silk.NET.Maths.Rectangle.GetInflated(Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Rectangle +Silk.NET.Maths.Rectangle.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Rectangle +Silk.NET.Maths.Rectangle.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Rectangle +Silk.NET.Maths.Rectangle.GetTranslated(Silk.NET.Maths.Vector2D distance) -> Silk.NET.Maths.Rectangle +Silk.NET.Maths.Rectangle.HalfSize.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Rectangle.Max.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Rectangle.Origin -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Rectangle.Rectangle() -> void +Silk.NET.Maths.Rectangle.Rectangle(Silk.NET.Maths.Vector2D origin, Silk.NET.Maths.Vector2D size) -> void +Silk.NET.Maths.Rectangle.Rectangle(Silk.NET.Maths.Vector2D origin, T sizeX, T sizeY) -> void +Silk.NET.Maths.Rectangle.Rectangle(T originX, T originY, Silk.NET.Maths.Vector2D size) -> void +Silk.NET.Maths.Rectangle.Rectangle(T originX, T originY, T sizeX, T sizeY) -> void +Silk.NET.Maths.Rectangle.Size -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Scalar +Silk.NET.Maths.Scalar +Silk.NET.Maths.Sphere +Silk.NET.Maths.Sphere.As() -> Silk.NET.Maths.Sphere +Silk.NET.Maths.Sphere.Center -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Sphere.Contains(Silk.NET.Maths.Sphere other) -> bool +Silk.NET.Maths.Sphere.Contains(Silk.NET.Maths.Vector3D point) -> bool +Silk.NET.Maths.Sphere.Diameter.get -> T +Silk.NET.Maths.Sphere.Equals(Silk.NET.Maths.Sphere other) -> bool +Silk.NET.Maths.Sphere.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D point) -> T +Silk.NET.Maths.Sphere.GetDistanceToNearestEdgeSquared(Silk.NET.Maths.Vector3D point) -> T +Silk.NET.Maths.Sphere.GetInflated(Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Sphere +Silk.NET.Maths.Sphere.GetTranslated(Silk.NET.Maths.Vector3D distance) -> Silk.NET.Maths.Sphere +Silk.NET.Maths.Sphere.Radius -> T +Silk.NET.Maths.Sphere.Sphere() -> void +Silk.NET.Maths.Sphere.Sphere(Silk.NET.Maths.Vector3D center, T radius) -> void +Silk.NET.Maths.Sphere.Sphere(T centerX, T centerY, T centerZ, T radius) -> void +Silk.NET.Maths.Sphere.SquaredRadius.get -> T +Silk.NET.Maths.SystemNumericsExtensions +Silk.NET.Maths.Vector2D +Silk.NET.Maths.Vector2D.extension(Silk.NET.Maths.Vector2D) +Silk.NET.Maths.Vector2D.extension(Silk.NET.Maths.Vector2D).Length.get -> T +Silk.NET.Maths.Vector2D.extension(Silk.NET.Maths.Vector2D).LengthSquared.get -> T +Silk.NET.Maths.Vector2D +Silk.NET.Maths.Vector2D.As() -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Vector2D.AsChecked() -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Vector2D.AsSaturating() -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Vector2D.AsSpan() -> System.Span +Silk.NET.Maths.Vector2D.AsTruncating() -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Vector2D.CopyTo(System.Span span) -> void +Silk.NET.Maths.Vector2D.CopyTo(System.Span span, int startIndex) -> void +Silk.NET.Maths.Vector2D.CopyTo(T[]! array) -> void +Silk.NET.Maths.Vector2D.CopyTo(T[]! array, int startIndex) -> void +Silk.NET.Maths.Vector2D.Count.get -> int +Silk.NET.Maths.Vector2D.Equals(Silk.NET.Maths.Vector2D other) -> bool +Silk.NET.Maths.Vector2D.GetEnumerator() -> System.Collections.Generic.IEnumerator! +Silk.NET.Maths.Vector2D.this[int index].get -> T +Silk.NET.Maths.Vector2D.ToString(string? format, System.IFormatProvider? formatProvider) -> string! +Silk.NET.Maths.Vector2D.TryFormat(System.Span utf8Destination, out int bytesWritten, System.ReadOnlySpan format, System.IFormatProvider? provider) -> bool +Silk.NET.Maths.Vector2D.TryFormat(System.Span destination, out int charsWritten, System.ReadOnlySpan format, System.IFormatProvider? provider) -> bool +Silk.NET.Maths.Vector2D.Vector2D() -> void +Silk.NET.Maths.Vector2D.Vector2D(System.ReadOnlySpan values) -> void +Silk.NET.Maths.Vector2D.Vector2D(T value) -> void +Silk.NET.Maths.Vector2D.Vector2D(T x, T y) -> void +Silk.NET.Maths.Vector2D.X -> T +Silk.NET.Maths.Vector2D.Y -> T +Silk.NET.Maths.Vector3D +Silk.NET.Maths.Vector3D.extension(Silk.NET.Maths.Vector3D) +Silk.NET.Maths.Vector3D.extension(Silk.NET.Maths.Vector3D).Length.get -> T +Silk.NET.Maths.Vector3D.extension(Silk.NET.Maths.Vector3D).LengthSquared.get -> T +Silk.NET.Maths.Vector3D +Silk.NET.Maths.Vector3D.As() -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Vector3D.AsChecked() -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Vector3D.AsSaturating() -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Vector3D.AsSpan() -> System.Span +Silk.NET.Maths.Vector3D.AsTruncating() -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Vector3D.CopyTo(System.Span span) -> void +Silk.NET.Maths.Vector3D.CopyTo(System.Span span, int startIndex) -> void +Silk.NET.Maths.Vector3D.CopyTo(T[]! array) -> void +Silk.NET.Maths.Vector3D.CopyTo(T[]! array, int startIndex) -> void +Silk.NET.Maths.Vector3D.Count.get -> int +Silk.NET.Maths.Vector3D.Equals(Silk.NET.Maths.Vector3D other) -> bool +Silk.NET.Maths.Vector3D.GetEnumerator() -> System.Collections.Generic.IEnumerator! +Silk.NET.Maths.Vector3D.this[int index].get -> T +Silk.NET.Maths.Vector3D.ToString(string? format, System.IFormatProvider? formatProvider) -> string! +Silk.NET.Maths.Vector3D.TryFormat(System.Span utf8Destination, out int bytesWritten, System.ReadOnlySpan format, System.IFormatProvider? provider) -> bool +Silk.NET.Maths.Vector3D.TryFormat(System.Span destination, out int charsWritten, System.ReadOnlySpan format, System.IFormatProvider? provider) -> bool +Silk.NET.Maths.Vector3D.Vector3D() -> void +Silk.NET.Maths.Vector3D.Vector3D(Silk.NET.Maths.Vector2D other, T z) -> void +Silk.NET.Maths.Vector3D.Vector3D(System.ReadOnlySpan values) -> void +Silk.NET.Maths.Vector3D.Vector3D(T value) -> void +Silk.NET.Maths.Vector3D.Vector3D(T x, T y, T z) -> void +Silk.NET.Maths.Vector3D.X -> T +Silk.NET.Maths.Vector3D.Y -> T +Silk.NET.Maths.Vector3D.Z -> T +Silk.NET.Maths.Vector4D +Silk.NET.Maths.Vector4D.extension(Silk.NET.Maths.Vector4D) +Silk.NET.Maths.Vector4D.extension(Silk.NET.Maths.Vector4D).Length.get -> T +Silk.NET.Maths.Vector4D.extension(Silk.NET.Maths.Vector4D).LengthSquared.get -> T +Silk.NET.Maths.Vector4D +Silk.NET.Maths.Vector4D.As() -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Vector4D.AsChecked() -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Vector4D.AsSaturating() -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Vector4D.AsSpan() -> System.Span +Silk.NET.Maths.Vector4D.AsTruncating() -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Vector4D.CopyTo(System.Span span) -> void +Silk.NET.Maths.Vector4D.CopyTo(System.Span span, int startIndex) -> void +Silk.NET.Maths.Vector4D.CopyTo(T[]! array) -> void +Silk.NET.Maths.Vector4D.CopyTo(T[]! array, int startIndex) -> void +Silk.NET.Maths.Vector4D.Count.get -> int +Silk.NET.Maths.Vector4D.Equals(Silk.NET.Maths.Vector4D other) -> bool +Silk.NET.Maths.Vector4D.GetEnumerator() -> System.Collections.Generic.IEnumerator! +Silk.NET.Maths.Vector4D.this[int index].get -> T +Silk.NET.Maths.Vector4D.ToString(string? format, System.IFormatProvider? formatProvider) -> string! +Silk.NET.Maths.Vector4D.TryFormat(System.Span utf8Destination, out int bytesWritten, System.ReadOnlySpan format, System.IFormatProvider? provider) -> bool +Silk.NET.Maths.Vector4D.TryFormat(System.Span destination, out int charsWritten, System.ReadOnlySpan format, System.IFormatProvider? provider) -> bool +Silk.NET.Maths.Vector4D.Vector4D() -> void +Silk.NET.Maths.Vector4D.Vector4D(Silk.NET.Maths.Vector2D other, T z, T w) -> void +Silk.NET.Maths.Vector4D.Vector4D(Silk.NET.Maths.Vector3D other, T w) -> void +Silk.NET.Maths.Vector4D.Vector4D(System.ReadOnlySpan values) -> void +Silk.NET.Maths.Vector4D.Vector4D(T value) -> void +Silk.NET.Maths.Vector4D.Vector4D(T x, T y, T z, T w) -> void +Silk.NET.Maths.Vector4D.W -> T +Silk.NET.Maths.Vector4D.X -> T +Silk.NET.Maths.Vector4D.Y -> T +Silk.NET.Maths.Vector4D.Z -> T +static readonly Silk.NET.Maths.Scalar.DegreesPerRadian -> T +static readonly Silk.NET.Maths.Scalar.E -> T +static readonly Silk.NET.Maths.Scalar.Epsilon -> T +static readonly Silk.NET.Maths.Scalar.MaxValue -> T +static readonly Silk.NET.Maths.Scalar.MinusOne -> T +static readonly Silk.NET.Maths.Scalar.MinusTwo -> T +static readonly Silk.NET.Maths.Scalar.MinValue -> T +static readonly Silk.NET.Maths.Scalar.NaN -> T +static readonly Silk.NET.Maths.Scalar.NegativeInfinity -> T +static readonly Silk.NET.Maths.Scalar.One -> T +static readonly Silk.NET.Maths.Scalar.Pi -> T +static readonly Silk.NET.Maths.Scalar.PiOver2 -> T +static readonly Silk.NET.Maths.Scalar.PositiveInfinity -> T +static readonly Silk.NET.Maths.Scalar.RadiansPerDegree -> T +static readonly Silk.NET.Maths.Scalar.Tau -> T +static readonly Silk.NET.Maths.Scalar.Two -> T +static readonly Silk.NET.Maths.Scalar.Zero -> T +static Silk.NET.Maths.Box2D.operator !=(Silk.NET.Maths.Box2D value1, Silk.NET.Maths.Box2D value2) -> bool +static Silk.NET.Maths.Box2D.operator ==(Silk.NET.Maths.Box2D value1, Silk.NET.Maths.Box2D value2) -> bool +static Silk.NET.Maths.Box3D.operator !=(Silk.NET.Maths.Box3D value1, Silk.NET.Maths.Box3D value2) -> bool +static Silk.NET.Maths.Box3D.operator ==(Silk.NET.Maths.Box3D value1, Silk.NET.Maths.Box3D value2) -> bool +static Silk.NET.Maths.Circle.operator !=(Silk.NET.Maths.Circle value1, Silk.NET.Maths.Circle value2) -> bool +static Silk.NET.Maths.Circle.operator ==(Silk.NET.Maths.Circle value1, Silk.NET.Maths.Circle value2) -> bool +static Silk.NET.Maths.Cube.operator !=(Silk.NET.Maths.Cube value1, Silk.NET.Maths.Cube value2) -> bool +static Silk.NET.Maths.Cube.operator ==(Silk.NET.Maths.Cube value1, Silk.NET.Maths.Cube value2) -> bool +static Silk.NET.Maths.Matrix2X2.Add(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.Lerp(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2, T amount) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 left, T right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 matrix, Silk.NET.Maths.Vector2D columnVector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Vector2D rowVector, Silk.NET.Maths.Matrix2X2 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X2.Multiply(T left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.Negate(Silk.NET.Maths.Matrix2X2 value) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.Subtract(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.CreateChecked(Silk.NET.Maths.Matrix2X2 other) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.CreateSaturating(Silk.NET.Maths.Matrix2X2 other) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.CreateTruncating(Silk.NET.Maths.Matrix2X2 other) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.Identity.get -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.operator !=(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> bool +static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Matrix2X2 left, T right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Matrix2X2 matrix, Silk.NET.Maths.Vector2D columnVector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Vector2D rowVector, Silk.NET.Maths.Matrix2X2 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X2.operator *(T left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.operator +(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.operator -(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.operator -(Silk.NET.Maths.Matrix2X2 value) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.operator ==(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> bool +static Silk.NET.Maths.Matrix2X3.Add(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.CreateBillboard(Silk.NET.Maths.Vector3D objectPosition, Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D cameraUpVector, Silk.NET.Maths.Vector3D cameraForwardVector) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.CreateFromAxisAngle(Silk.NET.Maths.Vector3D axis, T angle) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.CreateFromQuaternion(Silk.NET.Maths.Quaternion quaternion) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.CreateFromYawPitchRoll(T yaw, T pitch, T roll) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Lerp(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2, T amount) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 left, T right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 matrix, Silk.NET.Maths.Vector3D columnVector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Vector2D rowVector, Silk.NET.Maths.Matrix2X3 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix2X3.Multiply(T left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Negate(Silk.NET.Maths.Matrix2X3 value) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Subtract(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Transform(Silk.NET.Maths.Matrix2X3 value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.CreateChecked(Silk.NET.Maths.Matrix2X3 other) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.CreateSaturating(Silk.NET.Maths.Matrix2X3 other) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.CreateTruncating(Silk.NET.Maths.Matrix2X3 other) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Identity.get -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.operator !=(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix2X3 right) -> bool +static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X3 left, T right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X3 matrix, Silk.NET.Maths.Vector3D columnVector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Vector2D rowVector, Silk.NET.Maths.Matrix2X3 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix2X3.operator *(T left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.operator +(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.operator -(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.operator -(Silk.NET.Maths.Matrix2X3 value) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.operator ==(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix2X3 right) -> bool +static Silk.NET.Maths.Matrix2X4.Add(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Lerp(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix2X4 value2, T amount) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 left, T right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 matrix, Silk.NET.Maths.Vector4D columnVector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Vector2D rowVector, Silk.NET.Maths.Matrix2X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix2X4.Multiply(T left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Negate(Silk.NET.Maths.Matrix2X4 value) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Subtract(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.CreateChecked(Silk.NET.Maths.Matrix2X4 other) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.CreateSaturating(Silk.NET.Maths.Matrix2X4 other) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.CreateTruncating(Silk.NET.Maths.Matrix2X4 other) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Identity.get -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.operator !=(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix2X4 right) -> bool +static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X4 left, T right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X4 matrix, Silk.NET.Maths.Vector4D columnVector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Vector2D rowVector, Silk.NET.Maths.Matrix2X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix2X4.operator *(T left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.operator +(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.operator -(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.operator -(Silk.NET.Maths.Matrix2X4 value) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.operator ==(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix2X4 right) -> bool +static Silk.NET.Maths.Matrix3X2.Add(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateRotation(T radians) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateRotation(T radians, Silk.NET.Maths.Vector2D centerPoint) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateScale(Silk.NET.Maths.Vector2D scales) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateScale(Silk.NET.Maths.Vector2D scales, Silk.NET.Maths.Vector2D centerPoint) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateScale(T scale) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateScale(T scale, Silk.NET.Maths.Vector2D centerPoint) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateScale(T xScale, T yScale) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateScale(T xScale, T yScale, Silk.NET.Maths.Vector2D centerPoint) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateSkew(T radiansX, T radiansY) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateSkew(T radiansX, T radiansY, Silk.NET.Maths.Vector2D centerPoint) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateTranslation(Silk.NET.Maths.Vector2D position) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateTranslation(T xPosition, T yPosition) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.Invert(Silk.NET.Maths.Matrix3X2 matrix, out Silk.NET.Maths.Matrix3X2 result) -> bool +static Silk.NET.Maths.Matrix3X2.Lerp(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2, T amount) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 left, T right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 matrix, Silk.NET.Maths.Vector2D columnVector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Vector3D rowVector, Silk.NET.Maths.Matrix3X2 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix3X2.Multiply(T left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.Negate(Silk.NET.Maths.Matrix3X2 value) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.Subtract(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateChecked(Silk.NET.Maths.Matrix3X2 other) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateSaturating(Silk.NET.Maths.Matrix3X2 other) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateTruncating(Silk.NET.Maths.Matrix3X2 other) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator System.Numerics.Matrix3x2(Silk.NET.Maths.Matrix3X2 from) -> System.Numerics.Matrix3x2 +static Silk.NET.Maths.Matrix3X2.Identity.get -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.operator !=(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix3X2 right) -> bool +static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 left, T right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 matrix, Silk.NET.Maths.Vector2D columnVector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Vector3D rowVector, Silk.NET.Maths.Matrix3X2 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix3X2.operator *(T left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.operator +(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.operator -(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.operator -(Silk.NET.Maths.Matrix3X2 value) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.operator ==(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix3X2 right) -> bool +static Silk.NET.Maths.Matrix3X3.Add(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateBillboard(Silk.NET.Maths.Vector3D objectPosition, Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D cameraUpVector, Silk.NET.Maths.Vector3D cameraForwardVector) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateFromAxisAngle(Silk.NET.Maths.Vector3D axis, T angle) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateFromQuaternion(Silk.NET.Maths.Quaternion quaternion) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateFromYawPitchRoll(T yaw, T pitch, T roll) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateRotationX(T radians) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateRotationY(T radians) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateRotationZ(T radians) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateScale(Silk.NET.Maths.Vector3D scales) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateScale(T scale) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateScale(T xScale, T yScale, T zScale) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Lerp(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2, T amount) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 left, T right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 matrix, Silk.NET.Maths.Vector3D columnVector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Vector3D rowVector, Silk.NET.Maths.Matrix3X3 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X3.Multiply(T left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Negate(Silk.NET.Maths.Matrix3X3 value) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Subtract(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Transform(Silk.NET.Maths.Matrix3X3 value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Transpose(Silk.NET.Maths.Matrix3X3 matrix) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateChecked(Silk.NET.Maths.Matrix3X3 other) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateSaturating(Silk.NET.Maths.Matrix3X3 other) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateTruncating(Silk.NET.Maths.Matrix3X3 other) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Identity.get -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.operator !=(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> bool +static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix3X3 left, T right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix3X3 matrix, Silk.NET.Maths.Vector3D columnVector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Vector3D rowVector, Silk.NET.Maths.Matrix3X3 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X3.operator *(T left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.operator +(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.operator -(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.operator -(Silk.NET.Maths.Matrix3X3 value) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.operator ==(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> bool +static Silk.NET.Maths.Matrix3X4.Add(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Lerp(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2, T amount) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 left, T right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 matrix, Silk.NET.Maths.Vector4D columnVector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Vector3D rowVector, Silk.NET.Maths.Matrix3X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix3X4.Multiply(T left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Negate(Silk.NET.Maths.Matrix3X4 value) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Subtract(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.CreateChecked(Silk.NET.Maths.Matrix3X4 other) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.CreateSaturating(Silk.NET.Maths.Matrix3X4 other) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.CreateTruncating(Silk.NET.Maths.Matrix3X4 other) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Identity.get -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.operator !=(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix3X4 right) -> bool +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X4 left, T right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X4 matrix, Silk.NET.Maths.Vector4D columnVector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Vector3D rowVector, Silk.NET.Maths.Matrix3X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix3X4.operator *(T left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.operator +(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.operator -(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.operator -(Silk.NET.Maths.Matrix3X4 value) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.operator ==(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix3X4 right) -> bool +static Silk.NET.Maths.Matrix4X2.Add(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Lerp(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2, T amount) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 left, T right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 matrix, Silk.NET.Maths.Vector2D columnVector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Vector4D rowVector, Silk.NET.Maths.Matrix4X2 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix4X2.Multiply(T left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Negate(Silk.NET.Maths.Matrix4X2 value) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Subtract(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.CreateChecked(Silk.NET.Maths.Matrix4X2 other) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.CreateSaturating(Silk.NET.Maths.Matrix4X2 other) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.CreateTruncating(Silk.NET.Maths.Matrix4X2 other) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Identity.get -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.operator !=(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix4X2 right) -> bool +static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 left, T right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 matrix, Silk.NET.Maths.Vector2D columnVector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Vector4D rowVector, Silk.NET.Maths.Matrix4X2 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix4X2.operator *(T left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.operator +(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.operator -(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.operator -(Silk.NET.Maths.Matrix4X2 value) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.operator ==(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix4X2 right) -> bool +static Silk.NET.Maths.Matrix4X3.Add(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Lerp(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2, T amount) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 left, T right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 matrix, Silk.NET.Maths.Vector3D columnVector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Vector4D rowVector, Silk.NET.Maths.Matrix4X3 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix4X3.Multiply(T left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Negate(Silk.NET.Maths.Matrix4X3 value) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Subtract(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.CreateChecked(Silk.NET.Maths.Matrix4X3 other) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.CreateSaturating(Silk.NET.Maths.Matrix4X3 other) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.CreateTruncating(Silk.NET.Maths.Matrix4X3 other) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Identity.get -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.operator !=(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix4X3 right) -> bool +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 left, T right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 matrix, Silk.NET.Maths.Vector3D columnVector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Vector4D rowVector, Silk.NET.Maths.Matrix4X3 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix4X3.operator *(T left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.operator +(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.operator -(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.operator -(Silk.NET.Maths.Matrix4X3 value) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.operator ==(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix4X3 right) -> bool +static Silk.NET.Maths.Matrix4X4.Add(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateBillboard(Silk.NET.Maths.Vector3D objectPosition, Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D cameraUpVector, Silk.NET.Maths.Vector3D cameraForwardVector) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateConstrainedBillboard(Silk.NET.Maths.Vector3D objectPosition, Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D rotateAxis, Silk.NET.Maths.Vector3D cameraForwardVector, Silk.NET.Maths.Vector3D objectForwardVector) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateFromAxisAngle(Silk.NET.Maths.Vector3D axis, T angle) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateFromQuaternion(Silk.NET.Maths.Quaternion quaternion) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateFromYawPitchRoll(T yaw, T pitch, T roll) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateLookAt(Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D cameraTarget, Silk.NET.Maths.Vector3D cameraUpVector) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateOrthographic(T width, T height, T zNearPlane, T zFarPlane) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateOrthographicOffCenter(T left, T right, T bottom, T top, T zNearPlane, T zFarPlane) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreatePerspective(T width, T height, T nearPlaneDistance, T farPlaneDistance) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreatePerspectiveFieldOfView(T fieldOfView, T aspectRatio, T nearPlaneDistance, T farPlaneDistance) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreatePerspectiveOffCenter(T left, T right, T bottom, T top, T nearPlaneDistance, T farPlaneDistance) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateReflection(Silk.NET.Maths.Plane value) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateRotationX(T radians) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateRotationX(T radians, Silk.NET.Maths.Vector3D centerPoint) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateRotationY(T radians) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateRotationY(T radians, Silk.NET.Maths.Vector3D centerPoint) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateRotationZ(T radians) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateRotationZ(T radians, Silk.NET.Maths.Vector3D centerPoint) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateScale(Silk.NET.Maths.Vector3D scales) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateScale(Silk.NET.Maths.Vector3D scales, Silk.NET.Maths.Vector3D centerPoint) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateScale(T scale) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateScale(T scale, Silk.NET.Maths.Vector3D centerPoint) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateScale(T xScale, T yScale, T zScale) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateScale(T xScale, T yScale, T zScale, Silk.NET.Maths.Vector3D centerPoint) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateShadow(Silk.NET.Maths.Vector3D lightDirection, Silk.NET.Maths.Plane plane) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateTranslation(Silk.NET.Maths.Vector3D position) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateTranslation(T xPosition, T yPosition, T zPosition) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateWorld(Silk.NET.Maths.Vector3D position, Silk.NET.Maths.Vector3D forward, Silk.NET.Maths.Vector3D up) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Invert(Silk.NET.Maths.Matrix4X4 matrix, out Silk.NET.Maths.Matrix4X4 result) -> bool +static Silk.NET.Maths.Matrix4X4.Lerp(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2, T amount) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 left, T right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 matrix, Silk.NET.Maths.Vector4D columnVector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Vector4D rowVector, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X4.Multiply(T left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Negate(Silk.NET.Maths.Matrix4X4 value) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Subtract(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Transform(Silk.NET.Maths.Matrix4X4 value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Transpose(Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateChecked(Silk.NET.Maths.Matrix4X4 other) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateSaturating(Silk.NET.Maths.Matrix4X4 other) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateTruncating(Silk.NET.Maths.Matrix4X4 other) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Identity.get -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.operator !=(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> bool +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 left, T right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 matrix, Silk.NET.Maths.Vector4D columnVector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Vector4D rowVector, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X4.operator *(T left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.operator +(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.operator -(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.operator -(Silk.NET.Maths.Matrix4X4 value) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.operator ==(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> bool +static Silk.NET.Maths.Matrix5X4.Add(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix5X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.Lerp(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2, T amount) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.Multiply(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.Multiply(Silk.NET.Maths.Matrix5X4 left, T right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix5X4.Multiply(T left, Silk.NET.Maths.Matrix5X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.Negate(Silk.NET.Maths.Matrix5X4 value) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.Subtract(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix5X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.CreateChecked(Silk.NET.Maths.Matrix5X4 other) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.CreateSaturating(Silk.NET.Maths.Matrix5X4 other) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.CreateTruncating(Silk.NET.Maths.Matrix5X4 other) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.Identity.get -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.operator !=(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix5X4 right) -> bool +static Silk.NET.Maths.Matrix5X4.operator *(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.operator *(Silk.NET.Maths.Matrix5X4 left, T right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.operator *(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix5X4.operator *(T left, Silk.NET.Maths.Matrix5X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.operator +(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix5X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.operator -(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix5X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.operator -(Silk.NET.Maths.Matrix5X4 value) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.operator ==(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix5X4 right) -> bool +static Silk.NET.Maths.Plane.CreateFromVertices(Silk.NET.Maths.Vector3D point1, Silk.NET.Maths.Vector3D point2, Silk.NET.Maths.Vector3D point3) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.Dot(Silk.NET.Maths.Plane plane, Silk.NET.Maths.Vector4D value) -> T +static Silk.NET.Maths.Plane.DotCoordinate(Silk.NET.Maths.Plane plane, Silk.NET.Maths.Vector3D value) -> T +static Silk.NET.Maths.Plane.DotNormal(Silk.NET.Maths.Plane plane, Silk.NET.Maths.Vector3D value) -> T +static Silk.NET.Maths.Plane.Normalize(Silk.NET.Maths.Plane value) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.Transform(Silk.NET.Maths.Plane plane, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.Transform(Silk.NET.Maths.Plane plane, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator Silk.NET.Maths.Plane(Silk.NET.Maths.Plane from) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.Plane.explicit operator System.Numerics.Plane(Silk.NET.Maths.Plane from) -> System.Numerics.Plane +static Silk.NET.Maths.Plane.operator !=(Silk.NET.Maths.Plane value1, Silk.NET.Maths.Plane value2) -> bool +static Silk.NET.Maths.Plane.operator ==(Silk.NET.Maths.Plane value1, Silk.NET.Maths.Plane value2) -> bool +static Silk.NET.Maths.Quaternion.Add(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.Concatenate(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.Conjugate(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.CreateFromAxisAngle(Silk.NET.Maths.Vector3D axis, T angle) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.CreateFromRotationMatrix(Silk.NET.Maths.Matrix3X3 matrix) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.CreateFromRotationMatrix(Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.CreateFromYawPitchRoll(T yaw, T pitch, T roll) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.Divide(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.Dot(Silk.NET.Maths.Quaternion quaternion1, Silk.NET.Maths.Quaternion quaternion2) -> T +static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.explicit operator System.Numerics.Quaternion(Silk.NET.Maths.Quaternion from) -> System.Numerics.Quaternion +static Silk.NET.Maths.Quaternion.Identity.get -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.Inverse(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.Lerp(Silk.NET.Maths.Quaternion quaternion1, Silk.NET.Maths.Quaternion quaternion2, T amount) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.Multiply(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.Multiply(Silk.NET.Maths.Quaternion value1, T value2) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.Negate(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.Normalize(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.operator !=(Silk.NET.Maths.Quaternion left, Silk.NET.Maths.Quaternion right) -> bool +static Silk.NET.Maths.Quaternion.operator *(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.operator *(Silk.NET.Maths.Quaternion value1, T value2) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.operator +(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.operator -(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.operator -(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.operator /(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.operator ==(Silk.NET.Maths.Quaternion left, Silk.NET.Maths.Quaternion right) -> bool +static Silk.NET.Maths.Quaternion.Slerp(Silk.NET.Maths.Quaternion quaternion1, Silk.NET.Maths.Quaternion quaternion2, T amount) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Quaternion.Subtract(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.Ray2D.operator !=(Silk.NET.Maths.Ray2D value1, Silk.NET.Maths.Ray2D value2) -> bool +static Silk.NET.Maths.Ray2D.operator ==(Silk.NET.Maths.Ray2D value1, Silk.NET.Maths.Ray2D value2) -> bool +static Silk.NET.Maths.Ray3D.operator !=(Silk.NET.Maths.Ray3D value1, Silk.NET.Maths.Ray3D value2) -> bool +static Silk.NET.Maths.Ray3D.operator ==(Silk.NET.Maths.Ray3D value1, Silk.NET.Maths.Ray3D value2) -> bool +static Silk.NET.Maths.Rectangle.FromLTRB(T left, T top, T right, T bottom) -> Silk.NET.Maths.Rectangle +static Silk.NET.Maths.Rectangle.operator !=(Silk.NET.Maths.Rectangle value1, Silk.NET.Maths.Rectangle value2) -> bool +static Silk.NET.Maths.Rectangle.operator ==(Silk.NET.Maths.Rectangle value1, Silk.NET.Maths.Rectangle value2) -> bool +static Silk.NET.Maths.Scalar.Abs(T x) -> T +static Silk.NET.Maths.Scalar.Acos(T x) -> T +static Silk.NET.Maths.Scalar.Acosh(T x) -> T +static Silk.NET.Maths.Scalar.Add(T left, T right) -> T +static Silk.NET.Maths.Scalar.And(T left, T right) -> T +static Silk.NET.Maths.Scalar.As(TFrom val) -> TTo +static Silk.NET.Maths.Scalar.Asin(T x) -> T +static Silk.NET.Maths.Scalar.Asinh(T x) -> T +static Silk.NET.Maths.Scalar.Atan2(T y, T x) -> T +static Silk.NET.Maths.Scalar.Atan(T x) -> T +static Silk.NET.Maths.Scalar.Atanh(T x) -> T +static Silk.NET.Maths.Scalar.Cbrt(T x) -> T +static Silk.NET.Maths.Scalar.Ceiling(T x) -> T +static Silk.NET.Maths.Scalar.Cos(T x) -> T +static Silk.NET.Maths.Scalar.Cosh(T x) -> T +static Silk.NET.Maths.Scalar.DegreesToRadians(T degrees) -> T +static Silk.NET.Maths.Scalar.Divide(T left, T right) -> T +static Silk.NET.Maths.Scalar.Equal(T left, T right) -> bool +static Silk.NET.Maths.Scalar.Exp(T x) -> T +static Silk.NET.Maths.Scalar.Floor(T x) -> T +static Silk.NET.Maths.Scalar.GreaterThan(T left, T right) -> bool +static Silk.NET.Maths.Scalar.GreaterThanOrEqual(T left, T right) -> bool +static Silk.NET.Maths.Scalar.IEEERemainder(T x, T y) -> T +static Silk.NET.Maths.Scalar.IsFinite(T f) -> bool +static Silk.NET.Maths.Scalar.IsHardwareAccelerated.get -> bool +static Silk.NET.Maths.Scalar.IsInfinity(T f) -> bool +static Silk.NET.Maths.Scalar.IsNaN(T f) -> bool +static Silk.NET.Maths.Scalar.IsNegative(T f) -> bool +static Silk.NET.Maths.Scalar.IsNegativeInfinity(T f) -> bool +static Silk.NET.Maths.Scalar.IsNormal(T f) -> bool +static Silk.NET.Maths.Scalar.IsPositiveInfinity(T f) -> bool +static Silk.NET.Maths.Scalar.IsSubnormal(T f) -> bool +static Silk.NET.Maths.Scalar.LessThan(T left, T right) -> bool +static Silk.NET.Maths.Scalar.LessThanOrEqual(T left, T right) -> bool +static Silk.NET.Maths.Scalar.Log10(T x) -> T +static Silk.NET.Maths.Scalar.Log(T x) -> T +static Silk.NET.Maths.Scalar.Log(T x, T y) -> T +static Silk.NET.Maths.Scalar.Max(T x, T y) -> T +static Silk.NET.Maths.Scalar.Min(T x, T y) -> T +static Silk.NET.Maths.Scalar.Multiply(T left, T right) -> T +static Silk.NET.Maths.Scalar.Negate(T x) -> T +static Silk.NET.Maths.Scalar.Not(T value) -> T +static Silk.NET.Maths.Scalar.NotEqual(T left, T right) -> bool +static Silk.NET.Maths.Scalar.Or(T left, T right) -> T +static Silk.NET.Maths.Scalar.Pow(T x, T y) -> T +static Silk.NET.Maths.Scalar.RadiansToDegrees(T radians) -> T +static Silk.NET.Maths.Scalar.Reciprocal(T x) -> T +static Silk.NET.Maths.Scalar.RotateLeft(T value, int offset) -> T +static Silk.NET.Maths.Scalar.RotateRight(T value, int offset) -> T +static Silk.NET.Maths.Scalar.Round(T x) -> T +static Silk.NET.Maths.Scalar.Round(T x, int digits) -> T +static Silk.NET.Maths.Scalar.Round(T x, int digits, System.MidpointRounding mode) -> T +static Silk.NET.Maths.Scalar.Round(T x, System.MidpointRounding mode) -> T +static Silk.NET.Maths.Scalar.ShiftLeft(T value, int offset) -> T +static Silk.NET.Maths.Scalar.ShiftRight(T value, int offset) -> T +static Silk.NET.Maths.Scalar.Sign(T x) -> int +static Silk.NET.Maths.Scalar.Sin(T x) -> T +static Silk.NET.Maths.Scalar.Sinh(T x) -> T +static Silk.NET.Maths.Scalar.Sqrt(T x) -> T +static Silk.NET.Maths.Scalar.Subtract(T left, T right) -> T +static Silk.NET.Maths.Scalar.Tan(T x) -> T +static Silk.NET.Maths.Scalar.Tanh(T x) -> T +static Silk.NET.Maths.Scalar.Truncate(T x) -> T +static Silk.NET.Maths.Scalar.Xor(T left, T right) -> T +static Silk.NET.Maths.Sphere.operator !=(Silk.NET.Maths.Sphere value1, Silk.NET.Maths.Sphere value2) -> bool +static Silk.NET.Maths.Sphere.operator ==(Silk.NET.Maths.Sphere value1, Silk.NET.Maths.Sphere value2) -> bool +static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Matrix3x2 value) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Matrix4x4 value) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Plane value) -> Silk.NET.Maths.Plane +static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Quaternion value) -> Silk.NET.Maths.Quaternion +static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Vector2 value) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Vector3 value) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Vector4 value) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Matrix3X2 value) -> System.Numerics.Matrix3x2 +static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Matrix4X4 value) -> System.Numerics.Matrix4x4 +static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Plane value) -> System.Numerics.Plane +static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Quaternion value) -> System.Numerics.Quaternion +static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Vector2D value) -> System.Numerics.Vector2 +static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Vector3D value) -> System.Numerics.Vector3 +static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Vector4D value) -> System.Numerics.Vector4 +static Silk.NET.Maths.Vector2D.Abs(this Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Acos(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Acosh(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.AcosPi(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Asin(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Asinh(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.AsinPi(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Atan2(this Silk.NET.Maths.Vector2D y, Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Atan2Pi(this Silk.NET.Maths.Vector2D y, Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Atan(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Atanh(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.AtanPi(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.BitDecrement(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.BitIncrement(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Cbrt(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Ceiling(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Clamp(this Silk.NET.Maths.Vector2D value, Silk.NET.Maths.Vector2D min, Silk.NET.Maths.Vector2D max) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Clamp(this Silk.NET.Maths.Vector2D value, TSelf min, TSelf max) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.CopySign(this Silk.NET.Maths.Vector2D value, Silk.NET.Maths.Vector2D sign) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.CopySign(this Silk.NET.Maths.Vector2D value, TSelf sign) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Cos(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Cosh(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.CosPi(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Cross(this Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> T +static Silk.NET.Maths.Vector2D.Deconstruct(this Silk.NET.Maths.Vector2D vector, out T x, out T y) -> void +static Silk.NET.Maths.Vector2D.DegreesToRadians(this Silk.NET.Maths.Vector2D degrees) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Distance(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2) -> T +static Silk.NET.Maths.Vector2D.DistanceSquared(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2) -> T +static Silk.NET.Maths.Vector2D.DivRem(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> (Silk.NET.Maths.Vector2D Quotient, Silk.NET.Maths.Vector2D Remainder) +static Silk.NET.Maths.Vector2D.Dot(this Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> T +static Silk.NET.Maths.Vector2D.Exp10(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Exp10M1(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Exp2(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Exp2M1(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Exp(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.ExpM1(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Floor(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.FusedMultiplyAdd(this Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right, Silk.NET.Maths.Vector2D addend) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.FusedMultiplyAdd(this Silk.NET.Maths.Vector2D left, TSelf right, TSelf addend) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Hypot(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Ieee754Remainder(this Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Ieee754Remainder(this Silk.NET.Maths.Vector2D left, TSelf right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.ILogB(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Lerp(this Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2, TSelf amount) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.LerpClamped(Silk.NET.Maths.Vector2D a, Silk.NET.Maths.Vector2D b, Silk.NET.Maths.Vector2D amount) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.LerpClamped(Silk.NET.Maths.Vector2D a, Silk.NET.Maths.Vector2D b, T amount) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log10(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log10P1(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log2(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log2P1(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log(this Silk.NET.Maths.Vector2D x, TSelf newBase) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.LogP1(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Max(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Max(this Silk.NET.Maths.Vector2D x, TSelf y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MaxMagnitude(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MaxMagnitudeNumber(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MaxNumber(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MaxNumber(this Silk.NET.Maths.Vector2D x, TSelf y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Min(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Min(this Silk.NET.Maths.Vector2D x, TSelf y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MinMagnitude(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MinMagnitudeNumber(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MinNumber(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MinNumber(this Silk.NET.Maths.Vector2D x, TSelf y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Multiply(Silk.NET.Maths.Vector2D left, T right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Multiply(T left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Normalize(this Silk.NET.Maths.Vector2D vector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.PopCount(this Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Pow(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Pow(this Silk.NET.Maths.Vector2D x, TSelf y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.RadiansToDegrees(this Silk.NET.Maths.Vector2D radians) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.ReciprocalEstimate(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.ReciprocalSqrtEstimate(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Reflect(Silk.NET.Maths.Vector2D vector, Silk.NET.Maths.Vector2D normal) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.RootN(this Silk.NET.Maths.Vector2D x, int n) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.RootN(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D n) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Round(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Round(this Silk.NET.Maths.Vector2D x, int digits, System.MidpointRounding mode) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.ScaleB(this Silk.NET.Maths.Vector2D x, int n) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.ScaleB(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D n) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Sign(this Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Sin(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.SinCos(this Silk.NET.Maths.Vector2D x) -> (Silk.NET.Maths.Vector2D Sin, Silk.NET.Maths.Vector2D Cos) +static Silk.NET.Maths.Vector2D.SinCosPi(this Silk.NET.Maths.Vector2D x) -> (Silk.NET.Maths.Vector2D SinPi, Silk.NET.Maths.Vector2D CosPi) +static Silk.NET.Maths.Vector2D.Sinh(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.SinPi(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Sqrt(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Tan(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Tanh(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.TanPi(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.TrailingZeroCount(this Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Truncate(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.CreateChecked(Silk.NET.Maths.Vector2D source) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.CreateSaturating(Silk.NET.Maths.Vector2D source) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.CreateTruncating(Silk.NET.Maths.Vector2D source) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(System.Numerics.Vector2 v) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator System.Numerics.Vector2(Silk.NET.Maths.Vector2D v) -> System.Numerics.Vector2 +static Silk.NET.Maths.Vector2D.implicit operator (T X, T Y)(Silk.NET.Maths.Vector2D v) -> (T X, T Y) +static Silk.NET.Maths.Vector2D.implicit operator Silk.NET.Maths.Vector2D((T X, T Y) v) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.One.get -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator !=(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> bool +static Silk.NET.Maths.Vector2D.operator *(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator *(Silk.NET.Maths.Vector2D vector, T scalar) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator *(T scalar, Silk.NET.Maths.Vector2D vector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator +(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator +(Silk.NET.Maths.Vector2D vector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator +(Silk.NET.Maths.Vector2D vector, T scalar) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator -(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator -(Silk.NET.Maths.Vector2D vector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator -(Silk.NET.Maths.Vector2D vector, T scalar) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator /(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator /(Silk.NET.Maths.Vector2D vector, T scalar) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator ==(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> bool +static Silk.NET.Maths.Vector2D.Parse(string! s, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Parse(System.ReadOnlySpan utf8Text, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Parse(System.ReadOnlySpan s, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.TryParse(string? s, System.IFormatProvider? provider, out Silk.NET.Maths.Vector2D result) -> bool +static Silk.NET.Maths.Vector2D.TryParse(System.ReadOnlySpan utf8Text, System.IFormatProvider? provider, out Silk.NET.Maths.Vector2D result) -> bool +static Silk.NET.Maths.Vector2D.TryParse(System.ReadOnlySpan s, System.IFormatProvider? provider, out Silk.NET.Maths.Vector2D result) -> bool +static Silk.NET.Maths.Vector2D.UnitX.get -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.UnitY.get -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Zero.get -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector3D.Abs(this Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Acos(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Acosh(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.AcosPi(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Asin(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Asinh(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.AsinPi(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Atan2(this Silk.NET.Maths.Vector3D y, Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Atan2Pi(this Silk.NET.Maths.Vector3D y, Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Atan(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Atanh(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.AtanPi(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.BitDecrement(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.BitIncrement(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Cbrt(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Ceiling(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Clamp(this Silk.NET.Maths.Vector3D value, Silk.NET.Maths.Vector3D min, Silk.NET.Maths.Vector3D max) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Clamp(this Silk.NET.Maths.Vector3D value, TSelf min, TSelf max) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.CopySign(this Silk.NET.Maths.Vector3D value, Silk.NET.Maths.Vector3D sign) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.CopySign(this Silk.NET.Maths.Vector3D value, TSelf sign) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Cos(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Cosh(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.CosPi(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Cross(this Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Deconstruct(this Silk.NET.Maths.Vector3D vector, out T x, out T y, out T z) -> void +static Silk.NET.Maths.Vector3D.DegreesToRadians(this Silk.NET.Maths.Vector3D degrees) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Distance(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2) -> T +static Silk.NET.Maths.Vector3D.DistanceSquared(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2) -> T +static Silk.NET.Maths.Vector3D.DivRem(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> (Silk.NET.Maths.Vector3D Quotient, Silk.NET.Maths.Vector3D Remainder) +static Silk.NET.Maths.Vector3D.Dot(this Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> T +static Silk.NET.Maths.Vector3D.Exp10(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Exp10M1(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Exp2(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Exp2M1(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Exp(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.ExpM1(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Floor(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.FusedMultiplyAdd(this Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right, Silk.NET.Maths.Vector3D addend) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.FusedMultiplyAdd(this Silk.NET.Maths.Vector3D left, TSelf right, TSelf addend) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Hypot(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Ieee754Remainder(this Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Ieee754Remainder(this Silk.NET.Maths.Vector3D left, TSelf right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.ILogB(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Lerp(this Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2, TSelf amount) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.LerpClamped(Silk.NET.Maths.Vector3D a, Silk.NET.Maths.Vector3D b, Silk.NET.Maths.Vector3D amount) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.LerpClamped(Silk.NET.Maths.Vector3D a, Silk.NET.Maths.Vector3D b, T amount) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log10(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log10P1(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log2(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log2P1(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log(this Silk.NET.Maths.Vector3D x, TSelf newBase) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.LogP1(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Max(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Max(this Silk.NET.Maths.Vector3D x, TSelf y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MaxMagnitude(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MaxMagnitudeNumber(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MaxNumber(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MaxNumber(this Silk.NET.Maths.Vector3D x, TSelf y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Min(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Min(this Silk.NET.Maths.Vector3D x, TSelf y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MinMagnitude(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MinMagnitudeNumber(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MinNumber(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MinNumber(this Silk.NET.Maths.Vector3D x, TSelf y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Multiply(Silk.NET.Maths.Vector3D left, T right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Multiply(T left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Normalize(this Silk.NET.Maths.Vector3D vector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.PopCount(this Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Pow(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Pow(this Silk.NET.Maths.Vector3D x, TSelf y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.RadiansToDegrees(this Silk.NET.Maths.Vector3D radians) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.ReciprocalEstimate(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.ReciprocalSqrtEstimate(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Reflect(Silk.NET.Maths.Vector3D vector, Silk.NET.Maths.Vector3D normal) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.RootN(this Silk.NET.Maths.Vector3D x, int n) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.RootN(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D n) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Round(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Round(this Silk.NET.Maths.Vector3D x, int digits, System.MidpointRounding mode) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.ScaleB(this Silk.NET.Maths.Vector3D x, int n) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.ScaleB(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D n) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Sign(this Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Sin(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.SinCos(this Silk.NET.Maths.Vector3D x) -> (Silk.NET.Maths.Vector3D Sin, Silk.NET.Maths.Vector3D Cos) +static Silk.NET.Maths.Vector3D.SinCosPi(this Silk.NET.Maths.Vector3D x) -> (Silk.NET.Maths.Vector3D SinPi, Silk.NET.Maths.Vector3D CosPi) +static Silk.NET.Maths.Vector3D.Sinh(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.SinPi(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Sqrt(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Tan(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Tanh(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.TanPi(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.TrailingZeroCount(this Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Truncate(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.CreateChecked(Silk.NET.Maths.Vector3D source) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.CreateSaturating(Silk.NET.Maths.Vector3D source) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.CreateTruncating(Silk.NET.Maths.Vector3D source) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(System.Numerics.Vector3 v) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator System.Numerics.Vector3(Silk.NET.Maths.Vector3D v) -> System.Numerics.Vector3 +static Silk.NET.Maths.Vector3D.implicit operator (T X, T Y, T Z)(Silk.NET.Maths.Vector3D v) -> (T X, T Y, T Z) +static Silk.NET.Maths.Vector3D.implicit operator Silk.NET.Maths.Vector3D((T X, T Y, T Z) v) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.One.get -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator !=(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> bool +static Silk.NET.Maths.Vector3D.operator *(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator *(Silk.NET.Maths.Vector3D vector, T scalar) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator *(T scalar, Silk.NET.Maths.Vector3D vector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator +(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator +(Silk.NET.Maths.Vector3D vector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator +(Silk.NET.Maths.Vector3D vector, T scalar) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator -(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator -(Silk.NET.Maths.Vector3D vector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator -(Silk.NET.Maths.Vector3D vector, T scalar) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator /(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator /(Silk.NET.Maths.Vector3D vector, T scalar) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator ==(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> bool +static Silk.NET.Maths.Vector3D.Parse(string! s, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Parse(System.ReadOnlySpan utf8Text, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Parse(System.ReadOnlySpan s, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.TryParse(string? s, System.IFormatProvider? provider, out Silk.NET.Maths.Vector3D result) -> bool +static Silk.NET.Maths.Vector3D.TryParse(System.ReadOnlySpan utf8Text, System.IFormatProvider? provider, out Silk.NET.Maths.Vector3D result) -> bool +static Silk.NET.Maths.Vector3D.TryParse(System.ReadOnlySpan s, System.IFormatProvider? provider, out Silk.NET.Maths.Vector3D result) -> bool +static Silk.NET.Maths.Vector3D.UnitX.get -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.UnitY.get -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.UnitZ.get -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Zero.get -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector4D.Abs(this Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Acos(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Acosh(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.AcosPi(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Asin(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Asinh(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.AsinPi(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Atan2(this Silk.NET.Maths.Vector4D y, Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Atan2Pi(this Silk.NET.Maths.Vector4D y, Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Atan(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Atanh(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.AtanPi(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.BitDecrement(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.BitIncrement(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Cbrt(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Ceiling(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Clamp(this Silk.NET.Maths.Vector4D value, Silk.NET.Maths.Vector4D min, Silk.NET.Maths.Vector4D max) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Clamp(this Silk.NET.Maths.Vector4D value, TSelf min, TSelf max) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.CopySign(this Silk.NET.Maths.Vector4D value, Silk.NET.Maths.Vector4D sign) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.CopySign(this Silk.NET.Maths.Vector4D value, TSelf sign) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Cos(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Cosh(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.CosPi(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Deconstruct(this Silk.NET.Maths.Vector4D vector, out T x, out T y, out T z, out T w) -> void +static Silk.NET.Maths.Vector4D.DegreesToRadians(this Silk.NET.Maths.Vector4D degrees) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Distance(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2) -> T +static Silk.NET.Maths.Vector4D.DistanceSquared(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2) -> T +static Silk.NET.Maths.Vector4D.DivRem(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> (Silk.NET.Maths.Vector4D Quotient, Silk.NET.Maths.Vector4D Remainder) +static Silk.NET.Maths.Vector4D.Dot(this Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> T +static Silk.NET.Maths.Vector4D.Exp10(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Exp10M1(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Exp2(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Exp2M1(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Exp(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.ExpM1(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Floor(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.FusedMultiplyAdd(this Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right, Silk.NET.Maths.Vector4D addend) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.FusedMultiplyAdd(this Silk.NET.Maths.Vector4D left, TSelf right, TSelf addend) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Hypot(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Ieee754Remainder(this Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Ieee754Remainder(this Silk.NET.Maths.Vector4D left, TSelf right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.ILogB(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Lerp(this Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2, TSelf amount) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.LerpClamped(Silk.NET.Maths.Vector4D a, Silk.NET.Maths.Vector4D b, Silk.NET.Maths.Vector4D amount) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.LerpClamped(Silk.NET.Maths.Vector4D a, Silk.NET.Maths.Vector4D b, T amount) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log10(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log10P1(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log2(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log2P1(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log(this Silk.NET.Maths.Vector4D x, TSelf newBase) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.LogP1(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Max(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Max(this Silk.NET.Maths.Vector4D x, TSelf y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MaxMagnitude(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MaxMagnitudeNumber(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MaxNumber(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MaxNumber(this Silk.NET.Maths.Vector4D x, TSelf y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Min(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Min(this Silk.NET.Maths.Vector4D x, TSelf y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MinMagnitude(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MinMagnitudeNumber(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MinNumber(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MinNumber(this Silk.NET.Maths.Vector4D x, TSelf y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Multiply(Silk.NET.Maths.Vector4D left, T right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Multiply(T left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Normalize(this Silk.NET.Maths.Vector4D vector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.PopCount(this Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Pow(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Pow(this Silk.NET.Maths.Vector4D x, TSelf y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.RadiansToDegrees(this Silk.NET.Maths.Vector4D radians) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.ReciprocalEstimate(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.ReciprocalSqrtEstimate(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Reflect(Silk.NET.Maths.Vector4D vector, Silk.NET.Maths.Vector4D normal) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.RootN(this Silk.NET.Maths.Vector4D x, int n) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.RootN(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D n) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Round(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Round(this Silk.NET.Maths.Vector4D x, int digits, System.MidpointRounding mode) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.ScaleB(this Silk.NET.Maths.Vector4D x, int n) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.ScaleB(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D n) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Sign(this Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Sin(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.SinCos(this Silk.NET.Maths.Vector4D x) -> (Silk.NET.Maths.Vector4D Sin, Silk.NET.Maths.Vector4D Cos) +static Silk.NET.Maths.Vector4D.SinCosPi(this Silk.NET.Maths.Vector4D x) -> (Silk.NET.Maths.Vector4D SinPi, Silk.NET.Maths.Vector4D CosPi) +static Silk.NET.Maths.Vector4D.Sinh(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.SinPi(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Sqrt(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Tan(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Tanh(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.TanPi(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.TrailingZeroCount(this Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Truncate(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.CreateChecked(Silk.NET.Maths.Vector4D source) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.CreateSaturating(Silk.NET.Maths.Vector4D source) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.CreateTruncating(Silk.NET.Maths.Vector4D source) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(System.Numerics.Vector4 v) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator System.Numerics.Vector4(Silk.NET.Maths.Vector4D v) -> System.Numerics.Vector4 +static Silk.NET.Maths.Vector4D.implicit operator (T X, T Y, T Z, T W)(Silk.NET.Maths.Vector4D v) -> (T X, T Y, T Z, T W) +static Silk.NET.Maths.Vector4D.implicit operator Silk.NET.Maths.Vector4D((T X, T Y, T Z, T W) v) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.One.get -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator !=(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> bool +static Silk.NET.Maths.Vector4D.operator *(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator *(Silk.NET.Maths.Vector4D vector, T scalar) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator *(T scalar, Silk.NET.Maths.Vector4D vector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator +(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator +(Silk.NET.Maths.Vector4D vector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator +(Silk.NET.Maths.Vector4D vector, T scalar) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator -(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator -(Silk.NET.Maths.Vector4D vector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator -(Silk.NET.Maths.Vector4D vector, T scalar) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator /(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator /(Silk.NET.Maths.Vector4D vector, T scalar) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator ==(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> bool +static Silk.NET.Maths.Vector4D.Parse(string! s, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Parse(System.ReadOnlySpan utf8Text, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Parse(System.ReadOnlySpan s, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.TryParse(string? s, System.IFormatProvider? provider, out Silk.NET.Maths.Vector4D result) -> bool +static Silk.NET.Maths.Vector4D.TryParse(System.ReadOnlySpan utf8Text, System.IFormatProvider? provider, out Silk.NET.Maths.Vector4D result) -> bool +static Silk.NET.Maths.Vector4D.TryParse(System.ReadOnlySpan s, System.IFormatProvider? provider, out Silk.NET.Maths.Vector4D result) -> bool +static Silk.NET.Maths.Vector4D.UnitW.get -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.UnitX.get -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.UnitY.get -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.UnitZ.get -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Zero.get -> Silk.NET.Maths.Vector4D From de7b9f1fad37e545623392ab5750be2c67f06dba Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Fri, 18 Jul 2025 11:00:42 -0700 Subject: [PATCH 53/67] Remove Scalar class and references. --- .../Silk.NET.Maths.Benchmarks/AbsBenchmark.cs | 53 - .../Silk.NET.Maths.Benchmarks/ExpBenchmark.cs | 74 - .../FloorBenchmark.cs | 53 - .../Silk.NET.Maths.Benchmarks/LogBenchmark.cs | 74 - .../Silk.NET.Maths.Benchmarks/PowBenchmark.cs | 115 - .../RoundBenchmark.cs | 271 - .../Silk.NET.Maths.Benchmarks/SinBenchmark.cs | 38 - .../SqrtBenchmark.cs | 53 - sources/Maths/Maths/Box2D.cs | 17 +- sources/Maths/Maths/Box3D.cs | 27 +- sources/Maths/Maths/Circle.cs | 21 +- sources/Maths/Maths/Cube.cs | 24 +- sources/Maths/Maths/Matrix2X2.cs | 2 +- sources/Maths/Maths/Matrix2X3.Ops.cs | 104 +- sources/Maths/Maths/Matrix2X3.cs | 4 +- sources/Maths/Maths/Matrix3X2.Ops.cs | 122 +- sources/Maths/Maths/Matrix3X2.cs | 16 +- sources/Maths/Maths/Matrix3X3.Ops.cs | 190 +- sources/Maths/Maths/Matrix3X3.cs | 6 +- sources/Maths/Maths/Matrix4X2.cs | 8 +- sources/Maths/Maths/Matrix4X3.cs | 10 +- sources/Maths/Maths/Matrix4X4.Ops.cs | 516 +- sources/Maths/Maths/Matrix4X4.cs | 35 +- sources/Maths/Maths/Plane.Ops.cs | 144 +- sources/Maths/Maths/Plane.cs | 44 +- .../PublicAPI/net8.0/PublicAPI.Unshipped.txt | 83 - sources/Maths/Maths/Quaternion.Old.cs | 392 +- sources/Maths/Maths/Quaternion.cs | 2 +- sources/Maths/Maths/Rectangle.cs | 20 +- sources/Maths/Maths/Scalar.As.cs | 3184 ---------- sources/Maths/Maths/Scalar.As.tt | 178 - sources/Maths/Maths/Scalar.BaseOps.cs | 2266 ------- .../Maths/Maths/Scalar.Bitwise/Scalar.And.cs | 137 - .../Maths/Maths/Scalar.Bitwise/Scalar.Not.cs | 137 - .../Maths/Maths/Scalar.Bitwise/Scalar.Or.cs | 137 - .../Maths/Scalar.Bitwise/Scalar.RotateLeft.cs | 148 - .../Scalar.Bitwise/Scalar.RotateRight.cs | 148 - .../Maths/Scalar.Bitwise/Scalar.ShiftLeft.cs | 137 - .../Maths/Scalar.Bitwise/Scalar.ShiftRight.cs | 137 - .../Maths/Maths/Scalar.Bitwise/Scalar.Xor.cs | 137 - sources/Maths/Maths/Scalar.Constants.cs | 387 -- sources/Maths/Maths/Scalar.Conversions.cs | 26 - sources/Maths/Maths/Scalar.Exp.cs | 244 - sources/Maths/Maths/Scalar.Inverse.cs | 185 - sources/Maths/Maths/Scalar.Log.cs | 307 - .../Maths/Scalar.MathFPort.MissingMethods.cs | 379 -- sources/Maths/Maths/Scalar.MathFPort.cs | 5658 ----------------- sources/Maths/Maths/Scalar.Pow.cs | 19 - sources/Maths/Maths/Scalar.Sin.cs | 476 -- sources/Maths/Maths/Silk.NET.Maths.csproj | 15 - sources/Maths/Maths/Sphere.cs | 21 +- tests/Maths/Maths/ExpTests.cs | 75 - tests/Maths/Maths/LogTests.cs | 56 - tests/Maths/Maths/PlaneTests.cs | 4 +- tests/Maths/Maths/PowIntTests.cs | 55 - tests/Maths/Maths/Scalar.Bitwise.cs | 111 - tests/Maths/Maths/ScalarTests.cs | 90 - 57 files changed, 843 insertions(+), 16529 deletions(-) delete mode 100644 eng/benchmarks/Silk.NET.Maths.Benchmarks/AbsBenchmark.cs delete mode 100644 eng/benchmarks/Silk.NET.Maths.Benchmarks/ExpBenchmark.cs delete mode 100644 eng/benchmarks/Silk.NET.Maths.Benchmarks/FloorBenchmark.cs delete mode 100644 eng/benchmarks/Silk.NET.Maths.Benchmarks/LogBenchmark.cs delete mode 100644 eng/benchmarks/Silk.NET.Maths.Benchmarks/PowBenchmark.cs delete mode 100644 eng/benchmarks/Silk.NET.Maths.Benchmarks/RoundBenchmark.cs delete mode 100644 eng/benchmarks/Silk.NET.Maths.Benchmarks/SinBenchmark.cs delete mode 100644 eng/benchmarks/Silk.NET.Maths.Benchmarks/SqrtBenchmark.cs delete mode 100644 sources/Maths/Maths/Scalar.As.cs delete mode 100644 sources/Maths/Maths/Scalar.As.tt delete mode 100644 sources/Maths/Maths/Scalar.BaseOps.cs delete mode 100644 sources/Maths/Maths/Scalar.Bitwise/Scalar.And.cs delete mode 100644 sources/Maths/Maths/Scalar.Bitwise/Scalar.Not.cs delete mode 100644 sources/Maths/Maths/Scalar.Bitwise/Scalar.Or.cs delete mode 100644 sources/Maths/Maths/Scalar.Bitwise/Scalar.RotateLeft.cs delete mode 100644 sources/Maths/Maths/Scalar.Bitwise/Scalar.RotateRight.cs delete mode 100644 sources/Maths/Maths/Scalar.Bitwise/Scalar.ShiftLeft.cs delete mode 100644 sources/Maths/Maths/Scalar.Bitwise/Scalar.ShiftRight.cs delete mode 100644 sources/Maths/Maths/Scalar.Bitwise/Scalar.Xor.cs delete mode 100644 sources/Maths/Maths/Scalar.Constants.cs delete mode 100644 sources/Maths/Maths/Scalar.Conversions.cs delete mode 100644 sources/Maths/Maths/Scalar.Exp.cs delete mode 100644 sources/Maths/Maths/Scalar.Inverse.cs delete mode 100644 sources/Maths/Maths/Scalar.Log.cs delete mode 100644 sources/Maths/Maths/Scalar.MathFPort.MissingMethods.cs delete mode 100644 sources/Maths/Maths/Scalar.MathFPort.cs delete mode 100644 sources/Maths/Maths/Scalar.Pow.cs delete mode 100644 sources/Maths/Maths/Scalar.Sin.cs delete mode 100644 tests/Maths/Maths/ExpTests.cs delete mode 100644 tests/Maths/Maths/LogTests.cs delete mode 100644 tests/Maths/Maths/PowIntTests.cs delete mode 100644 tests/Maths/Maths/Scalar.Bitwise.cs delete mode 100644 tests/Maths/Maths/ScalarTests.cs diff --git a/eng/benchmarks/Silk.NET.Maths.Benchmarks/AbsBenchmark.cs b/eng/benchmarks/Silk.NET.Maths.Benchmarks/AbsBenchmark.cs deleted file mode 100644 index afdf43e36f..0000000000 --- a/eng/benchmarks/Silk.NET.Maths.Benchmarks/AbsBenchmark.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Engines; - -namespace Silk.NET.Maths.Benchmark -{ - [SimpleJob(RunStrategy.Throughput)] - public class AbsBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - public int XInt; - - [GlobalSetup] - public void GlobalSetup() - { - XInt = (int)X; - } - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Abs(X); -#else - return (float)Math.Abs(X); -#endif - } - - [Benchmark] - public float SilkFloat() - { - return Scalar.Abs(X); - } - - [Benchmark] - public int SilkInt() - { - return Scalar.Abs(XInt); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) _random.NextDouble(); - } - } -} diff --git a/eng/benchmarks/Silk.NET.Maths.Benchmarks/ExpBenchmark.cs b/eng/benchmarks/Silk.NET.Maths.Benchmarks/ExpBenchmark.cs deleted file mode 100644 index 772762ebeb..0000000000 --- a/eng/benchmarks/Silk.NET.Maths.Benchmarks/ExpBenchmark.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Engines; - -namespace Silk.NET.Maths.Benchmark -{ - [MemoryDiagnoser] - [SimpleJob(RunStrategy.Throughput)] - public class ExpSmallBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Exp(X); -#else - return (float)Math.Exp(X); -#endif - } - - [Benchmark] - public float Silk() - { - return Scalar.Exp(X); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) _random.NextDouble(); - } - } - - [MemoryDiagnoser] - [SimpleJob(RunStrategy.Throughput)] - public class ExpBigBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Exp(X); -#else - return (float)Math.Exp(X); -#endif - } - - [Benchmark] - public float Silk() - { - return Scalar.Exp(X); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) (_random.NextDouble() * 10) + 10f; - } - } -} \ No newline at end of file diff --git a/eng/benchmarks/Silk.NET.Maths.Benchmarks/FloorBenchmark.cs b/eng/benchmarks/Silk.NET.Maths.Benchmarks/FloorBenchmark.cs deleted file mode 100644 index bbd1dfd989..0000000000 --- a/eng/benchmarks/Silk.NET.Maths.Benchmarks/FloorBenchmark.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Engines; - -namespace Silk.NET.Maths.Benchmark -{ - [SimpleJob(RunStrategy.Throughput)] - public class FloorBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - public int XInt; - - [GlobalSetup] - public void GlobalSetup() - { - XInt = (int)X; - } - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Floor(X); -#else - return (float)Math.Floor(X); -#endif - } - - [Benchmark] - public float SilkFloat() - { - return Scalar.Floor(X); - } - - [Benchmark] - public int SilkInt() - { - return Scalar.Floor(XInt); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) _random.NextDouble(); - } - } -} diff --git a/eng/benchmarks/Silk.NET.Maths.Benchmarks/LogBenchmark.cs b/eng/benchmarks/Silk.NET.Maths.Benchmarks/LogBenchmark.cs deleted file mode 100644 index 6838db77af..0000000000 --- a/eng/benchmarks/Silk.NET.Maths.Benchmarks/LogBenchmark.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Engines; - -namespace Silk.NET.Maths.Benchmark -{ - [MemoryDiagnoser] - [SimpleJob(RunStrategy.Throughput)] - public class LogSmallBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Log(X); -#else - return (float)Math.Log(X); -#endif - } - - [Benchmark] - public float Silk() - { - return Scalar.Log(X); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) _random.NextDouble(); - } - } - - [MemoryDiagnoser] - [SimpleJob(RunStrategy.Throughput)] - public class LogBigBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Log(X); -#else - return (float)Math.Log(X); -#endif - } - - [Benchmark] - public float Silk() - { - return Scalar.Log(X); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) (_random.NextDouble() * 1000); - } - } -} \ No newline at end of file diff --git a/eng/benchmarks/Silk.NET.Maths.Benchmarks/PowBenchmark.cs b/eng/benchmarks/Silk.NET.Maths.Benchmarks/PowBenchmark.cs deleted file mode 100644 index eb1453ce82..0000000000 --- a/eng/benchmarks/Silk.NET.Maths.Benchmarks/PowBenchmark.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Engines; - -namespace Silk.NET.Maths.Benchmark -{ - [MemoryDiagnoser] - [SimpleJob(RunStrategy.Throughput)] - public class PowSmallBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - [ParamsSource("GenerateNumber")] public float Y; - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Pow(X, Y); -#else - return (float)Math.Pow(X, Y); -#endif - } - - [Benchmark] - public float Silk() - { - return Scalar.Pow(X, Y); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) _random.NextDouble(); - } - } - - [MemoryDiagnoser] - [SimpleJob(RunStrategy.Throughput)] - public class PowBigBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - [ParamsSource("GenerateNumber")] public float Y; - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Pow(X, Y); -#else - return (float)Math.Pow(X, Y); -#endif - } - - [Benchmark] - public float Silk() - { - return Scalar.Pow(X, Y); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) (_random.NextDouble() * 10) + 10f; - } - } - - [MemoryDiagnoser] - [SimpleJob(RunStrategy.Throughput)] - public class PowIntBenchmark - { - [ParamsSource("GenerateNumber")] public int X; - [ParamsSource("GenerateNumber")] public int Y; - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Pow(X, Y); -#else - return (float)Math.Pow(X, Y); -#endif - } - - [Benchmark] - public float SilkFloat() - { - return Scalar.Pow(X, Y); - } - - [Benchmark] - public float SilkInt() - { - return Scalar.Pow(X, Y); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return _random.Next(-1000, 1000); - } - } -} \ No newline at end of file diff --git a/eng/benchmarks/Silk.NET.Maths.Benchmarks/RoundBenchmark.cs b/eng/benchmarks/Silk.NET.Maths.Benchmarks/RoundBenchmark.cs deleted file mode 100644 index e245e977b1..0000000000 --- a/eng/benchmarks/Silk.NET.Maths.Benchmarks/RoundBenchmark.cs +++ /dev/null @@ -1,271 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Engines; - -namespace Silk.NET.Maths.Benchmark -{ - [SimpleJob(RunStrategy.Throughput)] - public class RoundAllBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - public int XInt; - [ParamsAllValues] public MidpointRounding Mode; - - [GlobalSetup] - public void GlobalSetup() - { - XInt = (int)X; - } - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Round(X, Mode); -#else - return (float)Math.Round(X, Mode); -#endif - } - - [Benchmark] - public float SilkFloat() - { - return Scalar.Round(X, Mode); - } - - [Benchmark] - public int SilkInt() - { - return Scalar.Round(XInt, Mode); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) _random.NextDouble(); - } - } - -#if !NET48 - [SimpleJob(RunStrategy.Throughput)] - public class RoundToPositiveInfinityBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - public int XInt; - - [GlobalSetup] - public void GlobalSetup() - { - XInt = (int)X; - } - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Round(X, MidpointRounding.ToPositiveInfinity); -#else - return (float)Math.Round(X, MidpointRounding.ToPositiveInfinity); -#endif - } - - [Benchmark] - public float SilkFloat() - { - return Scalar.Round(X, MidpointRounding.ToPositiveInfinity); - } - - [Benchmark] - public int SilkInt() - { - return Scalar.Round(XInt, MidpointRounding.ToPositiveInfinity); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) _random.NextDouble(); - } - } - - [SimpleJob(RunStrategy.Throughput)] - public class RoundToNegativeInfinityBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - public int XInt; - - [GlobalSetup] - public void GlobalSetup() - { - XInt = (int)X; - } - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Round(X, MidpointRounding.ToNegativeInfinity); -#else - return (float)Math.Round(X, MidpointRounding.ToNegativeInfinity); -#endif - } - - [Benchmark] - public float SilkFloat() - { - return Scalar.Round(X, MidpointRounding.ToNegativeInfinity); - } - - [Benchmark] - public int SilkInt() - { - return Scalar.Round(XInt, MidpointRounding.ToNegativeInfinity); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) _random.NextDouble(); - } - } - - [SimpleJob(RunStrategy.Throughput)] - public class RoundToZeroBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - public int XInt; - - [GlobalSetup] - public void GlobalSetup() - { - XInt = (int)X; - } - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Round(X, MidpointRounding.ToZero); -#else - return (float)Math.Round(X, MidpointRounding.ToZero); -#endif - } - - [Benchmark] - public float SilkFloat() - { - return Scalar.Round(X, MidpointRounding.ToZero); - } - - [Benchmark] - public int SilkInt() - { - return Scalar.Round(XInt, MidpointRounding.ToZero); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) _random.NextDouble(); - } - } -#endif - - [SimpleJob(RunStrategy.Throughput)] - public class RoundAwayFromZeroBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - public int XInt; - - [GlobalSetup] - public void GlobalSetup() - { - XInt = (int) X; - } - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Round(X, MidpointRounding.AwayFromZero); -#else - return (float) Math.Round(X, MidpointRounding.AwayFromZero); -#endif - } - - [Benchmark] - public float SilkFloat() - { - return Scalar.Round(X, MidpointRounding.AwayFromZero); - } - - [Benchmark] - public int SilkInt() - { - return Scalar.Round(XInt, MidpointRounding.AwayFromZero); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) _random.NextDouble(); - } - } - - [SimpleJob(RunStrategy.Throughput)] - public class RoundToEvenBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - public int XInt; - - [GlobalSetup] - public void GlobalSetup() - { - XInt = (int)X; - } - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Round(X, MidpointRounding.ToEven); -#else - return (float)Math.Round(X, MidpointRounding.ToEven); -#endif - } - - [Benchmark] - public float SilkFloat() - { - return Scalar.Round(X, MidpointRounding.ToEven); - } - - [Benchmark] - public int SilkInt() - { - return Scalar.Round(XInt, MidpointRounding.ToEven); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) _random.NextDouble(); - } - } -} diff --git a/eng/benchmarks/Silk.NET.Maths.Benchmarks/SinBenchmark.cs b/eng/benchmarks/Silk.NET.Maths.Benchmarks/SinBenchmark.cs deleted file mode 100644 index f1b4924856..0000000000 --- a/eng/benchmarks/Silk.NET.Maths.Benchmarks/SinBenchmark.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using BenchmarkDotNet.Attributes; - -namespace Silk.NET.Maths.Benchmark -{ - public class SinBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Sin(X); -#else - return (float)Math.Sin(X); -#endif - } - - [Benchmark] - public float Silk() - { - return Scalar.Sin(X); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) _random.NextDouble(); - } - } -} diff --git a/eng/benchmarks/Silk.NET.Maths.Benchmarks/SqrtBenchmark.cs b/eng/benchmarks/Silk.NET.Maths.Benchmarks/SqrtBenchmark.cs deleted file mode 100644 index e91ae90f4f..0000000000 --- a/eng/benchmarks/Silk.NET.Maths.Benchmarks/SqrtBenchmark.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Engines; - -namespace Silk.NET.Maths.Benchmark -{ - [SimpleJob(RunStrategy.Throughput)] - public class SqrtBenchmark - { - [ParamsSource("GenerateNumber")] public float X; - public int XInt; - - [GlobalSetup] - public void GlobalSetup() - { - XInt = (int)X; - } - - [Benchmark(Baseline = true)] - public float Sys() - { -#if MATHF - return MathF.Sqrt(X); -#else - return (float)Math.Sqrt(X); -#endif - } - - [Benchmark] - public float SilkFloat() - { - return Scalar.Sqrt(X); - } - - [Benchmark] - public int SilkInt() - { - return Scalar.Sqrt(XInt); - } - - private const int NumbersTested = 1; - private static Random _random = new Random(); - public IEnumerable GenerateNumber() - { - for (int i = 0; i < NumbersTested; i++) - yield return (float) (_random.NextDouble() + 5) * 100; - } - } -} diff --git a/sources/Maths/Maths/Box2D.cs b/sources/Maths/Maths/Box2D.cs index c468e2fa48..4eb606def6 100644 --- a/sources/Maths/Maths/Box2D.cs +++ b/sources/Maths/Maths/Box2D.cs @@ -22,6 +22,7 @@ public struct Box2D /// [DataMember] public Vector2D Min; + /// /// The max. /// @@ -77,7 +78,7 @@ public Box2D(T minX, T minY, T maxX, T maxY) /// The center of this box. /// [IgnoreDataMember] - public Vector2D Center => (Min + Max) / Scalar.Two; + public Vector2D Center => (Min + Max) / T.CreateTruncating(2); /// /// The size of this box. @@ -93,8 +94,8 @@ public Box2D(T minX, T minY, T maxX, T maxY) /// True if this box contains the point; False otherwise. /// This does consider a point on the edge contained. public bool Contains(Vector2D point) - => Scalar.GreaterThanOrEqual(point.X, Min.X) && Scalar.GreaterThanOrEqual(point.Y, Min.Y) - && Scalar.LessThanOrEqual(point.X, Max.X) && Scalar.LessThanOrEqual(point.Y, Max.Y); + => (point.X >= Min.X) && (point.Y >= Min.Y) + && (point.X <= Max.X) && (point.Y <= Max.Y); /// /// Calculates whether this box contains another box @@ -103,8 +104,8 @@ public bool Contains(Vector2D point) /// True if this box contains the given box; False otherwise. /// This does consider a box that touches the edge contained. public bool Contains(Box2D other) - => Scalar.GreaterThanOrEqual(other.Min.X, Min.X) && Scalar.GreaterThanOrEqual(other.Min.Y, Min.Y) - && Scalar.LessThanOrEqual(other.Max.X, Max.X) && Scalar.LessThanOrEqual(other.Max.Y, Max.Y); + => (other.Min.X >= Min.X) && (other.Min.Y >= Min.Y) + && (other.Max.X <= Max.X) && (other.Max.Y <= Max.Y); /// /// Calculates the distance to the nearest edge from the point. @@ -113,9 +114,9 @@ public bool Contains(Box2D other) /// The distance. public T GetDistanceToNearestEdge(Vector2D point) { - var dx = Scalar.Max(Scalar.Max(Scalar.Subtract(Min.X, point.X), Scalar.Zero), Scalar.Subtract(point.X, Max.X)); - var dy = Scalar.Max(Scalar.Max(Scalar.Subtract(Min.Y, point.Y), Scalar.Zero), Scalar.Subtract(point.Y, Max.Y)); - return Scalar.Sqrt(Scalar.Add(Scalar.Multiply(dx, dx), Scalar.Multiply(dy, dy))); + var dx = T.Max(T.Max(Min.X - point.X, T.Zero), point.X - Max.X); + var dy = T.Max(T.Max(Min.Y - point.Y, T.Zero), point.Y - Max.Y); + return T.Sqrt((dx * dx) + (dy * dy)); } /// diff --git a/sources/Maths/Maths/Box3D.cs b/sources/Maths/Maths/Box3D.cs index 4e50cfb16a..5b81675b4d 100644 --- a/sources/Maths/Maths/Box3D.cs +++ b/sources/Maths/Maths/Box3D.cs @@ -22,6 +22,7 @@ public struct Box3D /// [DataMember] public Vector3D Min; + /// /// The max. /// @@ -81,7 +82,7 @@ public Box3D(T minX, T minY, T minZ, T maxX, T maxY, T maxZ) /// The center of this box. /// [IgnoreDataMember] - public Vector3D Center => (Min + Max) / Scalar.Two; + public Vector3D Center => (Min + Max) / T.CreateTruncating(2); /// /// The size of this box. @@ -97,10 +98,8 @@ public Box3D(T minX, T minY, T minZ, T maxX, T maxY, T maxZ) /// True if this box contains the point; False otherwise. /// This does consider a point on the edge contained. public bool Contains(Vector3D point) - => Scalar.GreaterThanOrEqual(point.X, Min.X) && Scalar.GreaterThanOrEqual(point.Y, Min.Y) - && Scalar.GreaterThanOrEqual(point.Z, Min.Z) - && Scalar.LessThanOrEqual(point.X, Max.X) && Scalar.LessThanOrEqual(point.Y, Max.Y) - && Scalar.LessThanOrEqual(point.Z, Max.Z); + => (point.X >= Min.X) && (point.Y >= Min.Y) && (point.Z >= Min.Z) + && (point.X <= Max.X) && (point.Y <= Max.Y) && (point.Z <= Max.Z); /// /// Calculates whether this box contains another box @@ -109,10 +108,8 @@ public bool Contains(Vector3D point) /// True if this box contains the given box; False otherwise. /// This does consider a box that touches the edge contained. public bool Contains(Box3D other) - => Scalar.GreaterThanOrEqual(other.Min.X, this.Min.X) && Scalar.GreaterThanOrEqual(other.Min.Y, this.Min.Y) - && Scalar.GreaterThanOrEqual(other.Min.Z, this.Min.Z) - && Scalar.LessThanOrEqual(other.Max.X, this.Max.X) && Scalar.LessThanOrEqual(other.Max.Y, this.Max.Y) - && Scalar.LessThanOrEqual(other.Max.Z, this.Max.Z); + => (other.Min.X >= this.Min.X) && (other.Min.Y >= this.Min.Y) && (other.Min.Z >= this.Min.Z) + && (other.Max.X <= this.Max.X) && (other.Max.Y <= this.Max.Y) && (other.Max.Z <= this.Max.Z); /// /// Calculates the distance to the nearest edge from the point. @@ -121,10 +118,10 @@ public bool Contains(Box3D other) /// The distance. public T GetDistanceToNearestEdge(Vector3D point) { - var dx = Scalar.Max(Scalar.Max(Scalar.Subtract(Min.X, point.X), Scalar.Zero), Scalar.Subtract(point.X, Max.X)); - var dy = Scalar.Max(Scalar.Max(Scalar.Subtract(Min.Y, point.Y), Scalar.Zero), Scalar.Subtract(point.Y, Max.Y)); - var dz = Scalar.Max(Scalar.Max(Scalar.Subtract(Min.Z, point.Z), Scalar.Zero), Scalar.Subtract(point.Z, Max.Z)); - return Scalar.Sqrt(Scalar.Add(Scalar.Add(Scalar.Multiply(dx, dx), Scalar.Multiply(dy, dy)), Scalar.Multiply(dz, dz))); + var dx = T.Max(T.Max(Min.X - point.X, T.Zero), point.X - Max.X); + var dy = T.Max(T.Max(Min.Y - point.Y, T.Zero), point.Y - Max.Y); + var dz = T.Max(T.Max(Min.Z - point.Z, T.Zero), point.Z - Max.Z); + return T.Sqrt((dx * dx) + (dy * dy) + (dz * dz)); } /// @@ -149,7 +146,7 @@ public Box3D GetScaled(Vector3D scale, Vector3D anchor) var max = (scale * (Max - anchor)) + anchor; return new(min, max); } - + /// /// Calculates a new box scaled by the given scale around the given anchor. /// @@ -216,7 +213,7 @@ public override int GetHashCode() { return !value1.Equals(value2); } - + /// /// Returns this box casted to /// diff --git a/sources/Maths/Maths/Circle.cs b/sources/Maths/Maths/Circle.cs index 53e37c049e..fc860c1814 100644 --- a/sources/Maths/Maths/Circle.cs +++ b/sources/Maths/Maths/Circle.cs @@ -21,6 +21,7 @@ public struct Circle /// [DataMember] public Vector2D Center; + /// /// The radius. /// @@ -53,19 +54,19 @@ public Circle(T centerX, T centerY, T radius) /// The diameter. /// [IgnoreDataMember] - public T Diameter => Scalar.Multiply(Radius, Scalar.Two); + public T Diameter => Radius * T.CreateTruncating(2); /// /// The radius squared. /// [IgnoreDataMember] - public T SquaredRadius => Scalar.Multiply(Radius, Radius); + public T SquaredRadius => Radius * Radius; /// /// The circumference. /// [IgnoreDataMember] - public T Circumference => Scalar.Multiply(Scalar.Tau, Radius); + public T Circumference => T.Tau * Radius; /// /// Calculates whether this circle contains a point. @@ -75,7 +76,7 @@ public Circle(T centerX, T centerY, T radius) /// This does consider a point on the edge contained. public bool Contains(Vector2D point) { - return Scalar.LessThanOrEqual(Vector2D.DistanceSquared(point, Center), Radius); + return Vector2D.DistanceSquared(point, Center) <= Radius; } /// @@ -87,8 +88,8 @@ public bool Contains(Vector2D point) public bool Contains(Circle other) { var distanceSquared = Vector2D.DistanceSquared(Center, other.Center); - var radiusDiff = Scalar.Subtract(Radius, other.Radius); - return Scalar.LessThanOrEqual(distanceSquared, Scalar.Multiply(radiusDiff, radiusDiff)); + var radiusDiff = Radius - other.Radius; + return distanceSquared <= radiusDiff * radiusDiff; } /// @@ -98,7 +99,7 @@ public bool Contains(Circle other) /// The distance squared. public T GetDistanceToNearestEdgeSquared(Vector2D point) { - return Scalar.Subtract(Vector2D.DistanceSquared(Center, point), SquaredRadius); + return Vector2D.DistanceSquared(Center, point) - SquaredRadius; } /// @@ -106,7 +107,7 @@ public T GetDistanceToNearestEdgeSquared(Vector2D point) /// /// The point. /// The distance. - public T GetDistanceToNearestEdge(Vector2D point) => Scalar.Sqrt(GetDistanceToNearestEdgeSquared(point)); + public T GetDistanceToNearestEdge(Vector2D point) => T.Sqrt(GetDistanceToNearestEdgeSquared(point)); /// /// Calculates a new circle translated by a given distance. @@ -125,7 +126,7 @@ public Circle GetTranslated(Vector2D distance) /// The circle. public Circle GetInflated(Vector2D point) { - return new(Center, Scalar.Max(Radius, Vector2D.Distance(Center, point))); + return new(Center, T.Max(Radius, Vector2D.Distance(Center, point))); } /// Returns a boolean indicating whether the given Circle is equal to this Circle instance. @@ -177,7 +178,7 @@ public override int GetHashCode() [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Circle As() where TOther : IRootFunctions { - return new(Center.As(), Scalar.As(Radius)); + return new(Center.As(), TOther.CreateTruncating(Radius)); } } } diff --git a/sources/Maths/Maths/Cube.cs b/sources/Maths/Maths/Cube.cs index bdc61f267e..6948ab6200 100644 --- a/sources/Maths/Maths/Cube.cs +++ b/sources/Maths/Maths/Cube.cs @@ -22,6 +22,7 @@ public struct Cube /// [DataMember] public Vector3D Origin; + /// /// The size. /// @@ -93,7 +94,7 @@ public Cube(T originX, T originY, T originZ, T sizeX, T sizeY, T sizeZ) /// Half the size of this cube. /// [IgnoreDataMember] - public Vector3D HalfSize => Size / Scalar.Two; + public Vector3D HalfSize => Size / T.CreateTruncating(2); /// /// Calculates whether this cube contains a point. @@ -104,9 +105,8 @@ public Cube(T originX, T originY, T originZ, T sizeX, T sizeY, T sizeZ) public bool Contains(Vector3D point) { var max = Max; - return Scalar.GreaterThanOrEqual(point.X, Origin.X) && Scalar.GreaterThanOrEqual - (point.Y, Origin.Y) && Scalar.GreaterThanOrEqual(point.Z, Origin.Z) && Scalar.LessThanOrEqual - (point.X, max.X) && Scalar.LessThanOrEqual(point.Y, max.Y) && Scalar.LessThanOrEqual(point.Z, max.Z); + return (point.X >= Origin.X) && (point.Y >= Origin.Y) && (point.Z >= Origin.Z) + && (point.X <= max.X) && (point.Y <= max.Y) && (point.Z <= max.Z); } /// @@ -119,10 +119,8 @@ public bool Contains(Cube other) { var tMax = this.Max; var oMax = other.Max; - return Scalar.GreaterThanOrEqual(other.Origin.X, this.Origin.X) && Scalar.GreaterThanOrEqual - (other.Origin.Y, this.Origin.Y) && Scalar.GreaterThanOrEqual - (other.Origin.Z, this.Origin.Z) && Scalar.LessThanOrEqual(oMax.X, tMax.X) && Scalar.LessThanOrEqual - (oMax.Y, tMax.Y) && Scalar.GreaterThanOrEqual(oMax.Y, tMax.Y); + return (other.Origin.X >= this.Origin.X) && (other.Origin.Y >= this.Origin.Y) && (other.Origin.Z >= this.Origin.Z) + && (oMax.X <= tMax.X) && (oMax.Y <= tMax.Y) && (oMax.Y <= tMax.Y); } /// @@ -133,10 +131,10 @@ public bool Contains(Cube other) public T GetDistanceToNearestEdge(Vector3D point) { var max = Max; - var dx = Scalar.Max(Scalar.Max(Scalar.Subtract(Origin.X, point.X), Scalar.Zero), Scalar.Subtract(point.X, max.X)); - var dy = Scalar.Max(Scalar.Max(Scalar.Subtract(Origin.Y, point.Y), Scalar.Zero), Scalar.Subtract(point.Y, max.Y)); - var dz = Scalar.Max(Scalar.Max(Scalar.Subtract(Origin.Z, point.Z), Scalar.Zero), Scalar.Subtract(point.Z, max.Z)); - return Scalar.Sqrt(Scalar.Add(Scalar.Add(Scalar.Multiply(dx, dx), Scalar.Multiply(dy, dy)), Scalar.Multiply(dz, dz))); + var dx = T.Max(T.Max(Origin.X - point.X, T.Zero), point.X - max.X); + var dy = T.Max(T.Max(Origin.Y - point.Y, T.Zero), point.Y - max.Y); + var dz = T.Max(T.Max(Origin.Z - point.Z, T.Zero), point.Z - max.Z); + return T.Sqrt((dx * dx) + (dy * dy) + (dz * dz)); } /// @@ -161,7 +159,7 @@ public Cube GetScaled(Vector3D scale, Vector3D anchor) var max = (scale * (Max - anchor)) + anchor; return new(min, max - min); } - + /// /// Calculates a new cube scaled by the given scale around the given anchor. /// diff --git a/sources/Maths/Maths/Matrix2X2.cs b/sources/Maths/Maths/Matrix2X2.cs index 25d3a702ca..adfb53b5b2 100644 --- a/sources/Maths/Maths/Matrix2X2.cs +++ b/sources/Maths/Maths/Matrix2X2.cs @@ -64,7 +64,7 @@ public readonly T GetDeterminant() T a = Row1.X, b = Row1.Y; T d = Row2.X, c = Row1.Y; - return Scalar.Subtract(Scalar.Multiply(a, d), Scalar.Multiply(b, c)); + return (a * d) - (b * c); } } } diff --git a/sources/Maths/Maths/Matrix2X3.Ops.cs b/sources/Maths/Maths/Matrix2X3.Ops.cs index fdd180d1ce..d201af2e30 100644 --- a/sources/Maths/Maths/Matrix2X3.Ops.cs +++ b/sources/Maths/Maths/Matrix2X3.Ops.cs @@ -26,13 +26,13 @@ public static Matrix2X3 CreateBillboard(Vector3D objectPosition, Vector Vector3D zaxis = objectPosition - cameraPosition; var norm = zaxis.LengthSquared; - if (!Scalar.GreaterThanOrEqual(norm, Scalar.As(BillboardEpsilon))) + if (!(norm >= T.CreateTruncating(BillboardEpsilon))) { zaxis = -cameraForwardVector; } else { - zaxis = Vector3D.Multiply(zaxis, Scalar.Reciprocal(Scalar.Sqrt(norm))); + zaxis = Vector3D.Multiply(zaxis, T.One / T.Sqrt(norm)); } Vector3D xaxis = Vector3D.Normalize(Vector3D.Cross(cameraUpVector, zaxis)); @@ -74,19 +74,19 @@ public static Matrix2X3 CreateFromAxisAngle(Vector3D axis, T angle) // [ zx-cosa*zx-sina*y zy-cosa*zy+sina*x zz+cosa*(1-zz) ] // T x = axis.X, y = axis.Y, z = axis.Z; - T sa = Scalar.Sin(angle), ca = Scalar.Cos(angle); - T xx = Scalar.Multiply(x, x), yy = Scalar.Multiply(y, y), zz = Scalar.Multiply(z, z); - T xy = Scalar.Multiply(x, y), xz = Scalar.Multiply(x, z), yz = Scalar.Multiply(y, z); + T sa = T.Sin(angle), ca = T.Cos(angle); + T xx = x * x, yy = y * y, zz = z * z; + T xy = x * y, xz = x * z, yz = y * z; Matrix2X3 result = Matrix2X3.Identity; - result.M11 = Scalar.Add(xx, Scalar.Multiply(ca, Scalar.Subtract(Scalar.One, xx))); - result.M12 = Scalar.Add(Scalar.Subtract(xy, Scalar.Multiply(ca, xy)), Scalar.Multiply(sa, z)); - result.M13 = Scalar.Subtract(Scalar.Subtract(xz, Scalar.Multiply(ca, xz)), Scalar.Multiply(sa, y)); + result.M11 = xx + (ca * (T.One - xx)); + result.M12 = xy - (ca * xy) + (sa * z); + result.M13 = xz - (ca * xz) - (sa * y); - result.M21 = Scalar.Subtract(Scalar.Subtract(xy, Scalar.Multiply(ca, xy)), Scalar.Multiply(sa, z)); - result.M22 = Scalar.Add(yy, Scalar.Multiply(ca, Scalar.Subtract(Scalar.One, yy))); - result.M23 = Scalar.Add(Scalar.Subtract(yz, Scalar.Multiply(ca, yz)), Scalar.Multiply(sa, x)); + result.M21 = xy - (ca * xy) - (sa * z); + result.M22 = yy + (ca * (T.One - yy)); + result.M23 = yz - (ca * yz) + (sa * x); return result; } @@ -99,24 +99,24 @@ public static Matrix2X3 CreateFromQuaternion(Quaternion quaternion) { Matrix2X3 result = Matrix2X3.Identity; - T xx = Scalar.Multiply(quaternion.X, quaternion.X); - T yy = Scalar.Multiply(quaternion.Y, quaternion.Y); - T zz = Scalar.Multiply(quaternion.Z, quaternion.Z); + T xx = quaternion.X * quaternion.X; + T yy = quaternion.Y * quaternion.Y; + T zz = quaternion.Z * quaternion.Z; - T xy = Scalar.Multiply(quaternion.X, quaternion.Y); - T wz = Scalar.Multiply(quaternion.Z, quaternion.W); - T xz = Scalar.Multiply(quaternion.Z, quaternion.X); - T wy = Scalar.Multiply(quaternion.Y, quaternion.W); - T yz = Scalar.Multiply(quaternion.Y, quaternion.Z); - T wx = Scalar.Multiply(quaternion.X, quaternion.W); + T xy = quaternion.X * quaternion.Y; + T wz = quaternion.Z * quaternion.W; + T xz = quaternion.Z * quaternion.X; + T wy = quaternion.Y * quaternion.W; + T yz = quaternion.Y * quaternion.Z; + T wx = quaternion.X * quaternion.W; - result.M11 = Scalar.Subtract(Scalar.One, Scalar.Multiply(Scalar.Two, Scalar.Add(yy, zz))); - result.M12 = Scalar.Multiply(Scalar.Two, Scalar.Add(xy, wz)); - result.M13 = Scalar.Multiply(Scalar.Two, Scalar.Subtract(xz, wy)); + result.M11 = T.One - (T.CreateTruncating(2) * (yy + zz)); + result.M12 = T.CreateTruncating(2) * (xy + wz); + result.M13 = T.CreateTruncating(2) * (xz - wy); - result.M21 = Scalar.Multiply(Scalar.Two, Scalar.Subtract(xy, wz)); - result.M22 = Scalar.Subtract(Scalar.One, Scalar.Multiply(Scalar.Two, Scalar.Add(zz, xx))); - result.M23 = Scalar.Multiply(Scalar.Two, Scalar.Add(yz, wx)); + result.M21 = T.CreateTruncating(2) * (xy - wz); + result.M22 = T.One - (T.CreateTruncating(2) * (zz + xx)); + result.M23 = T.CreateTruncating(2) * (yz + wx); return result; } @@ -142,37 +142,37 @@ public static Matrix2X3 Transform(Matrix2X3 value, Quaternion rotati where T : ITrigonometricFunctions { // Compute rotation matrix. - T x2 = Scalar.Add(rotation.X, rotation.X); - T y2 = Scalar.Add(rotation.Y, rotation.Y); - T z2 = Scalar.Add(rotation.Z, rotation.Z); - - T wx2 = Scalar.Multiply(rotation.W, x2); - T wy2 = Scalar.Multiply(rotation.W, y2); - T wz2 = Scalar.Multiply(rotation.W, z2); - T xx2 = Scalar.Multiply(rotation.X, x2); - T xy2 = Scalar.Multiply(rotation.X, y2); - T xz2 = Scalar.Multiply(rotation.X, z2); - T yy2 = Scalar.Multiply(rotation.Y, y2); - T yz2 = Scalar.Multiply(rotation.Y, z2); - T zz2 = Scalar.Multiply(rotation.Z, z2); - - T q11 = Scalar.Subtract(Scalar.Subtract(Scalar.One, yy2), zz2); - T q21 = Scalar.Subtract(xy2, wz2); - T q31 = Scalar.Add(xz2, wy2); - - T q12 = Scalar.Add(xy2, wz2); - T q22 = Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), zz2); - T q32 = Scalar.Subtract(yz2, wx2); - - T q13 = Scalar.Subtract(xz2, wy2); - T q23 = Scalar.Add(yz2, wx2); - T q33 = Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), yy2); + T x2 = rotation.X + rotation.X; + T y2 = rotation.Y + rotation.Y; + T z2 = rotation.Z + rotation.Z; + + T wx2 = rotation.W * x2; + T wy2 = rotation.W * y2; + T wz2 = rotation.W * z2; + T xx2 = rotation.X * x2; + T xy2 = rotation.X * y2; + T xz2 = rotation.X * z2; + T yy2 = rotation.Y * y2; + T yz2 = rotation.Y * z2; + T zz2 = rotation.Z * z2; + + T q11 = T.One - yy2 - zz2; + T q21 = xy2 - wz2; + T q31 = xz2 + wy2; + + T q12 = xy2 + wz2; + T q22 = T.One - xx2 - zz2; + T q32 = yz2 - wx2; + + T q13 = xz2 - wy2; + T q23 = yz2 + wx2; + T q33 = T.One - xx2 - yy2; var q1 = new Vector3D(q11, q12, q13); var q2 = new Vector3D(q21, q22, q23); var q3 = new Vector3D(q31, q32, q33); - return new(value.M11 * q1 + value.M12 * q2 + value.M13 * q3, value.M21 * q1 + value.M22 * q2 + value.M23 * q3); + return new((value.M11 * q1) + (value.M12 * q2) + (value.M13 * q3), (value.M21 * q1) + (value.M22 * q2) + (value.M23 * q3)); } } } diff --git a/sources/Maths/Maths/Matrix2X3.cs b/sources/Maths/Maths/Matrix2X3.cs index 1f9c06fc6e..9ec69ba3bd 100644 --- a/sources/Maths/Maths/Matrix2X3.cs +++ b/sources/Maths/Maths/Matrix2X3.cs @@ -16,8 +16,8 @@ public partial struct Matrix2X3 { private static readonly Matrix2X3 _identity = new ( - Scalar.One, Scalar.Zero, Scalar.Zero, - Scalar.Zero, Scalar.One, Scalar.Zero + T.One, T.Zero, T.Zero, + T.Zero, T.One, T.Zero ); /// Constructs a from the given . diff --git a/sources/Maths/Maths/Matrix3X2.Ops.cs b/sources/Maths/Maths/Matrix3X2.Ops.cs index 34096ae04d..14d318437d 100644 --- a/sources/Maths/Maths/Matrix3X2.Ops.cs +++ b/sources/Maths/Maths/Matrix3X2.Ops.cs @@ -24,23 +24,23 @@ public static partial class Matrix3X2 public static Matrix3X2 CreateRotation(T radians) where T : INumberBase { - radians = Scalar.IEEERemainder(radians, Scalar.Tau); + radians = T.Ieee754Remainder(radians, T.Tau); T c, s; - if (Scalar.GreaterThan(radians, Scalar.As(-RotationEpsilon)) && !Scalar.GreaterThanOrEqual(radians, Scalar.As(RotationEpsilon))) + if ((radians > T.CreateTruncating(-RotationEpsilon)) && !(radians >= T.CreateTruncating(RotationEpsilon))) { // Exact case for zero rotation. - c = Scalar.One; - s = Scalar.Zero; + c = T.One; + s = T.Zero; } - else if (Scalar.GreaterThan(radians, Scalar.As( + else if ((radians > T.CreateTruncating( #if MATHF MathF.PI #else ((float) Math.PI) #endif - / 2 - RotationEpsilon)) && !Scalar.GreaterThanOrEqual(radians, Scalar.As( + / 2 - RotationEpsilon)) && !(radians >= T.CreateTruncating( #if MATHF MathF.PI #else @@ -49,16 +49,16 @@ public static Matrix3X2 CreateRotation(T radians) / 2 + RotationEpsilon))) { // Exact case for 90 degree rotation. - c = Scalar.Zero; - s = Scalar.One; + c = T.Zero; + s = T.One; } - else if (!Scalar.GreaterThanOrEqual(radians, Scalar.As(- + else if (!(radians >= T.CreateTruncating(- #if MATHF MathF.PI #else ((float) Math.PI) #endif - + RotationEpsilon)) || Scalar.GreaterThan(radians, Scalar.As( + + RotationEpsilon)) || (radians > T.CreateTruncating( #if MATHF MathF.PI #else @@ -67,16 +67,16 @@ public static Matrix3X2 CreateRotation(T radians) - RotationEpsilon))) { // Exact case for 180 degree rotation. - c = Scalar.MinusOne; - s = Scalar.Zero; + c = -T.One; + s = T.Zero; } - else if (Scalar.GreaterThan(radians, Scalar.As(- + else if ((radians > T.CreateTruncating(- #if MATHF MathF.PI #else ((float) Math.PI) #endif - / 2 - RotationEpsilon)) && !Scalar.GreaterThanOrEqual(radians, Scalar.As(- + / 2 - RotationEpsilon)) && !(radians >= T.CreateTruncating(- #if MATHF MathF.PI #else @@ -85,14 +85,14 @@ public static Matrix3X2 CreateRotation(T radians) / 2 + RotationEpsilon))) { // Exact case for 270 degree rotation. - c = Scalar.Zero; - s = Scalar.MinusOne; + c = T.Zero; + s = -T.One; } else { // Arbitrary rotation. - c = Scalar.Cos(radians); - s = Scalar.Sin(radians); + c = T.Cos(radians); + s = T.Sin(radians); } // [ c s ] @@ -102,7 +102,7 @@ public static Matrix3X2 CreateRotation(T radians) result.M11 = c; result.M12 = s; - result.M21 = Scalar.Negate(s); + result.M21 = -s; result.M22 = c; return result; @@ -115,23 +115,23 @@ public static Matrix3X2 CreateRotation(T radians) public static Matrix3X2 CreateRotation(T radians, Vector2D centerPoint) where T : INumberBase { - radians = Scalar.IEEERemainder(radians, Scalar.Tau); + radians = T.Ieee754Remainder(radians, T.Tau); T c, s; - if (Scalar.GreaterThan(radians, Scalar.As(-RotationEpsilon)) && !Scalar.GreaterThanOrEqual(radians, Scalar.As(RotationEpsilon))) + if ((radians > T.CreateTruncating(-RotationEpsilon)) && !(radians >= T.CreateTruncating(RotationEpsilon))) { // Exact case for zero rotation. - c = Scalar.One; - s = Scalar.Zero; + c = T.One; + s = T.Zero; } - else if (Scalar.GreaterThan(radians, Scalar.As( + else if ((radians > T.CreateTruncating( #if MATHF MathF.PI #else ((float) Math.PI) #endif - / 2 - RotationEpsilon)) && !Scalar.GreaterThanOrEqual(radians, Scalar.As( + / 2 - RotationEpsilon)) && !(radians >= T.CreateTruncating( #if MATHF MathF.PI #else @@ -140,16 +140,16 @@ public static Matrix3X2 CreateRotation(T radians, Vector2D centerPoint) / 2 + RotationEpsilon))) { // Exact case for 90 degree rotation. - c = Scalar.Zero; - s = Scalar.One; + c = T.Zero; + s = T.One; } - else if (!Scalar.GreaterThanOrEqual(radians, Scalar.As(- + else if (!(radians >= T.CreateTruncating(- #if MATHF MathF.PI #else ((float) Math.PI) #endif - + RotationEpsilon)) || Scalar.GreaterThan(radians, Scalar.As( + + RotationEpsilon)) || (radians > T.CreateTruncating( #if MATHF MathF.PI #else @@ -158,16 +158,16 @@ public static Matrix3X2 CreateRotation(T radians, Vector2D centerPoint) - RotationEpsilon))) { // Exact case for 180 degree rotation. - c = Scalar.MinusOne; - s = Scalar.Zero; + c = -T.One; + s = T.Zero; } - else if (Scalar.GreaterThan(radians, Scalar.As(- + else if ((radians > T.CreateTruncating(- #if MATHF MathF.PI #else ((float) Math.PI) #endif - / 2 - RotationEpsilon)) && !Scalar.GreaterThanOrEqual(radians, Scalar.As(- + / 2 - RotationEpsilon)) && !(radians >= T.CreateTruncating(- #if MATHF MathF.PI #else @@ -176,25 +176,25 @@ public static Matrix3X2 CreateRotation(T radians, Vector2D centerPoint) / 2 + RotationEpsilon))) { // Exact case for 270 degree rotation. - c = Scalar.Zero; - s = Scalar.MinusOne; + c = T.Zero; + s = -T.One; } else { // Arbitrary rotation. - c = Scalar.Cos(radians); - s = Scalar.Sin(radians); + c = T.Cos(radians); + s = T.Sin(radians); } - T x = Scalar.Add(Scalar.Multiply(centerPoint.X, Scalar.Subtract(Scalar.One, c)), Scalar.Multiply(centerPoint.Y, s)); - T y = Scalar.Subtract(Scalar.Multiply(centerPoint.Y, Scalar.Subtract(Scalar.One, c)), Scalar.Multiply(centerPoint.X, s)); + T x = (centerPoint.X * (T.One - c)) + (centerPoint.Y * s); + T y = (centerPoint.Y * (T.One - c)) - (centerPoint.X * s); // [ c s ] // [ -s c ] // [ x y ] return new( new(c, s), - new(Scalar.Negate(s), c), + new(-s, c), new(x, y)); } @@ -237,8 +237,8 @@ public static Matrix3X2 CreateScale(T xScale, T yScale, Vector2D center { Matrix3X2 result = Matrix3X2.Identity; - T tx = Scalar.Multiply(centerPoint.X, Scalar.Subtract(Scalar.One, xScale)); - T ty = Scalar.Multiply(centerPoint.Y, Scalar.Subtract(Scalar.One, yScale)); + T tx = centerPoint.X * (T.One - xScale); + T ty = centerPoint.Y * (T.One - yScale); result.M11 = xScale; result.M22 = yScale; @@ -257,8 +257,8 @@ public static Matrix3X2 CreateScale(Vector2D scales, Vector2D center { Matrix3X2 result = Matrix3X2.Identity; - T tx = Scalar.Multiply(centerPoint.X, Scalar.Subtract(Scalar.One, scales.X)); - T ty = Scalar.Multiply(centerPoint.Y, Scalar.Subtract(Scalar.One, scales.Y)); + T tx = centerPoint.X * (T.One - scales.X); + T ty = centerPoint.Y * (T.One - scales.Y); result.M11 = scales.X; result.M22 = scales.Y; @@ -291,8 +291,8 @@ public static Matrix3X2 CreateScale(T scale, Vector2D centerPoint) { Matrix3X2 result = Matrix3X2.Identity; - T tx = Scalar.Multiply(centerPoint.X, Scalar.Subtract(Scalar.One, scale)); - T ty = Scalar.Multiply(centerPoint.Y, Scalar.Subtract(Scalar.One, scale)); + T tx = centerPoint.X * (T.One - scale); + T ty = centerPoint.Y * (T.One - scale); result.M11 = scale; result.M22 = scale; @@ -311,8 +311,8 @@ public static Matrix3X2 CreateSkew(T radiansX, T radiansY) { Matrix3X2 result = Matrix3X2.Identity; - T xTan = Scalar.Tan(radiansX); - T yTan = Scalar.Tan(radiansY); + T xTan = T.Tan(radiansX); + T yTan = T.Tan(radiansY); result.M12 = yTan; result.M21 = xTan; @@ -330,11 +330,11 @@ public static Matrix3X2 CreateSkew(T radiansX, T radiansY, Vector2D cen { Matrix3X2 result = Matrix3X2.Identity; - T xTan = Scalar.Tan(radiansX); - T yTan = Scalar.Tan(radiansY); + T xTan = T.Tan(radiansX); + T yTan = T.Tan(radiansY); - T tx = Scalar.Negate(Scalar.Multiply(centerPoint.Y, xTan)); - T ty = Scalar.Negate(Scalar.Multiply(centerPoint.X, yTan)); + T tx = -(centerPoint.Y * xTan); + T ty = -(centerPoint.X * yTan); result.M12 = yTan; result.M21 = xTan; @@ -381,26 +381,26 @@ public static Matrix3X2 CreateTranslation(T xPosition, T yPosition) public static bool Invert(Matrix3X2 matrix, out Matrix3X2 result) where T : IFloatingPointIeee754 { - T det = Scalar.Subtract(Scalar.Multiply(matrix.M11, matrix.M22), Scalar.Multiply(matrix.M21, matrix.M12)); + T det = (matrix.M11 * matrix.M22) - (matrix.M21 * matrix.M12); if (!(T.Abs(det) >= T.Epsilon)) { - result = new(Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN); + result = new(T.NaN, T.NaN, T.NaN, T.NaN, T.NaN, T.NaN); return false; } - T invDet = Scalar.Reciprocal(det); + T invDet = T.One / det; result = default; - result.M11 = Scalar.Multiply(matrix.M22, invDet); - result.M12 = Scalar.Negate(Scalar.Multiply(matrix.M12, invDet)); + result.M11 = matrix.M22 * invDet; + result.M12 = -(matrix.M12 * invDet); - result.M21 = Scalar.Negate(Scalar.Multiply(matrix.M21, invDet)); - result.M22 = Scalar.Multiply(matrix.M11, invDet); + result.M21 = -(matrix.M21 * invDet); + result.M22 = matrix.M11 * invDet; - result.M31 = Scalar.Multiply(Scalar.Subtract(Scalar.Multiply(matrix.M21, matrix.M32), Scalar.Multiply(matrix.M31, matrix.M22)), invDet); - result.M32 = Scalar.Multiply(Scalar.Subtract(Scalar.Multiply(matrix.M31, matrix.M12), Scalar.Multiply(matrix.M11, matrix.M32)), invDet); + result.M31 = ((matrix.M21 * matrix.M32) - (matrix.M31 * matrix.M22)) * invDet; + result.M32 = ((matrix.M31 * matrix.M12) - (matrix.M11 * matrix.M32)) * invDet; return true; } diff --git a/sources/Maths/Maths/Matrix3X2.cs b/sources/Maths/Maths/Matrix3X2.cs index 6f618c2e69..8fa03166d2 100644 --- a/sources/Maths/Maths/Matrix3X2.cs +++ b/sources/Maths/Maths/Matrix3X2.cs @@ -15,9 +15,9 @@ namespace Silk.NET.Maths public partial struct Matrix3X2 { private static readonly Matrix3X2 _identity = new( - Scalar.One, Scalar.Zero, - Scalar.Zero, Scalar.One, - Scalar.Zero, Scalar.Zero + T.One, T.Zero, + T.Zero, T.One, + T.Zero, T.Zero ); /// Constructs a from the given Matrix4x3. @@ -93,9 +93,7 @@ public readonly T GetDeterminant() // // Collapse out the constants and oh look, this is just a 2x2 determinant! - return Scalar.Subtract( - Scalar.Multiply(Row1.X, Row2.Y), - Scalar.Multiply(Row2.X, Row1.Y)); + return (Row1.X * Row2.Y) - (Row2.X * Row1.Y); } /// @@ -105,9 +103,9 @@ public readonly T GetDeterminant() /// The matrix public static explicit operator System.Numerics.Matrix3x2(Matrix3X2 from) => new( - Scalar.As(from.M11), Scalar.As(from.M12), - Scalar.As(from.M21), Scalar.As(from.M22), - Scalar.As(from.M31), Scalar.As(from.M32) + float.CreateTruncating(from.M11), float.CreateTruncating(from.M12), + float.CreateTruncating(from.M21), float.CreateTruncating(from.M22), + float.CreateTruncating(from.M31), float.CreateTruncating(from.M32) ); } } diff --git a/sources/Maths/Maths/Matrix3X3.Ops.cs b/sources/Maths/Maths/Matrix3X3.Ops.cs index 2cdcb433e6..740d43d1ba 100644 --- a/sources/Maths/Maths/Matrix3X3.Ops.cs +++ b/sources/Maths/Maths/Matrix3X3.Ops.cs @@ -47,13 +47,13 @@ public static Matrix3X3 CreateBillboard(Vector3D objectPosition, Vector Vector3D zaxis = objectPosition - cameraPosition; var norm = zaxis.LengthSquared; - if (!Scalar.GreaterThanOrEqual(norm, Scalar.As(BillboardEpsilon))) + if (!(norm >= T.CreateTruncating(BillboardEpsilon))) { zaxis = -cameraForwardVector; } else { - zaxis = Vector3D.Multiply(zaxis, Scalar.Reciprocal(Scalar.Sqrt(norm))); + zaxis = Vector3D.Multiply(zaxis, T.One / T.Sqrt(norm)); } Vector3D xaxis = Vector3D.Normalize(Vector3D.Cross(cameraUpVector, zaxis)); @@ -95,23 +95,23 @@ public static Matrix3X3 CreateFromAxisAngle(Vector3D axis, T angle) // [ zx-cosa*zx-sina*y zy-cosa*zy+sina*x zz+cosa*(1-zz) ] // T x = axis.X, y = axis.Y, z = axis.Z; - T sa = Scalar.Sin(angle), ca = Scalar.Cos(angle); - T xx = Scalar.Multiply(x, x), yy = Scalar.Multiply(y, y), zz = Scalar.Multiply(z, z); - T xy = Scalar.Multiply(x, y), xz = Scalar.Multiply(x, z), yz = Scalar.Multiply(y, z); + T sa = T.Sin(angle), ca = T.Cos(angle); + T xx = x * x, yy = y * y, zz = z * z; + T xy = x * y, xz = x * z, yz = y * z; Matrix3X3 result = Matrix3X3.Identity; - result.M11 = Scalar.Add(xx, Scalar.Multiply(ca, Scalar.Subtract(Scalar.One, xx))); - result.M12 = Scalar.Add(Scalar.Subtract(xy, Scalar.Multiply(ca, xy)), Scalar.Multiply(sa, z)); - result.M13 = Scalar.Subtract(Scalar.Subtract(xz, Scalar.Multiply(ca, xz)), Scalar.Multiply(sa, y)); + result.M11 = xx + (ca * (T.One - xx)); + result.M12 = xy - (ca * xy) + (sa * z); + result.M13 = xz - (ca * xz) - (sa * y); - result.M21 = Scalar.Subtract(Scalar.Subtract(xy, Scalar.Multiply(ca, xy)), Scalar.Multiply(sa, z)); - result.M22 = Scalar.Add(yy, Scalar.Multiply(ca, Scalar.Subtract(Scalar.One, yy))); - result.M23 = Scalar.Add(Scalar.Subtract(yz, Scalar.Multiply(ca, yz)), Scalar.Multiply(sa, x)); + result.M21 = xy - (ca * xy) - (sa * z); + result.M22 = yy + (ca * (T.One - yy)); + result.M23 = yz - (ca * yz) + (sa * x); - result.M31 = Scalar.Add(Scalar.Subtract(xz, Scalar.Multiply(ca, xz)), Scalar.Multiply(sa, y)); - result.M32 = Scalar.Subtract(Scalar.Subtract(yz, Scalar.Multiply(ca, yz)), Scalar.Multiply(sa, x)); - result.M33 = Scalar.Add(zz, Scalar.Multiply(ca, Scalar.Subtract(Scalar.One, zz))); + result.M31 = xz - (ca * xz) + (sa * y); + result.M32 = yz - (ca * yz) - (sa * x); + result.M33 = zz + (ca * (T.One - zz)); return result; } @@ -124,28 +124,28 @@ public static Matrix3X3 CreateFromQuaternion(Quaternion quaternion) { Matrix3X3 result = Matrix3X3.Identity; - T xx = Scalar.Multiply(quaternion.X, quaternion.X); - T yy = Scalar.Multiply(quaternion.Y, quaternion.Y); - T zz = Scalar.Multiply(quaternion.Z, quaternion.Z); + T xx = quaternion.X * quaternion.X; + T yy = quaternion.Y * quaternion.Y; + T zz = quaternion.Z * quaternion.Z; - T xy = Scalar.Multiply(quaternion.X, quaternion.Y); - T wz = Scalar.Multiply(quaternion.Z, quaternion.W); - T xz = Scalar.Multiply(quaternion.Z, quaternion.X); - T wy = Scalar.Multiply(quaternion.Y, quaternion.W); - T yz = Scalar.Multiply(quaternion.Y, quaternion.Z); - T wx = Scalar.Multiply(quaternion.X, quaternion.W); + T xy = quaternion.X * quaternion.Y; + T wz = quaternion.Z * quaternion.W; + T xz = quaternion.Z * quaternion.X; + T wy = quaternion.Y * quaternion.W; + T yz = quaternion.Y * quaternion.Z; + T wx = quaternion.X * quaternion.W; - result.M11 = Scalar.Subtract(Scalar.One, Scalar.Multiply(Scalar.Two, Scalar.Add(yy, zz))); - result.M12 = Scalar.Multiply(Scalar.Two, Scalar.Add(xy, wz)); - result.M13 = Scalar.Multiply(Scalar.Two, Scalar.Subtract(xz, wy)); + result.M11 = T.One - (T.CreateTruncating(2) * (yy + zz)); + result.M12 = T.CreateTruncating(2) * (xy + wz); + result.M13 = T.CreateTruncating(2) * (xz - wy); - result.M21 = Scalar.Multiply(Scalar.Two, Scalar.Subtract(xy, wz)); - result.M22 = Scalar.Subtract(Scalar.One, Scalar.Multiply(Scalar.Two, Scalar.Add(zz, xx))); - result.M23 = Scalar.Multiply(Scalar.Two, Scalar.Add(yz, wx)); + result.M21 = T.CreateTruncating(2) * (xy - wz); + result.M22 = T.One - (T.CreateTruncating(2) * (zz + xx)); + result.M23 = T.CreateTruncating(2) * (yz + wx); - result.M31 = Scalar.Multiply(Scalar.Two, Scalar.Add(xz, wy)); - result.M32 = Scalar.Multiply(Scalar.Two, Scalar.Subtract(yz, wx)); - result.M33 = Scalar.Subtract(Scalar.One, Scalar.Multiply(Scalar.Two, Scalar.Add(yy, xx))); + result.M31 = T.CreateTruncating(2) * (xz + wy); + result.M32 = T.CreateTruncating(2) * (yz - wx); + result.M33 = T.One - (T.CreateTruncating(2) * (yy + xx)); return result; } @@ -171,8 +171,8 @@ public static Matrix3X3 CreateRotationX(T radians) { Matrix3X3 result = Matrix3X3.Identity; - T c = Scalar.Cos(radians); - T s = Scalar.Sin(radians); + T c = T.Cos(radians); + T s = T.Sin(radians); // [ 1 0 0 0 ] // [ 0 c s 0 ] @@ -181,7 +181,7 @@ public static Matrix3X3 CreateRotationX(T radians) result.M22 = c; result.M23 = s; - result.M32 = Scalar.Negate(s); + result.M32 = -s; result.M33 = c; return result; @@ -195,15 +195,15 @@ public static Matrix3X3 CreateRotationY(T radians) { Matrix3X3 result = Matrix3X3.Identity; - T c = Scalar.Cos(radians); - T s = Scalar.Sin(radians); + T c = T.Cos(radians); + T s = T.Sin(radians); // [ c 0 -s 0 ] // [ 0 1 0 0 ] // [ s 0 c 0 ] // [ 0 0 0 1 ] result.M11 = c; - result.M13 = Scalar.Negate(s); + result.M13 = -s; result.M31 = s; result.M33 = c; @@ -218,8 +218,8 @@ public static Matrix3X3 CreateRotationZ(T radians) { Matrix3X3 result = Matrix3X3.Identity; - T c = Scalar.Cos(radians); - T s = Scalar.Sin(radians); + T c = T.Cos(radians); + T s = T.Sin(radians); // [ c s 0 0 ] // [ -s c 0 0 ] @@ -227,7 +227,7 @@ public static Matrix3X3 CreateRotationZ(T radians) // [ 0 0 0 1 ] result.M11 = c; result.M12 = s; - result.M21 = Scalar.Negate(s); + result.M21 = -s; result.M22 = c; return result; @@ -302,17 +302,17 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out CanonicalBasis canonicalBasis = default; Vector3D* pCanonicalBasis = &canonicalBasis.Row0; - canonicalBasis.Row0 = new Vector3D(Scalar.One, Scalar.Zero, Scalar.Zero); - canonicalBasis.Row1 = new Vector3D(Scalar.Zero, Scalar.One, Scalar.Zero); - canonicalBasis.Row2 = new Vector3D(Scalar.Zero, Scalar.Zero, Scalar.One); + canonicalBasis.Row0 = new Vector3D(T.One, T.Zero, T.Zero); + canonicalBasis.Row1 = new Vector3D(T.Zero, T.One, T.Zero); + canonicalBasis.Row2 = new Vector3D(T.Zero, T.Zero, T.One); pVectorBasis[0] = &matTemp.Row1; pVectorBasis[1] = &matTemp.Row2; pVectorBasis[2] = &matTemp.Row3; - *(pVectorBasis[0]) = new Vector3D(matrix.M11, matrix.M12, matrix.M13); - *(pVectorBasis[1]) = new Vector3D(matrix.M21, matrix.M22, matrix.M23); - *(pVectorBasis[2]) = new Vector3D(matrix.M31, matrix.M32, matrix.M33); + *pVectorBasis[0] = new Vector3D(matrix.M11, matrix.M12, matrix.M13); + *pVectorBasis[1] = new Vector3D(matrix.M21, matrix.M22, matrix.M23); + *pVectorBasis[2] = new Vector3D(matrix.M31, matrix.M32, matrix.M33); scale.X = pVectorBasis[0]->Length; scale.Y = pVectorBasis[1]->Length; @@ -321,9 +321,9 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out uint a, b, c; #region Ranking T x = pfScales[0], y = pfScales[1], z = pfScales[2]; - if (!Scalar.GreaterThanOrEqual(x, y)) + if (!(x >= y)) { - if (!Scalar.GreaterThanOrEqual(y, z)) + if (!(y >= z)) { a = 2; b = 1; @@ -333,7 +333,7 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out { a = 1; - if (!Scalar.GreaterThanOrEqual(x, z)) + if (!(x >= z)) { b = 2; c = 0; @@ -347,7 +347,7 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out } else { - if (!Scalar.GreaterThanOrEqual(x, z)) + if (!(x >= z)) { a = 2; b = 0; @@ -357,7 +357,7 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out { a = 0; - if (!Scalar.GreaterThanOrEqual(y, z)) + if (!(y >= z)) { b = 2; c = 1; @@ -371,32 +371,32 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out } #endregion - if (!Scalar.GreaterThanOrEqual(pfScales[a], Scalar.As(DecomposeEpsilon))) + if (!(pfScales[a] >= T.CreateTruncating(DecomposeEpsilon))) { *(pVectorBasis[a]) = pCanonicalBasis[a]; } *pVectorBasis[a] = Vector3D.Normalize(*pVectorBasis[a]); - if (!Scalar.GreaterThanOrEqual(pfScales[b], Scalar.As(DecomposeEpsilon))) + if (!(pfScales[b] >= T.CreateTruncating(DecomposeEpsilon))) { uint cc; T fAbsX, fAbsY, fAbsZ; - fAbsX = Scalar.Abs(pVectorBasis[a]->X); - fAbsY = Scalar.Abs(pVectorBasis[a]->Y); - fAbsZ = Scalar.Abs(pVectorBasis[a]->Z); + fAbsX = T.Abs(pVectorBasis[a]->X); + fAbsY = T.Abs(pVectorBasis[a]->Y); + fAbsZ = T.Abs(pVectorBasis[a]->Z); #region Ranking - if (!Scalar.GreaterThanOrEqual(fAbsX, fAbsY)) + if (!(fAbsX >= fAbsY)) { - if (!Scalar.GreaterThanOrEqual(fAbsY, fAbsZ)) + if (!(fAbsY >= fAbsZ)) { cc = 0; } else { - if (!Scalar.GreaterThanOrEqual(fAbsX, fAbsZ)) + if (!(fAbsX >= fAbsZ)) { cc = 0; } @@ -408,13 +408,13 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out } else { - if (!Scalar.GreaterThanOrEqual(fAbsX, fAbsZ)) + if (!(fAbsX >= fAbsZ)) { cc = 1; } else { - if (!Scalar.GreaterThanOrEqual(fAbsY, fAbsZ)) + if (!(fAbsY >= fAbsZ)) { cc = 1; } @@ -431,7 +431,7 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out *pVectorBasis[b] = Vector3D.Normalize(*pVectorBasis[b]); - if (!Scalar.GreaterThanOrEqual(pfScales[c], Scalar.As(DecomposeEpsilon))) + if (!(pfScales[c] >= T.CreateTruncating(DecomposeEpsilon))) { *pVectorBasis[c] = Vector3D.Cross(*pVectorBasis[a], *pVectorBasis[b]); } @@ -441,19 +441,19 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out det = matTemp.GetDeterminant(); // use Kramer's rule to check for handedness of coordinate system - if (!Scalar.GreaterThanOrEqual(det, Scalar.Zero)) + if (!(det >= T.Zero)) { // switch coordinate system by negating the scale and inverting the basis vector on the x-axis - pfScales[a] = Scalar.Negate(pfScales[a]); + pfScales[a] = -pfScales[a]; *pVectorBasis[a] = -(*pVectorBasis[a]); - det = Scalar.Negate(det); + det = -det; } - det = Scalar.Subtract(det, Scalar.One); - det = Scalar.Multiply(det, det); + det = det - T.One; + det = det * det; - if (!Scalar.GreaterThanOrEqual(Scalar.As(DecomposeEpsilon), det)) + if (!(T.CreateTruncating(DecomposeEpsilon) >= det)) { // Non-SRT matrix encountered rotation = Legacy.Quaternion.Identity; @@ -479,37 +479,37 @@ public static Matrix3X3 Transform(Matrix3X3 value, Quaternion rotati where T : ITrigonometricFunctions { // Compute rotation matrix. - T x2 = Scalar.Add(rotation.X, rotation.X); - T y2 = Scalar.Add(rotation.Y, rotation.Y); - T z2 = Scalar.Add(rotation.Z, rotation.Z); - - T wx2 = Scalar.Multiply(rotation.W, x2); - T wy2 = Scalar.Multiply(rotation.W, y2); - T wz2 = Scalar.Multiply(rotation.W, z2); - T xx2 = Scalar.Multiply(rotation.X, x2); - T xy2 = Scalar.Multiply(rotation.X, y2); - T xz2 = Scalar.Multiply(rotation.X, z2); - T yy2 = Scalar.Multiply(rotation.Y, y2); - T yz2 = Scalar.Multiply(rotation.Y, z2); - T zz2 = Scalar.Multiply(rotation.Z, z2); - - T q11 = Scalar.Subtract(Scalar.Subtract(Scalar.One, yy2), zz2); - T q21 = Scalar.Subtract(xy2, wz2); - T q31 = Scalar.Add(xz2, wy2); - - T q12 = Scalar.Add(xy2, wz2); - T q22 = Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), zz2); - T q32 = Scalar.Subtract(yz2, wx2); - - T q13 = Scalar.Subtract(xz2, wy2); - T q23 = Scalar.Add(yz2, wx2); - T q33 = Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), yy2); + T x2 = rotation.X + rotation.X; + T y2 = rotation.Y + rotation.Y; + T z2 = rotation.Z + rotation.Z; + + T wx2 = rotation.W * x2; + T wy2 = rotation.W * y2; + T wz2 = rotation.W * z2; + T xx2 = rotation.X * x2; + T xy2 = rotation.X * y2; + T xz2 = rotation.X * z2; + T yy2 = rotation.Y * y2; + T yz2 = rotation.Y * z2; + T zz2 = rotation.Z * z2; + + T q11 = T.One - yy2 - zz2; + T q21 = xy2 - wz2; + T q31 = xz2 + wy2; + + T q12 = xy2 + wz2; + T q22 = T.One - xx2 - zz2; + T q32 = yz2 - wx2; + + T q13 = xz2 - wy2; + T q23 = yz2 + wx2; + T q33 = T.One - xx2 - yy2; var q1 = new Vector3D(q11, q12, q13); var q2 = new Vector3D(q21, q22, q23); var q3 = new Vector3D(q31, q32, q33); - return new(value.M11 * q1 + value.M12 * q2 + value.M13 * q3, value.M21 * q1 + value.M22 * q2 + value.M23 * q3, value.M31 * q1 + value.M32 * q2 + value.M33 * q3); + return new((value.M11 * q1) + (value.M12 * q2) + (value.M13 * q3), (value.M21 * q1) + (value.M22 * q2) + (value.M23 * q3), (value.M31 * q1) + (value.M32 * q2) + (value.M33 * q3)); } /// Transposes the rows and columns of a matrix. diff --git a/sources/Maths/Maths/Matrix3X3.cs b/sources/Maths/Maths/Matrix3X3.cs index 492bc49f43..982de76974 100644 --- a/sources/Maths/Maths/Matrix3X3.cs +++ b/sources/Maths/Maths/Matrix3X3.cs @@ -89,11 +89,7 @@ public readonly T GetDeterminant() T d = Row2.X, e = Row2.Y, f = Row2.Z; T g = Row3.X, h = Row3.Y, i = Row3.Z; - return Scalar.Add( - Scalar.Subtract( - Scalar.Multiply(a, Scalar.Subtract(Scalar.Multiply(e, i), Scalar.Multiply(f, h))), - Scalar.Multiply(b, Scalar.Subtract(Scalar.Multiply(d, i), Scalar.Multiply(f, g)))), - Scalar.Multiply(c, Scalar.Subtract(Scalar.Multiply(d, h), Scalar.Multiply(e, g)))); + return (a * ((e * i) - (f * h))) - (b * ((d * i) - (f * g))) + (c * ((d * h) - (e * g))); } } } diff --git a/sources/Maths/Maths/Matrix4X2.cs b/sources/Maths/Maths/Matrix4X2.cs index 4fab060824..d738f1ea91 100644 --- a/sources/Maths/Maths/Matrix4X2.cs +++ b/sources/Maths/Maths/Matrix4X2.cs @@ -17,10 +17,10 @@ public partial struct Matrix4X2 { private static readonly Matrix4X2 _identity = new ( - Scalar.One, Scalar.Zero, - Scalar.Zero, Scalar.One, - Scalar.Zero, Scalar.Zero, - Scalar.Zero, Scalar.Zero + T.One, T.Zero, + T.Zero, T.One, + T.Zero, T.Zero, + T.Zero, T.Zero ); /// Constructs a from the given . diff --git a/sources/Maths/Maths/Matrix4X3.cs b/sources/Maths/Maths/Matrix4X3.cs index bbda207d29..b0c363a541 100644 --- a/sources/Maths/Maths/Matrix4X3.cs +++ b/sources/Maths/Maths/Matrix4X3.cs @@ -18,10 +18,10 @@ public partial struct Matrix4X3 { private static readonly Matrix4X3 _identity = new ( - Scalar.One, Scalar.Zero, Scalar.Zero, - Scalar.Zero, Scalar.One, Scalar.Zero, - Scalar.Zero, Scalar.Zero, Scalar.One, - Scalar.Zero, Scalar.Zero, Scalar.Zero + T.One, T.Zero, T.Zero, + T.Zero, T.One, T.Zero, + T.Zero, T.Zero, T.One, + T.Zero, T.Zero, T.Zero ); /// Constructs a from the given . @@ -81,7 +81,7 @@ public Matrix4X3(Matrix4X2 value) Row1 = new(value.M11, value.M12, T.Zero); Row2 = new(value.M21, value.M22, T.Zero); Row3 = new(value.M31, value.M32, T.Zero); - Row4 = new(value.M41, value.M42, Scalar.One); + Row4 = new(value.M41, value.M42, T.One); } /// Constructs a from the given . diff --git a/sources/Maths/Maths/Matrix4X4.Ops.cs b/sources/Maths/Maths/Matrix4X4.Ops.cs index fffd21652b..7c68e38403 100644 --- a/sources/Maths/Maths/Matrix4X4.Ops.cs +++ b/sources/Maths/Maths/Matrix4X4.Ops.cs @@ -52,13 +52,13 @@ public static Matrix4X4 CreateBillboard(Vector3D objectPosition, Vector Vector3D zaxis = objectPosition - cameraPosition; var norm = zaxis.LengthSquared; - if (!Scalar.GreaterThanOrEqual(norm, Scalar.As(BillboardEpsilon))) + if (!(norm >= T.CreateTruncating(BillboardEpsilon))) { zaxis = -cameraForwardVector; } else { - zaxis = Vector3D.Multiply(zaxis, Scalar.Reciprocal(Scalar.Sqrt(norm))); + zaxis = Vector3D.Multiply(zaxis, T.One / T.Sqrt(norm)); } Vector3D xaxis = Vector3D.Normalize(Vector3D.Cross(cameraUpVector, zaxis)); @@ -68,7 +68,7 @@ public static Matrix4X4 CreateBillboard(Vector3D objectPosition, Vector new(xaxis, T.Zero), new(yaxis, T.Zero), new(zaxis, T.Zero), - new(objectPosition, Scalar.One)); + new(objectPosition, T.One)); } /// Creates a cylindrical billboard that rotates around a specified axis. @@ -85,13 +85,13 @@ public static Matrix4X4 CreateConstrainedBillboard(Vector3D objectPosit Vector3D faceDir = objectPosition - cameraPosition; T norm = faceDir.LengthSquared; - if (!Scalar.GreaterThanOrEqual(norm, Scalar.As(BillboardEpsilon))) + if (!(norm >= T.CreateTruncating(BillboardEpsilon))) { faceDir = -cameraForwardVector; } else { - faceDir = Vector3D.Multiply(faceDir, Scalar.Reciprocal(Scalar.Sqrt(norm))); + faceDir = Vector3D.Multiply(faceDir, T.One / T.Sqrt(norm)); } Vector3D yaxis = rotateAxis; @@ -101,19 +101,19 @@ public static Matrix4X4 CreateConstrainedBillboard(Vector3D objectPosit // Treat the case when angle between faceDir and rotateAxis is too close to 0. T dot = Vector3D.Dot(rotateAxis, faceDir); - if (Scalar.GreaterThan(T.Abs(dot), Scalar.As(BillboardMinAngle))) + if (T.Abs(dot) > T.CreateTruncating(BillboardMinAngle)) { zaxis = objectForwardVector; // Make sure passed values are useful for compute. dot = Vector3D.Dot(rotateAxis, zaxis); - if (Scalar.GreaterThan(T.Abs(dot), Scalar.As(BillboardMinAngle))) + if (T.Abs(dot) > T.CreateTruncating(BillboardMinAngle)) { zaxis = - Scalar.GreaterThan(T.Abs(rotateAxis.Z), Scalar.As(BillboardMinAngle)) - ? new Vector3D(Scalar.One, Scalar.Zero, Scalar.Zero) - : new Vector3D(Scalar.Zero, Scalar.Zero, Scalar.MinusOne); + T.Abs(rotateAxis.Z) > T.CreateTruncating(BillboardMinAngle) + ? new Vector3D(T.One, T.Zero, T.Zero) + : new Vector3D(T.Zero, T.Zero, -T.One); } xaxis = Vector3D.Normalize(Vector3D.Cross(rotateAxis, zaxis)); @@ -129,7 +129,7 @@ public static Matrix4X4 CreateConstrainedBillboard(Vector3D objectPosit new(xaxis, T.Zero), new(yaxis, T.Zero), new(zaxis, T.Zero), - new(objectPosition, Scalar.One)); + new(objectPosition, T.One)); } /// Creates a matrix that rotates around an arbitrary vector. @@ -165,23 +165,23 @@ public static Matrix4X4 CreateFromAxisAngle(Vector3D axis, T angle) // [ zx-cosa*zx-sina*y zy-cosa*zy+sina*x zz+cosa*(1-zz) ] // T x = axis.X, y = axis.Y, z = axis.Z; - T sa = Scalar.Sin(angle), ca = Scalar.Cos(angle); - T xx = Scalar.Multiply(x, x), yy = Scalar.Multiply(y, y), zz = Scalar.Multiply(z, z); - T xy = Scalar.Multiply(x, y), xz = Scalar.Multiply(x, z), yz = Scalar.Multiply(y, z); + T sa = T.Sin(angle), ca = T.Cos(angle); + T xx = x * x, yy = y * y, zz = z * z; + T xy = x * y, xz = x * z, yz = y * z; Matrix4X4 result = Matrix4X4.Identity; - result.M11 = Scalar.Add(xx, Scalar.Multiply(ca, Scalar.Subtract(Scalar.One, xx))); - result.M12 = Scalar.Add(Scalar.Subtract(xy, Scalar.Multiply(ca, xy)), Scalar.Multiply(sa, z)); - result.M13 = Scalar.Subtract(Scalar.Subtract(xz, Scalar.Multiply(ca, xz)), Scalar.Multiply(sa, y)); + result.M11 = xx + (ca * (T.One - xx)); + result.M12 = xy - (ca * xy) + (sa * z); + result.M13 = xz - (ca * xz) - (sa * y); - result.M21 = Scalar.Subtract(Scalar.Subtract(xy, Scalar.Multiply(ca, xy)), Scalar.Multiply(sa, z)); - result.M22 = Scalar.Add(yy, Scalar.Multiply(ca, Scalar.Subtract(Scalar.One, yy))); - result.M23 = Scalar.Add(Scalar.Subtract(yz, Scalar.Multiply(ca, yz)), Scalar.Multiply(sa, x)); + result.M21 = xy - (ca * xy) - (sa * z); + result.M22 = yy + (ca * (T.One - yy)); + result.M23 = yz - (ca * yz) + (sa * x); - result.M31 = Scalar.Add(Scalar.Subtract(xz, Scalar.Multiply(ca, xz)), Scalar.Multiply(sa, y)); - result.M32 = Scalar.Subtract(Scalar.Subtract(yz, Scalar.Multiply(ca, yz)), Scalar.Multiply(sa, x)); - result.M33 = Scalar.Add(zz, Scalar.Multiply(ca, Scalar.Subtract(Scalar.One, zz))); + result.M31 = xz - (ca * xz) + (sa * y); + result.M32 = yz - (ca * yz) - (sa * x); + result.M33 = zz + (ca * (T.One - zz)); return result; } @@ -194,28 +194,28 @@ public static Matrix4X4 CreateFromQuaternion(Quaternion quaternion) { Matrix4X4 result = Matrix4X4.Identity; - T xx = Scalar.Multiply(quaternion.X, quaternion.X); - T yy = Scalar.Multiply(quaternion.Y, quaternion.Y); - T zz = Scalar.Multiply(quaternion.Z, quaternion.Z); + T xx = quaternion.X * quaternion.X; + T yy = quaternion.Y * quaternion.Y; + T zz = quaternion.Z * quaternion.Z; - T xy = Scalar.Multiply(quaternion.X, quaternion.Y); - T wz = Scalar.Multiply(quaternion.Z, quaternion.W); - T xz = Scalar.Multiply(quaternion.Z, quaternion.X); - T wy = Scalar.Multiply(quaternion.Y, quaternion.W); - T yz = Scalar.Multiply(quaternion.Y, quaternion.Z); - T wx = Scalar.Multiply(quaternion.X, quaternion.W); + T xy = quaternion.X * quaternion.Y; + T wz = quaternion.Z * quaternion.W; + T xz = quaternion.Z * quaternion.X; + T wy = quaternion.Y * quaternion.W; + T yz = quaternion.Y * quaternion.Z; + T wx = quaternion.X * quaternion.W; - result.M11 = Scalar.Subtract(Scalar.One, Scalar.Multiply(Scalar.Two, Scalar.Add(yy, zz))); - result.M12 = Scalar.Multiply(Scalar.Two, Scalar.Add(xy, wz)); - result.M13 = Scalar.Multiply(Scalar.Two, Scalar.Subtract(xz, wy)); + result.M11 = T.One - (T.CreateTruncating(2) * (yy + zz)); + result.M12 = T.CreateTruncating(2) * (xy + wz); + result.M13 = T.CreateTruncating(2) * (xz - wy); - result.M21 = Scalar.Multiply(Scalar.Two, Scalar.Subtract(xy, wz)); - result.M22 = Scalar.Subtract(Scalar.One, Scalar.Multiply(Scalar.Two, Scalar.Add(zz, xx))); - result.M23 = Scalar.Multiply(Scalar.Two, Scalar.Add(yz, wx)); + result.M21 = T.CreateTruncating(2) * (xy - wz); + result.M22 = T.One - (T.CreateTruncating(2) * (zz + xx)); + result.M23 = T.CreateTruncating(2) * (yz + wx); - result.M31 = Scalar.Multiply(Scalar.Two, Scalar.Add(xz, wy)); - result.M32 = Scalar.Multiply(Scalar.Two, Scalar.Subtract(yz, wx)); - result.M33 = Scalar.Subtract(Scalar.One, Scalar.Multiply(Scalar.Two, Scalar.Add(yy, xx))); + result.M31 = T.CreateTruncating(2) * (xz + wy); + result.M32 = T.CreateTruncating(2) * (yz - wx); + result.M33 = T.One - (T.CreateTruncating(2) * (yy + xx)); return result; } @@ -259,9 +259,9 @@ public static Matrix4X4 CreateLookAt(Vector3D cameraPosition, Vector3D< result.M32 = yaxis.Z; result.M33 = zaxis.Z; - result.M41 = Scalar.Negate(Vector3D.Dot(xaxis, cameraPosition)); - result.M42 = Scalar.Negate(Vector3D.Dot(yaxis, cameraPosition)); - result.M43 = Scalar.Negate(Vector3D.Dot(zaxis, cameraPosition)); + result.M41 = -Vector3D.Dot(xaxis, cameraPosition); + result.M42 = -Vector3D.Dot(yaxis, cameraPosition); + result.M43 = -Vector3D.Dot(zaxis, cameraPosition); return result; } @@ -277,10 +277,10 @@ public static Matrix4X4 CreateOrthographic(T width, T height, T zNearPlane { Matrix4X4 result = Matrix4X4.Identity; - result.M11 = Scalar.Divide(Scalar.Two, width); - result.M22 = Scalar.Divide(Scalar.Two, height); - result.M33 = Scalar.Reciprocal(Scalar.Subtract(zNearPlane, zFarPlane)); - result.M43 = Scalar.Divide(zNearPlane, Scalar.Subtract(zNearPlane, zFarPlane)); + result.M11 = T.CreateTruncating(2) / width; + result.M22 = T.CreateTruncating(2) / height; + result.M33 = T.One / (zNearPlane - zFarPlane); + result.M43 = zNearPlane / (zNearPlane - zFarPlane); return result; } @@ -298,15 +298,15 @@ public static Matrix4X4 CreateOrthographicOffCenter(T left, T right, T bot { Matrix4X4 result = Matrix4X4.Identity; - result.M11 = Scalar.Divide(Scalar.Two, Scalar.Subtract(right, left)); + result.M11 = T.CreateTruncating(2) / (right - left); - result.M22 = Scalar.Divide(Scalar.Two, Scalar.Subtract(top, bottom)); + result.M22 = T.CreateTruncating(2) / (top - bottom); - result.M33 = Scalar.Reciprocal(Scalar.Subtract(zNearPlane, zFarPlane)); + result.M33 = T.One / (zNearPlane - zFarPlane); - result.M41 = Scalar.Divide(Scalar.Add(left, right), Scalar.Subtract(left, right)); - result.M42 = Scalar.Divide(Scalar.Add(top, bottom), Scalar.Subtract(bottom, top)); - result.M43 = Scalar.Divide(zNearPlane, Scalar.Subtract(zNearPlane, zFarPlane)); + result.M41 = (left + right) / (left - right); + result.M42 = (top + bottom) / (bottom - top); + result.M43 = zNearPlane / (zNearPlane - zFarPlane); return result; } @@ -320,29 +320,29 @@ public static Matrix4X4 CreateOrthographicOffCenter(T left, T right, T bot public static Matrix4X4 CreatePerspective(T width, T height, T nearPlaneDistance, T farPlaneDistance) where T : INumberBase { - if (!Scalar.GreaterThan(nearPlaneDistance, Scalar.Zero)) + if (!(nearPlaneDistance > T.Zero)) throw new ArgumentOutOfRangeException(nameof(nearPlaneDistance)); - if (!Scalar.GreaterThan(farPlaneDistance, Scalar.Zero)) + if (!(farPlaneDistance > T.Zero)) throw new ArgumentOutOfRangeException(nameof(farPlaneDistance)); Matrix4X4 result = default; - result.M11 = Scalar.Divide(Scalar.Multiply(Scalar.Two, nearPlaneDistance), width); - result.M12 = result.M13 = result.M14 = Scalar.Zero; + result.M11 = T.CreateTruncating(2) * nearPlaneDistance / width; + result.M12 = result.M13 = result.M14 = T.Zero; - result.M22 = Scalar.Divide(Scalar.Multiply(Scalar.Two, nearPlaneDistance), height); - result.M21 = result.M23 = result.M24 = Scalar.Zero; + result.M22 = T.CreateTruncating(2) * nearPlaneDistance / height; + result.M21 = result.M23 = result.M24 = T.Zero; - T negFarRange = Scalar.IsPositiveInfinity(farPlaneDistance) - ? Scalar.MinusOne - : Scalar.Divide(farPlaneDistance, Scalar.Subtract(nearPlaneDistance, farPlaneDistance)); + T negFarRange = T.IsPositiveInfinity(farPlaneDistance) + ? -T.One + : farPlaneDistance / (nearPlaneDistance - farPlaneDistance); result.M33 = negFarRange; - result.M31 = result.M32 = Scalar.Zero; - result.M34 = Scalar.MinusOne; + result.M31 = result.M32 = T.Zero; + result.M34 = -T.One; - result.M41 = result.M42 = result.M44 = Scalar.Zero; - result.M43 = Scalar.Multiply(nearPlaneDistance, negFarRange); + result.M41 = result.M42 = result.M44 = T.Zero; + result.M43 = nearPlaneDistance * negFarRange; return result; } @@ -356,33 +356,33 @@ public static Matrix4X4 CreatePerspective(T width, T height, T nearPlaneDi public static Matrix4X4 CreatePerspectiveFieldOfView(T fieldOfView, T aspectRatio, T nearPlaneDistance, T farPlaneDistance) where T : INumberBase { - if (!Scalar.GreaterThan(fieldOfView, Scalar.Zero) || Scalar.GreaterThanOrEqual(fieldOfView, Scalar.Pi)) + if (!(fieldOfView > T.Zero) || (fieldOfView >= T.Pi)) throw new ArgumentOutOfRangeException(nameof(fieldOfView)); - if (!Scalar.GreaterThan(nearPlaneDistance, Scalar.Zero)) + if (!(nearPlaneDistance > T.Zero)) throw new ArgumentOutOfRangeException(nameof(nearPlaneDistance)); - if (!Scalar.GreaterThan(farPlaneDistance, Scalar.Zero)) + if (!(farPlaneDistance > T.Zero)) throw new ArgumentOutOfRangeException(nameof(farPlaneDistance)); - T yScale = Scalar.Reciprocal(Scalar.Tan(Scalar.Divide(fieldOfView, Scalar.Two))); - T xScale = Scalar.Divide(yScale, aspectRatio); + T yScale = T.One / T.Tan(fieldOfView / T.CreateTruncating(2)); + T xScale = yScale / aspectRatio; Matrix4X4 result = default; result.M11 = xScale; - result.M12 = result.M13 = result.M14 = Scalar.Zero; + result.M12 = result.M13 = result.M14 = T.Zero; result.M22 = yScale; - result.M21 = result.M23 = result.M24 = Scalar.Zero; + result.M21 = result.M23 = result.M24 = T.Zero; - result.M31 = result.M32 = Scalar.Zero; - T negFarRange = Scalar.IsPositiveInfinity(farPlaneDistance) ? Scalar.MinusOne : Scalar.Divide(farPlaneDistance, Scalar.Subtract(nearPlaneDistance, farPlaneDistance)); + result.M31 = result.M32 = T.Zero; + T negFarRange = T.IsPositiveInfinity(farPlaneDistance) ? -T.One : farPlaneDistance / (nearPlaneDistance - farPlaneDistance); result.M33 = negFarRange; - result.M34 = Scalar.MinusOne; + result.M34 = -T.One; - result.M41 = result.M42 = result.M44 = Scalar.Zero; - result.M43 = Scalar.Multiply(nearPlaneDistance, negFarRange); + result.M41 = result.M42 = result.M44 = T.Zero; + result.M43 = nearPlaneDistance * negFarRange; return result; } @@ -398,28 +398,28 @@ public static Matrix4X4 CreatePerspectiveFieldOfView(T fieldOfView, T aspe public static Matrix4X4 CreatePerspectiveOffCenter(T left, T right, T bottom, T top, T nearPlaneDistance, T farPlaneDistance) where T : INumberBase { - if (!Scalar.GreaterThan(nearPlaneDistance, Scalar.Zero)) + if (!(nearPlaneDistance > T.Zero)) throw new ArgumentOutOfRangeException(nameof(nearPlaneDistance)); - if (!Scalar.GreaterThan(farPlaneDistance, Scalar.Zero)) + if (!(farPlaneDistance > T.Zero)) throw new ArgumentOutOfRangeException(nameof(farPlaneDistance)); Matrix4X4 result = default; - result.M11 = Scalar.Divide(Scalar.Multiply(Scalar.Two, nearPlaneDistance), Scalar.Subtract(right, left)); - result.M12 = result.M13 = result.M14 = Scalar.Zero; + result.M11 = T.CreateTruncating(2) * nearPlaneDistance / (right - left); + result.M12 = result.M13 = result.M14 = T.Zero; - result.M22 = Scalar.Divide(Scalar.Multiply(Scalar.Two, nearPlaneDistance), Scalar.Subtract(top, bottom)); - result.M21 = result.M23 = result.M24 = Scalar.Zero; + result.M22 = T.CreateTruncating(2) * nearPlaneDistance / (top - bottom); + result.M21 = result.M23 = result.M24 = T.Zero; - result.M31 = Scalar.Divide(Scalar.Add(left, right), Scalar.Subtract(right, left)); - result.M32 = Scalar.Divide(Scalar.Add(top, bottom), Scalar.Subtract(top, bottom)); - T negFarRange = Scalar.IsPositiveInfinity(farPlaneDistance) ? Scalar.MinusOne : Scalar.Divide(farPlaneDistance, Scalar.Subtract(nearPlaneDistance, farPlaneDistance)); + result.M31 = (left + right) / (right - left); + result.M32 = (top + bottom) / (top - bottom); + T negFarRange = T.IsPositiveInfinity(farPlaneDistance) ? -T.One : farPlaneDistance / (nearPlaneDistance - farPlaneDistance); result.M33 = negFarRange; - result.M34 = Scalar.MinusOne; + result.M34 = -T.One; - result.M43 = Scalar.Multiply(nearPlaneDistance, negFarRange); - result.M41 = result.M42 = result.M44 = Scalar.Zero; + result.M43 = nearPlaneDistance * negFarRange; + result.M41 = result.M42 = result.M44 = T.Zero; return result; } @@ -436,27 +436,27 @@ public static Matrix4X4 CreateReflection(Plane value) T b = value.Normal.Y; T c = value.Normal.Z; - T fa = Scalar.Multiply(Scalar.MinusTwo, a); - T fb = Scalar.Multiply(Scalar.MinusTwo, b); - T fc = Scalar.Multiply(Scalar.MinusTwo, c); + T fa = -T.CreateTruncating(2) * a; + T fb = -T.CreateTruncating(2) * b; + T fc = -T.CreateTruncating(2) * c; Matrix4X4 result = Matrix4X4.Identity; - result.M11 = Scalar.Add(Scalar.Multiply(fa, a), Scalar.One); - result.M12 = Scalar.Multiply(fb, a); - result.M13 = Scalar.Multiply(fc, a); + result.M11 = (fa * a) + T.One; + result.M12 = fb * a; + result.M13 = fc * a; - result.M21 = Scalar.Multiply(fa, b); - result.M22 = Scalar.Add(Scalar.Multiply(fb, b), Scalar.One); - result.M23 = Scalar.Multiply(fc, b); + result.M21 = fa * b; + result.M22 = (fb * b) + T.One; + result.M23 = fc * b; - result.M31 = Scalar.Multiply(fa, c); - result.M32 = Scalar.Multiply(fb, c); - result.M33 = Scalar.Add(Scalar.Multiply(fc, c), Scalar.One); + result.M31 = fa * c; + result.M32 = fb * c; + result.M33 = (fc * c) + T.One; - result.M41 = Scalar.Multiply(fa, value.Distance); - result.M42 = Scalar.Multiply(fb, value.Distance); - result.M43 = Scalar.Multiply(fc, value.Distance); + result.M41 = fa * value.Distance; + result.M42 = fb * value.Distance; + result.M43 = fc * value.Distance; return result; } @@ -469,8 +469,8 @@ public static Matrix4X4 CreateRotationX(T radians) { Matrix4X4 result = Matrix4X4.Identity; - T c = Scalar.Cos(radians); - T s = Scalar.Sin(radians); + T c = T.Cos(radians); + T s = T.Sin(radians); // [ 1 0 0 0 ] // [ 0 c s 0 ] @@ -479,7 +479,7 @@ public static Matrix4X4 CreateRotationX(T radians) result.M22 = c; result.M23 = s; - result.M32 = Scalar.Negate(s); + result.M32 = -s; result.M33 = c; return result; @@ -494,11 +494,11 @@ public static Matrix4X4 CreateRotationX(T radians, Vector3D centerPoint { Matrix4X4 result = Matrix4X4.Identity; - T c = Scalar.Cos(radians); - T s = Scalar.Sin(radians); + T c = T.Cos(radians); + T s = T.Sin(radians); - T y = Scalar.Add(Scalar.Multiply(centerPoint.Y, Scalar.Subtract(Scalar.One, c)), Scalar.Multiply(centerPoint.Z, s)); - T z = Scalar.Subtract(Scalar.Multiply(centerPoint.Z, Scalar.Subtract(Scalar.One, c)), Scalar.Multiply(centerPoint.Y, s)); + T y = (centerPoint.Y * (T.One - c)) + (centerPoint.Z * s); + T z = (centerPoint.Z * (T.One - c)) - (centerPoint.Y * s); // [ 1 0 0 0 ] // [ 0 c s 0 ] @@ -507,7 +507,7 @@ public static Matrix4X4 CreateRotationX(T radians, Vector3D centerPoint result.M22 = c; result.M23 = s; - result.M32 = Scalar.Negate(s); + result.M32 = -s; result.M33 = c; result.M42 = y; result.M43 = z; @@ -523,15 +523,15 @@ public static Matrix4X4 CreateRotationY(T radians) { Matrix4X4 result = Matrix4X4.Identity; - T c = Scalar.Cos(radians); - T s = Scalar.Sin(radians); + T c = T.Cos(radians); + T s = T.Sin(radians); // [ c 0 -s 0 ] // [ 0 1 0 0 ] // [ s 0 c 0 ] // [ 0 0 0 1 ] result.M11 = c; - result.M13 = Scalar.Negate(s); + result.M13 = -s; result.M31 = s; result.M33 = c; @@ -547,18 +547,18 @@ public static Matrix4X4 CreateRotationY(T radians, Vector3D centerPoint { Matrix4X4 result = Matrix4X4.Identity; - T c = Scalar.Cos(radians); - T s = Scalar.Sin(radians); + T c = T.Cos(radians); + T s = T.Sin(radians); - T x = Scalar.Subtract(Scalar.Multiply(centerPoint.X, Scalar.Subtract(Scalar.One, c)), Scalar.Multiply(centerPoint.Z, s)); - T z = Scalar.Add(Scalar.Multiply(centerPoint.Z, Scalar.Subtract(Scalar.One, c)), Scalar.Multiply(centerPoint.X, s)); + T x = (centerPoint.X * (T.One - c)) - (centerPoint.Z * s); + T z = (centerPoint.Z * (T.One - c)) + (centerPoint.X * s); // [ c 0 -s 0 ] // [ 0 1 0 0 ] // [ s 0 c 0 ] // [ x 0 z 1 ] result.M11 = c; - result.M13 = Scalar.Negate(s); + result.M13 = -s; result.M31 = s; result.M33 = c; result.M41 = x; @@ -575,8 +575,8 @@ public static Matrix4X4 CreateRotationZ(T radians) { Matrix4X4 result = Matrix4X4.Identity; - T c = Scalar.Cos(radians); - T s = Scalar.Sin(radians); + T c = T.Cos(radians); + T s = T.Sin(radians); // [ c s 0 0 ] // [ -s c 0 0 ] @@ -584,7 +584,7 @@ public static Matrix4X4 CreateRotationZ(T radians) // [ 0 0 0 1 ] result.M11 = c; result.M12 = s; - result.M21 = Scalar.Negate(s); + result.M21 = -s; result.M22 = c; return result; @@ -599,11 +599,11 @@ public static Matrix4X4 CreateRotationZ(T radians, Vector3D centerPoint { Matrix4X4 result = Matrix4X4.Identity; - T c = Scalar.Cos(radians); - T s = Scalar.Sin(radians); + T c = T.Cos(radians); + T s = T.Sin(radians); - T x = Scalar.Add(Scalar.Multiply(centerPoint.X, Scalar.Subtract(Scalar.One, c)), Scalar.Multiply(centerPoint.Y, s)); - T y = Scalar.Subtract(Scalar.Multiply(centerPoint.Y, Scalar.Subtract(Scalar.One, c)), Scalar.Multiply(centerPoint.X, s)); + T x = (centerPoint.X * (T.One - c)) + (centerPoint.Y * s); + T y = (centerPoint.Y * (T.One - c)) - (centerPoint.X * s); // [ c s 0 0 ] // [ -s c 0 0 ] @@ -611,7 +611,7 @@ public static Matrix4X4 CreateRotationZ(T radians, Vector3D centerPoint // [ x y 0 1 ] result.M11 = c; result.M12 = s; - result.M21 = Scalar.Negate(s); + result.M21 = -s; result.M22 = c; result.M41 = x; result.M42 = y; @@ -645,9 +645,9 @@ public static Matrix4X4 CreateScale(T xScale, T yScale, T zScale, Vector3D { Matrix4X4 result = Matrix4X4.Identity; - T tx = Scalar.Multiply(centerPoint.X, Scalar.Subtract(Scalar.One, xScale)); - T ty = Scalar.Multiply(centerPoint.Y, Scalar.Subtract(Scalar.One, yScale)); - T tz = Scalar.Multiply(centerPoint.Z, Scalar.Subtract(Scalar.One, zScale)); + T tx = centerPoint.X * (T.One - xScale); + T ty = centerPoint.Y * (T.One - yScale); + T tz = centerPoint.Z * (T.One - zScale); result.M11 = xScale; result.M22 = yScale; @@ -680,9 +680,9 @@ public static Matrix4X4 CreateScale(Vector3D scales, Vector3D center { Matrix4X4 result = Matrix4X4.Identity; - T tx = Scalar.Multiply(centerPoint.X, Scalar.Subtract(Scalar.One, scales.X)); - T ty = Scalar.Multiply(centerPoint.Y, Scalar.Subtract(Scalar.One, scales.Y)); - T tz = Scalar.Multiply(centerPoint.Z, Scalar.Subtract(Scalar.One, scales.Z)); + T tx = centerPoint.X * (T.One - scales.X); + T ty = centerPoint.Y * (T.One - scales.Y); + T tz = centerPoint.Z * (T.One - scales.Z); result.M11 = scales.X; result.M22 = scales.Y; @@ -717,9 +717,9 @@ public static Matrix4X4 CreateScale(T scale, Vector3D centerPoint) { Matrix4X4 result = Matrix4X4.Identity; - T tx = Scalar.Multiply(centerPoint.X, Scalar.Subtract(Scalar.One, scale)); - T ty = Scalar.Multiply(centerPoint.Y, Scalar.Subtract(Scalar.One, scale)); - T tz = Scalar.Multiply(centerPoint.Z, Scalar.Subtract(Scalar.One, scale)); + T tx = centerPoint.X * (T.One - scale); + T ty = centerPoint.Y * (T.One - scale); + T tz = centerPoint.Z * (T.One - scale); result.M11 = scale; result.M22 = scale; @@ -741,28 +741,28 @@ public static Matrix4X4 CreateShadow(Vector3D lightDirection, Plane { Plane p = Plane.Normalize(plane); - T dot = Scalar.Add(Scalar.Add(Scalar.Multiply(p.Normal.X, lightDirection.X), Scalar.Multiply(p.Normal.Y, lightDirection.Y)), Scalar.Multiply(p.Normal.Z, lightDirection.Z)); - T a = Scalar.Negate(p.Normal.X); - T b = Scalar.Negate(p.Normal.Y); - T c = Scalar.Negate(p.Normal.Z); - T d = Scalar.Negate(p.Distance); + T dot = (p.Normal.X * lightDirection.X) + (p.Normal.Y * lightDirection.Y) + (p.Normal.Z * lightDirection.Z); + T a = -p.Normal.X; + T b = -p.Normal.Y; + T c = -p.Normal.Z; + T d = -p.Distance; Matrix4X4 result = Matrix4X4.Identity; - result.M11 = Scalar.Add(Scalar.Multiply(a, lightDirection.X), dot); - result.M21 = Scalar.Multiply(b, lightDirection.X); - result.M31 = Scalar.Multiply(c, lightDirection.X); - result.M41 = Scalar.Multiply(d, lightDirection.X); + result.M11 = (a * lightDirection.X) + dot; + result.M21 = b * lightDirection.X; + result.M31 = c * lightDirection.X; + result.M41 = d * lightDirection.X; - result.M12 = Scalar.Multiply(a, lightDirection.Y); - result.M22 = Scalar.Add(Scalar.Multiply(b, lightDirection.Y), dot); - result.M32 = Scalar.Multiply(c, lightDirection.Y); - result.M42 = Scalar.Multiply(d, lightDirection.Y); + result.M12 = a * lightDirection.Y; + result.M22 = (b * lightDirection.Y) + dot; + result.M32 = c * lightDirection.Y; + result.M42 = d * lightDirection.Y; - result.M13 = Scalar.Multiply(a, lightDirection.Z); - result.M23 = Scalar.Multiply(b, lightDirection.Z); - result.M33 = Scalar.Add(Scalar.Multiply(c, lightDirection.Z), dot); - result.M43 = Scalar.Multiply(d, lightDirection.Z); + result.M13 = a * lightDirection.Z; + result.M23 = b * lightDirection.Z; + result.M33 = (c * lightDirection.Z) + dot; + result.M43 = d * lightDirection.Z; result.M44 = dot; @@ -790,7 +790,7 @@ public static Matrix4X4 CreateTranslation(Vector3D position) public static Matrix4X4 CreateTranslation(T xPosition, T yPosition, T zPosition) where T : INumberBase { - Matrix4X4 result = Matrix4X4.Identity; ; + Matrix4X4 result = Matrix4X4.Identity; result.M41 = xPosition; result.M42 = yPosition; result.M43 = zPosition; @@ -835,7 +835,7 @@ public static Matrix4X4 CreateWorld(Vector3D position, Vector3D forw /// If successful, contains the inverted matrix. /// True if the source matrix could be inverted; False otherwise. /// - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static unsafe bool Invert(Matrix4X4 matrix, out Matrix4X4 result) where T : INumberBase { @@ -1115,67 +1115,67 @@ static bool SoftwareFallback(Matrix4X4 matrix, out Matrix4X4 result) T i = matrix.M31, j = matrix.M32, k = matrix.M33, l = matrix.M34; T m = matrix.M41, n = matrix.M42, o = matrix.M43, p = matrix.M44; - T kp_lo = Scalar.Subtract(Scalar.Multiply(k, p), Scalar.Multiply(l, o)); - T jp_ln = Scalar.Subtract(Scalar.Multiply(j, p), Scalar.Multiply(l, n)); - T jo_kn = Scalar.Subtract(Scalar.Multiply(j, o), Scalar.Multiply(k, n)); - T ip_lm = Scalar.Subtract(Scalar.Multiply(i, p), Scalar.Multiply(l, m)); - T io_km = Scalar.Subtract(Scalar.Multiply(i, o), Scalar.Multiply(k, m)); - T in_jm = Scalar.Subtract(Scalar.Multiply(i, n), Scalar.Multiply(j, m)); + T kp_lo = (k * p) - (l * o); + T jp_ln = (j * p) - (l * n); + T jo_kn = (j * o) - (k * n); + T ip_lm = (i * p) - (l * m); + T io_km = (i * o) - (k * m); + T in_jm = (i * n) - (j * m); - T a11 = Scalar.Add(Scalar.Subtract(Scalar.Multiply(f, kp_lo), Scalar.Multiply(g, jp_ln)), Scalar.Multiply(h, jo_kn)); - T a12 = Scalar.Negate(Scalar.Add(Scalar.Subtract(Scalar.Multiply(e, kp_lo), Scalar.Multiply(g, ip_lm)), Scalar.Multiply(h, io_km))); - T a13 = Scalar.Add(Scalar.Subtract(Scalar.Multiply(e, jp_ln), Scalar.Multiply(f, ip_lm)), Scalar.Multiply(h, in_jm)); - T a14 = Scalar.Negate(Scalar.Add(Scalar.Subtract(Scalar.Multiply(e, jo_kn), Scalar.Multiply(f, io_km)), Scalar.Multiply(g, in_jm))); + T a11 = (f * kp_lo) - (g * jp_ln) + (h * jo_kn); + T a12 = -((e * kp_lo) - (g * ip_lm) + (h * io_km)); + T a13 = (e * jp_ln) - (f * ip_lm) + (h * in_jm); + T a14 = -((e * jo_kn) - (f * io_km) + (g * in_jm)); - T det = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(a, a11), Scalar.Multiply(b, a12)), Scalar.Multiply(c, a13)), Scalar.Multiply(d, a14)); + T det = (a * a11) + (b * a12) + (c * a13) + (d * a14); - if (!Scalar.GreaterThanOrEqual(T.Abs(det), Scalar.Epsilon)) + if (!(T.Abs(det) >= T.Epsilon)) { - result = new Matrix4X4(Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN, - Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN, - Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN, - Scalar.NaN, Scalar.NaN, Scalar.NaN, Scalar.NaN); + result = new Matrix4X4(T.NaN, T.NaN, T.NaN, T.NaN, + T.NaN, T.NaN, T.NaN, T.NaN, + T.NaN, T.NaN, T.NaN, T.NaN, + T.NaN, T.NaN, T.NaN, T.NaN); return false; } - T invDet = Scalar.Reciprocal(det); + T invDet = T.One / det; // TODO: Vectorize result = default; - result.M11 = Scalar.Multiply(a11, invDet); - result.M21 = Scalar.Multiply(a12, invDet); - result.M31 = Scalar.Multiply(a13, invDet); - result.M41 = Scalar.Multiply(a14, invDet); - - result.M12 = Scalar.Negate(Scalar.Multiply(Scalar.Add(Scalar.Subtract(Scalar.Multiply(b, kp_lo), Scalar.Multiply(c, jp_ln)), Scalar.Multiply(d, jo_kn)), invDet)); - result.M22 = Scalar.Multiply(Scalar.Add(Scalar.Subtract(Scalar.Multiply(a, kp_lo), Scalar.Multiply(c, ip_lm)), Scalar.Multiply(d, io_km)), invDet); - result.M32 = Scalar.Negate(Scalar.Multiply(Scalar.Add(Scalar.Subtract(Scalar.Multiply(a, jp_ln), Scalar.Multiply(b, ip_lm)), Scalar.Multiply(d, in_jm)), invDet)); - result.M42 = Scalar.Multiply(Scalar.Add(Scalar.Subtract(Scalar.Multiply(a, jo_kn), Scalar.Multiply(b, io_km)), Scalar.Multiply(c, in_jm)), invDet); - - T gp_ho = Scalar.Subtract(Scalar.Multiply(g, p), Scalar.Multiply(h, o)); - T fp_hn = Scalar.Subtract(Scalar.Multiply(f, p), Scalar.Multiply(h, n)); - T fo_gn = Scalar.Subtract(Scalar.Multiply(f, o), Scalar.Multiply(g, n)); - T ep_hm = Scalar.Subtract(Scalar.Multiply(e, p), Scalar.Multiply(h, m)); - T eo_gm = Scalar.Subtract(Scalar.Multiply(e, o), Scalar.Multiply(g, m)); - T en_fm = Scalar.Subtract(Scalar.Multiply(e, n), Scalar.Multiply(f, m)); - - result.M13 = Scalar.Multiply(Scalar.Add(Scalar.Subtract(Scalar.Multiply(b, gp_ho), Scalar.Multiply(c, fp_hn)), Scalar.Multiply(d, fo_gn)), invDet); - result.M23 = Scalar.Negate(Scalar.Multiply(Scalar.Add(Scalar.Subtract(Scalar.Multiply(a, gp_ho), Scalar.Multiply(c, ep_hm)), Scalar.Multiply(d, eo_gm)), invDet)); - result.M33 = Scalar.Multiply(Scalar.Add(Scalar.Subtract(Scalar.Multiply(a, fp_hn), Scalar.Multiply(b, ep_hm)), Scalar.Multiply(d, en_fm)), invDet); - result.M43 = Scalar.Negate(Scalar.Multiply(Scalar.Add(Scalar.Subtract(Scalar.Multiply(a, fo_gn), Scalar.Multiply(b, eo_gm)), Scalar.Multiply(c, en_fm)), invDet)); - - T gl_hk = Scalar.Subtract(Scalar.Multiply(g, l), Scalar.Multiply(h, k)); - T fl_hj = Scalar.Subtract(Scalar.Multiply(f, l), Scalar.Multiply(h, j)); - T fk_gj = Scalar.Subtract(Scalar.Multiply(f, k), Scalar.Multiply(g, j)); - T el_hi = Scalar.Subtract(Scalar.Multiply(e, l), Scalar.Multiply(h, i)); - T ek_gi = Scalar.Subtract(Scalar.Multiply(e, k), Scalar.Multiply(g, i)); - T ej_fi = Scalar.Subtract(Scalar.Multiply(e, j), Scalar.Multiply(f, i)); - - result.M14 = Scalar.Negate(Scalar.Multiply(Scalar.Add(Scalar.Subtract(Scalar.Multiply(b, gl_hk), Scalar.Multiply(c, fl_hj)), Scalar.Multiply(d, fk_gj)), invDet)); - result.M24 = Scalar.Multiply(Scalar.Add(Scalar.Subtract(Scalar.Multiply(a, gl_hk), Scalar.Multiply(c, el_hi)), Scalar.Multiply(d, ek_gi)), invDet); - result.M34 = Scalar.Negate(Scalar.Multiply(Scalar.Add(Scalar.Subtract(Scalar.Multiply(a, fl_hj), Scalar.Multiply(b, el_hi)), Scalar.Multiply(d, ej_fi)), invDet)); - result.M44 = Scalar.Multiply(Scalar.Add(Scalar.Subtract(Scalar.Multiply(a, fk_gj), Scalar.Multiply(b, ek_gi)), Scalar.Multiply(c, ej_fi)), invDet); + result.M11 = a11 * invDet; + result.M21 = a12 * invDet; + result.M31 = a13 * invDet; + result.M41 = a14 * invDet; + + result.M12 = -(((b * kp_lo) - (c * jp_ln) + (d * jo_kn)) * invDet); + result.M22 = ((a * kp_lo) - (c * ip_lm) + (d * io_km)) * invDet; + result.M32 = -(((a * jp_ln) - (b * ip_lm) + (d * in_jm)) * invDet); + result.M42 = ((a * jo_kn) - (b * io_km) + (c * in_jm)) * invDet; + + T gp_ho = (g * p) - (h * o); + T fp_hn = (f * p) - (h * n); + T fo_gn = (f * o) - (g * n); + T ep_hm = (e * p) - (h * m); + T eo_gm = (e * o) - (g * m); + T en_fm = (e * n) - (f * m); + + result.M13 = ((b * gp_ho) - (c * fp_hn) + (d * fo_gn)) * invDet; + result.M23 = -(((a * gp_ho) - (c * ep_hm) + (d * eo_gm)) * invDet); + result.M33 = ((a * fp_hn) - (b * ep_hm) + (d * en_fm)) * invDet; + result.M43 = -(((a * fo_gn) - (b * eo_gm) + (c * en_fm)) * invDet); + + T gl_hk = (g * l) - (h * k); + T fl_hj = (f * l) - (h * j); + T fk_gj = (f * k) - (g * j); + T el_hi = (e * l) - (h * i); + T ek_gi = (e * k) - (g * i); + T ej_fi = (e * j) - (f * i); + + result.M14 = -(((b * gl_hk) - (c * fl_hj) + (d * fk_gj)) * invDet); + result.M24 = ((a * gl_hk) - (c * el_hi) + (d * ek_gi)) * invDet; + result.M34 = -(((a * fl_hj) - (b * el_hi) + (d * ej_fi)) * invDet); + result.M44 = ((a * fk_gj) - (b * ek_gi) + (c * ej_fi)) * invDet; return true; } @@ -1226,9 +1226,9 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out CanonicalBasis canonicalBasis = default; Vector3D* pCanonicalBasis = &canonicalBasis.Row0; - canonicalBasis.Row0 = new Vector3D(Scalar.One, Scalar.Zero, Scalar.Zero); - canonicalBasis.Row1 = new Vector3D(Scalar.Zero, Scalar.One, Scalar.Zero); - canonicalBasis.Row2 = new Vector3D(Scalar.Zero, Scalar.Zero, Scalar.One); + canonicalBasis.Row0 = new Vector3D(T.One, T.Zero, T.Zero); + canonicalBasis.Row1 = new Vector3D(T.Zero, T.One, T.Zero); + canonicalBasis.Row2 = new Vector3D(T.Zero, T.Zero, T.One); translation = new Vector3D( matrix.M41, @@ -1250,9 +1250,9 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out uint a, b, c; #region Ranking T x = pfScales[0], y = pfScales[1], z = pfScales[2]; - if (!Scalar.GreaterThanOrEqual(x, y)) + if (!(x >= y)) { - if (!Scalar.GreaterThanOrEqual(y, z)) + if (!(y >= z)) { a = 2; b = 1; @@ -1262,7 +1262,7 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out { a = 1; - if (!Scalar.GreaterThanOrEqual(x, z)) + if (!(x >= z)) { b = 2; c = 0; @@ -1276,7 +1276,7 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out } else { - if (!Scalar.GreaterThanOrEqual(x, z)) + if (!(x >= z)) { a = 2; b = 0; @@ -1286,7 +1286,7 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out { a = 0; - if (!Scalar.GreaterThanOrEqual(y, z)) + if (!(y >= z)) { b = 2; c = 1; @@ -1300,32 +1300,32 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out } #endregion - if (!Scalar.GreaterThanOrEqual(pfScales[a], Scalar.As(DecomposeEpsilon))) + if (!(pfScales[a] >= T.CreateTruncating(DecomposeEpsilon))) { *(pVectorBasis[a]) = pCanonicalBasis[a]; } *pVectorBasis[a] = Vector3D.Normalize(*pVectorBasis[a]); - if (!Scalar.GreaterThanOrEqual(pfScales[b], Scalar.As(DecomposeEpsilon))) + if (!(pfScales[b] >= T.CreateTruncating(DecomposeEpsilon))) { uint cc; T fAbsX, fAbsY, fAbsZ; - fAbsX = Scalar.Abs(pVectorBasis[a]->X); - fAbsY = Scalar.Abs(pVectorBasis[a]->Y); - fAbsZ = Scalar.Abs(pVectorBasis[a]->Z); + fAbsX = T.Abs(pVectorBasis[a]->X); + fAbsY = T.Abs(pVectorBasis[a]->Y); + fAbsZ = T.Abs(pVectorBasis[a]->Z); #region Ranking - if (!Scalar.GreaterThanOrEqual(fAbsX, fAbsY)) + if (!(fAbsX >= fAbsY)) { - if (!Scalar.GreaterThanOrEqual(fAbsY, fAbsZ)) + if (!(fAbsY >= fAbsZ)) { cc = 0; } else { - if (!Scalar.GreaterThanOrEqual(fAbsX, fAbsZ)) + if (!(fAbsX >= fAbsZ)) { cc = 0; } @@ -1337,13 +1337,13 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out } else { - if (!Scalar.GreaterThanOrEqual(fAbsX, fAbsZ)) + if (!(fAbsX >= fAbsZ)) { cc = 1; } else { - if (!Scalar.GreaterThanOrEqual(fAbsY, fAbsZ)) + if (!(fAbsY >= fAbsZ)) { cc = 1; } @@ -1360,7 +1360,7 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out *pVectorBasis[b] = Vector3D.Normalize(*pVectorBasis[b]); - if (!Scalar.GreaterThanOrEqual(pfScales[c], Scalar.As(DecomposeEpsilon))) + if (!(pfScales[c] >= T.CreateTruncating(DecomposeEpsilon))) { *pVectorBasis[c] = Vector3D.Cross(*pVectorBasis[a], *pVectorBasis[b]); } @@ -1370,19 +1370,19 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out det = matTemp.GetDeterminant(); // use Kramer's rule to check for handedness of coordinate system - if (!Scalar.GreaterThanOrEqual(det, Scalar.Zero)) + if (!(det >= T.Zero)) { // switch coordinate system by negating the scale and inverting the basis vector on the x-axis - pfScales[a] = Scalar.Negate(pfScales[a]); + pfScales[a] = -pfScales[a]; *pVectorBasis[a] = -(*pVectorBasis[a]); - det = Scalar.Negate(det); + det = -det; } - det = Scalar.Subtract(det, Scalar.One); - det = Scalar.Multiply(det, det); + det = det - T.One; + det = det * det; - if (!Scalar.GreaterThanOrEqual(Scalar.As(DecomposeEpsilon), det)) + if (!(T.CreateTruncating(DecomposeEpsilon) >= det)) { // Non-SRT matrix encountered rotation = Legacy.Quaternion.Identity; @@ -1408,31 +1408,31 @@ public static Matrix4X4 Transform(Matrix4X4 value, Quaternion rotati where T : ITrigonometricFunctions { // Compute rotation matrix. - T x2 = Scalar.Add(rotation.X, rotation.X); - T y2 = Scalar.Add(rotation.Y, rotation.Y); - T z2 = Scalar.Add(rotation.Z, rotation.Z); - - T wx2 = Scalar.Multiply(rotation.W, x2); - T wy2 = Scalar.Multiply(rotation.W, y2); - T wz2 = Scalar.Multiply(rotation.W, z2); - T xx2 = Scalar.Multiply(rotation.X, x2); - T xy2 = Scalar.Multiply(rotation.X, y2); - T xz2 = Scalar.Multiply(rotation.X, z2); - T yy2 = Scalar.Multiply(rotation.Y, y2); - T yz2 = Scalar.Multiply(rotation.Y, z2); - T zz2 = Scalar.Multiply(rotation.Z, z2); - - T q11 = Scalar.Subtract(Scalar.Subtract(Scalar.One, yy2), zz2); - T q21 = Scalar.Subtract(xy2, wz2); - T q31 = Scalar.Add(xz2, wy2); - - T q12 = Scalar.Add(xy2, wz2); - T q22 = Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), zz2); - T q32 = Scalar.Subtract(yz2, wx2); - - T q13 = Scalar.Subtract(xz2, wy2); - T q23 = Scalar.Add(yz2, wx2); - T q33 = Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), yy2); + T x2 = rotation.X + rotation.X; + T y2 = rotation.Y + rotation.Y; + T z2 = rotation.Z + rotation.Z; + + T wx2 = rotation.W * x2; + T wy2 = rotation.W * y2; + T wz2 = rotation.W * z2; + T xx2 = rotation.X * x2; + T xy2 = rotation.X * y2; + T xz2 = rotation.X * z2; + T yy2 = rotation.Y * y2; + T yz2 = rotation.Y * z2; + T zz2 = rotation.Z * z2; + + T q11 = T.One - yy2 - zz2; + T q21 = xy2 - wz2; + T q31 = xz2 + wy2; + + T q12 = xy2 + wz2; + T q22 = T.One - xx2 - zz2; + T q32 = yz2 - wx2; + + T q13 = xz2 - wy2; + T q23 = yz2 + wx2; + T q33 = T.One - xx2 - yy2; var q1 = new Vector3D(q11, q12, q13); var q2 = new Vector3D(q21, q22, q23); diff --git a/sources/Maths/Maths/Matrix4X4.cs b/sources/Maths/Maths/Matrix4X4.cs index 2cd9f69e41..4abee35430 100644 --- a/sources/Maths/Maths/Matrix4X4.cs +++ b/sources/Maths/Maths/Matrix4X4.cs @@ -110,32 +110,17 @@ public readonly T GetDeterminant() T i = Row3.X, j = Row3.Y, k = Row3.Z, l = Row3.W; T m = Row4.X, n = Row4.Y, o = Row4.Z, p = Row4.W; - T kp_lo = Scalar.Subtract(Scalar.Multiply(k, p), Scalar.Multiply(l, o)); - T jp_ln = Scalar.Subtract(Scalar.Multiply(j, p), Scalar.Multiply(l, n)); - T jo_kn = Scalar.Subtract(Scalar.Multiply(j, o), Scalar.Multiply(k, n)); - T ip_lm = Scalar.Subtract(Scalar.Multiply(i, p), Scalar.Multiply(l, m)); - T io_km = Scalar.Subtract(Scalar.Multiply(i, o), Scalar.Multiply(k, m)); - T in_jm = Scalar.Subtract(Scalar.Multiply(i, n), Scalar.Multiply(j, m)); + T kp_lo = (k * p) - (l * o); + T jp_ln = (j * p) - (l * n); + T jo_kn = (j * o) - (k * n); + T ip_lm = (i * p) - (l * m); + T io_km = (i * o) - (k * m); + T in_jm = (i * n) - (j * m); - return Scalar.Add( - Scalar.Subtract( - Scalar.Multiply(a, - Scalar.Add( - Scalar.Subtract(Scalar.Multiply(f, kp_lo), Scalar.Multiply(g, jp_ln)), - Scalar.Multiply(h, jo_kn))), - Scalar.Multiply(b, - Scalar.Add( - Scalar.Subtract(Scalar.Multiply(e, kp_lo), Scalar.Multiply(g, ip_lm)), - Scalar.Multiply(h, io_km)))), - Scalar.Subtract( - Scalar.Multiply(c, - Scalar.Add( - Scalar.Subtract(Scalar.Multiply(e, jp_ln), Scalar.Multiply(f, ip_lm)), - Scalar.Multiply(h, in_jm))), - Scalar.Multiply(d, - Scalar.Add( - Scalar.Subtract(Scalar.Multiply(e, jo_kn), Scalar.Multiply(f, io_km)), - Scalar.Multiply(g, in_jm))))); + return (a * ((f * kp_lo) - (g * jp_ln) + (h * jo_kn))) + - (b * ((e * kp_lo) - (g * ip_lm) + (h * io_km))) + + ((c * ((e * jp_ln) - (f * ip_lm) + (h * in_jm))) + - (d * ((e * jo_kn) - (f * io_km) + (g * in_jm)))); } } } diff --git a/sources/Maths/Maths/Plane.Ops.cs b/sources/Maths/Maths/Plane.Ops.cs index 279f4200bf..3752151970 100644 --- a/sources/Maths/Maths/Plane.Ops.cs +++ b/sources/Maths/Maths/Plane.Ops.cs @@ -17,7 +17,7 @@ public static class Plane /// The second point defining the Plane. /// The third point defining the Plane. /// The Plane containing the three points. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static Plane CreateFromVertices(Vector3D point1, Vector3D point2, Vector3D point3) where T : INumberBase { @@ -30,9 +30,7 @@ public static Plane CreateFromVertices(Vector3D point1, Vector3D poi var cross = Vector3D.Cross(ab, ac); Plane p; p.Normal = cross; - p.Distance = Scalar.Negate(Scalar.Add( - Scalar.Add(Scalar.Multiply(p.Normal.X, a.X), Scalar.Multiply(p.Normal.Y, a.Y)), - Scalar.Multiply(p.Normal.Z, a.Z))); + p.Distance = -((p.Normal.X * a.X) + (p.Normal.Y * a.Y) + (p.Normal.Z * a.Z)); return p; @@ -46,38 +44,35 @@ public static Plane CreateFromVertices(Vector3D point1, Vector3D poi Vector3D normal = Vector3D.Normalize(n); // D = - Dot(N, point1) - T d = Scalar.Negate(Vector3D.Dot(normal, point1)); + T d = -Vector3D.Dot(normal, point1); return new Plane(normal, d); } else { - T ax = Scalar.Subtract(point2.X, point1.X); - T ay = Scalar.Subtract(point2.Y, point1.Y); - T az = Scalar.Subtract(point2.Z, point1.Z); + T ax = point2.X - point1.X; + T ay = point2.Y - point1.Y; + T az = point2.Z - point1.Z; - T bx = Scalar.Subtract(point3.X, point1.X); - T by = Scalar.Subtract(point3.Y, point1.Y); - T bz = Scalar.Subtract(point3.Z, point1.Z); + T bx = point3.X - point1.X; + T by = point3.Y - point1.Y; + T bz = point3.Z - point1.Z; // N=Cross(a,b) - T nx = Scalar.Subtract(Scalar.Multiply(ay, bz), Scalar.Multiply(az, by)); - T ny = Scalar.Subtract(Scalar.Multiply(az, bx), Scalar.Multiply(ax, bz)); - T nz = Scalar.Subtract(Scalar.Multiply(ax, by), Scalar.Multiply(ay, bx)); + T nx = (ay * bz) - (az * by); + T ny = (az * bx) - (ax * bz); + T nz = (ax * by) - (ay * bx); // Normalize(N) - T ls = Scalar.Add(Scalar.Add(Scalar.Multiply(nx, nx), Scalar.Multiply(ny, ny)), Scalar.Multiply(nz, nz)); - T invNorm = Scalar.Inverse(Scalar.Sqrt(ls)); + T ls = (nx * nx) + (ny * ny) + (nz * nz); + T invNorm = T.One / T.Sqrt(ls); Vector3D normal = new Vector3D( - Scalar.Multiply(nx, invNorm), - Scalar.Multiply(ny, invNorm), - Scalar.Multiply(nz, invNorm)); - - return new(normal, - Scalar.Negate(Scalar.Add( - Scalar.Add(Scalar.Multiply(normal.X, point1.X), - Scalar.Multiply(normal.Y, point1.Y)), Scalar.Multiply(normal.Z, point1.Z)))); + nx * invNorm, + ny * invNorm, + nz * invNorm); + + return new(normal, -((normal.X * point1.X) + (normal.Y * point1.Y) + (normal.Z * point1.Z))); }*/ } @@ -85,29 +80,25 @@ public static Plane CreateFromVertices(Vector3D point1, Vector3D poi /// The Plane. /// The Vector4D. /// The dot product. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static T Dot(Plane plane, Vector4D value) where T : INumberBase - => Scalar.Add( - Scalar.Add( - Scalar.Add(Scalar.Multiply(plane.Normal.X, value.X), - Scalar.Multiply(plane.Normal.Y, value.Y)), Scalar.Multiply(plane.Normal.Z, value.Z)), - Scalar.Multiply(plane.Distance, value.W)); + => (plane.Normal.X * value.X) + (plane.Normal.Y * value.Y) + (plane.Normal.Z * value.Z) + (plane.Distance * value.W); /// Returns the dot product of a specified Vector3D and the normal vector of this Plane plus the distance (D) value of the Plane. /// The plane. /// The Vector3D. /// The resulting value. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static T DotCoordinate(Plane plane, Vector3D value) where T : INumberBase - => Scalar.Add(Vector3D.Dot(plane.Normal, value), plane.Distance); + => Vector3D.Dot(plane.Normal, value) + plane.Distance; /// Returns the dot product of a specified Vector3D and the Normal vector of this Plane. /// The plane. /// The Vector3D. /// The resulting dot product. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static T DotNormal(Plane plane, Vector3D value) where T : INumberBase => Vector3D.Dot(plane.Normal, value); @@ -117,7 +108,7 @@ public static T DotNormal(Plane plane, Vector3D value) /// Creates a new Plane whose normal vector is the source Plane's normal vector normalized. /// The source Plane. /// The normalized Plane. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static Plane Normalize(Plane value) where T : INumberBase { @@ -136,23 +127,20 @@ public static Plane Normalize(Plane value) } else*/ { - T f = Scalar.Add( - Scalar.Add(Scalar.Multiply(value.Normal.X, value.Normal.X), - Scalar.Multiply(value.Normal.Y, value.Normal.Y)), - Scalar.Multiply(value.Normal.Z, value.Normal.Z)); + T f = (value.Normal.X * value.Normal.X) + (value.Normal.Y * value.Normal.Y) + (value.Normal.Z * value.Normal.Z); - if (!Scalar.GreaterThanOrEqual(T.Abs(Scalar.Subtract(f, Scalar.One)), Scalar.As(NormalizeEpsilon))) + if (!(T.Abs(f - T.One) >= T.CreateTruncating(NormalizeEpsilon))) { return value; // It already normalized, so we don't need to further process. } - T fInv = Scalar.Reciprocal(Scalar.Sqrt(f)); + T fInv = T.One / T.Sqrt(f); return new( - Scalar.Multiply(value.Normal.X, fInv), - Scalar.Multiply(value.Normal.Y, fInv), - Scalar.Multiply(value.Normal.Z, fInv), - Scalar.Multiply(value.Distance, fInv)); + value.Normal.X * fInv, + value.Normal.Y * fInv, + value.Normal.Z * fInv, + value.Distance * fInv); } } @@ -161,7 +149,7 @@ public static Plane Normalize(Plane value) /// This Plane must already be normalized, so that its Normal vector is of unit length, before this method is called. /// The transformation matrix to apply to the Plane. /// The transformed Plane. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static Plane Transform(Plane plane, Matrix4X4 matrix) where T : INumberBase { @@ -170,10 +158,10 @@ public static Plane Transform(Plane plane, Matrix4X4 matrix) T x = plane.Normal.X, y = plane.Normal.Y, z = plane.Normal.Z, w = plane.Distance; return new( - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(x, m.M11), Scalar.Multiply(y, m.M12)), Scalar.Multiply(z, m.M13)), Scalar.Multiply(w, m.M14)), - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(x, m.M21), Scalar.Multiply(y, m.M22)), Scalar.Multiply(z, m.M23)), Scalar.Multiply(w, m.M24)), - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(x, m.M31), Scalar.Multiply(y, m.M32)), Scalar.Multiply(z, m.M33)), Scalar.Multiply(w, m.M34)), - Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(x, m.M41), Scalar.Multiply(y, m.M42)), Scalar.Multiply(z, m.M43)), Scalar.Multiply(w, m.M44))); + (x * m.M11) + (y * m.M12) + (z * m.M13) + (w * m.M14), + (x * m.M21) + (y * m.M22) + (z * m.M23) + (w * m.M24), + (x * m.M31) + (y * m.M32) + (z * m.M33) + (w * m.M34), + (x * m.M41) + (y * m.M42) + (z * m.M43) + (w * m.M44)); } /// Transforms a normalized Plane by a Quaternion rotation. @@ -181,43 +169,43 @@ public static Plane Transform(Plane plane, Matrix4X4 matrix) /// This Plane must already be normalized, so that its Normal vector is of unit length, before this method is called. /// The Quaternion rotation to apply to the Plane. /// A new Plane that results from applying the rotation. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static Plane Transform(Plane plane, Quaternion rotation) where T : ITrigonometricFunctions { // Compute rotation matrix. - T x2 = Scalar.Add(rotation.X, rotation.X); - T y2 = Scalar.Add(rotation.Y, rotation.Y); - T z2 = Scalar.Add(rotation.Z, rotation.Z); - - T wx2 = Scalar.Multiply(rotation.W, x2); - T wy2 = Scalar.Multiply(rotation.W, y2); - T wz2 = Scalar.Multiply(rotation.W, z2); - T xx2 = Scalar.Multiply(rotation.X, x2); - T xy2 = Scalar.Multiply(rotation.X, y2); - T xz2 = Scalar.Multiply(rotation.X, z2); - T yy2 = Scalar.Multiply(rotation.Y, y2); - T yz2 = Scalar.Multiply(rotation.Y, z2); - T zz2 = Scalar.Multiply(rotation.Z, z2); - - T m11 = Scalar.Subtract(Scalar.Subtract(Scalar.One, yy2), zz2); - T m21 = Scalar.Subtract(xy2, wz2); - T m31 = Scalar.Add(xz2, wy2); - - T m12 = Scalar.Add(xy2, wz2); - T m22 = Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), zz2); - T m32 = Scalar.Subtract(yz2, wx2); - - T m13 = Scalar.Subtract(xz2, wy2); - T m23 = Scalar.Add(yz2, wx2); - T m33 = Scalar.Subtract(Scalar.Subtract(Scalar.One, xx2), yy2); + T x2 = rotation.X + rotation.X; + T y2 = rotation.Y + rotation.Y; + T z2 = rotation.Z + rotation.Z; + + T wx2 = rotation.W * x2; + T wy2 = rotation.W * y2; + T wz2 = rotation.W * z2; + T xx2 = rotation.X * x2; + T xy2 = rotation.X * y2; + T xz2 = rotation.X * z2; + T yy2 = rotation.Y * y2; + T yz2 = rotation.Y * z2; + T zz2 = rotation.Z * z2; + + T m11 = T.One - yy2 - zz2; + T m21 = xy2 - wz2; + T m31 = xz2 + wy2; + + T m12 = xy2 + wz2; + T m22 = T.One - xx2 - zz2; + T m32 = yz2 - wx2; + + T m13 = xz2 - wy2; + T m23 = yz2 + wx2; + T m33 = T.One - xx2 - yy2; T x = plane.Normal.X, y = plane.Normal.Y, z = plane.Normal.Z; return new( - Scalar.Add(Scalar.Add(Scalar.Multiply(x, m11), Scalar.Multiply(y, m21)), Scalar.Multiply(z, m31)), - Scalar.Add(Scalar.Add(Scalar.Multiply(x, m12), Scalar.Multiply(y, m22)), Scalar.Multiply(z, m32)), - Scalar.Add(Scalar.Add(Scalar.Multiply(x, m13), Scalar.Multiply(y, m23)), Scalar.Multiply(z, m33)), + (x * m11) + (y * m21) + (z * m31), + (x * m12) + (y * m22) + (z * m32), + (x * m13) + (y * m23) + (z * m33), plane.Distance); } } diff --git a/sources/Maths/Maths/Plane.cs b/sources/Maths/Maths/Plane.cs index 39a7164f86..d4794bcced 100644 --- a/sources/Maths/Maths/Plane.cs +++ b/sources/Maths/Maths/Plane.cs @@ -60,22 +60,22 @@ public Plane(Vector4D value) /// The first Plane to compare. /// The second Plane to compare. /// True if the Planes are equal; False otherwise. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static bool operator ==(Plane value1, Plane value2) - => value1.Normal == value2.Normal && Scalar.Equal(value1.Distance, value2.Distance); + => value1.Normal == value2.Normal && value1.Distance == value2.Distance; /// Returns a boolean indicating whether the two given Planes are not equal. /// The first Plane to compare. /// The second Plane to compare. /// True if the Planes are not equal; False if they are equal. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static bool operator !=(Plane value1, Plane value2) => !(value1 == value2); /// Returns a boolean indicating whether the given Object is equal to this Plane instance. /// The Object to compare against. /// True if the Object is equal to this Plane; False otherwise. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public override readonly bool Equals(object? obj) { return (obj is Plane other) && Equals(other); @@ -84,10 +84,10 @@ public override readonly bool Equals(object? obj) /// Returns a boolean indicating whether the given Plane is equal to this Plane instance. /// The Plane to compare this instance to. /// True if the other Plane is equal to this instance; False otherwise. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public readonly bool Equals(Plane other) { - return Normal.Equals(other.Normal) && Scalar.Equal(Distance, other.Distance); + return Normal.Equals(other.Normal) && Distance == other.Distance; } /// Returns the hash code for this instance. @@ -111,7 +111,7 @@ public override readonly string ToString() /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new((Vector3D) from.Normal, Scalar.As(from.Distance)); + => new((Vector3D)from.Normal, Half.CreateTruncating(from.Distance)); /// /// Converts a into one with a of @@ -119,7 +119,7 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new((Vector3D) from.Normal, Scalar.As(from.Distance)); + => new((Vector3D)from.Normal, float.CreateTruncating(from.Distance)); /// /// Converts a into @@ -127,15 +127,15 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator System.Numerics.Plane(Plane from) - => new((System.Numerics.Vector3) from.Normal, Scalar.As(from.Distance)); - + => new((System.Numerics.Vector3)from.Normal, float.CreateTruncating(from.Distance)); + /// /// Converts a into one with a of /// /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new((Vector3D) from.Normal, Scalar.As(from.Distance)); + => new((Vector3D)from.Normal, double.CreateTruncating(from.Distance)); /// /// Converts a into one with a of @@ -143,7 +143,7 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new((Vector3D) from.Normal, Scalar.As(from.Distance)); + => new((Vector3D)from.Normal, decimal.CreateTruncating(from.Distance)); /// /// Converts a into one with a of @@ -151,7 +151,7 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new((Vector3D) from.Normal, Scalar.As(from.Distance)); + => new((Vector3D)from.Normal, sbyte.CreateTruncating(from.Distance)); /// /// Converts a into one with a of @@ -159,7 +159,7 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new((Vector3D) from.Normal, Scalar.As(from.Distance)); + => new((Vector3D)from.Normal, byte.CreateTruncating(from.Distance)); /// /// Converts a into one with a of @@ -167,7 +167,7 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new((Vector3D) from.Normal, Scalar.As(from.Distance)); + => new((Vector3D)from.Normal, ushort.CreateTruncating(from.Distance)); /// /// Converts a into one with a of @@ -175,7 +175,7 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new(from.Normal.AsSaturating(), short.CreateSaturating(from.Distance)); + => new((Vector3D)from.Normal, short.CreateTruncating(from.Distance)); /// /// Converts a into one with a of @@ -183,7 +183,7 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new((Vector3D) from.Normal, Scalar.As(from.Distance)); + => new((Vector3D)from.Normal, uint.CreateTruncating(from.Distance)); /// /// Converts a into one with a of @@ -191,7 +191,7 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new((Vector3D) from.Normal, Scalar.As(from.Distance)); + => new((Vector3D)from.Normal, int.CreateTruncating(from.Distance)); /// /// Converts a into one with a of @@ -199,7 +199,7 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new((Vector3D) from.Normal, Scalar.As(from.Distance)); + => new((Vector3D)from.Normal, ulong.CreateTruncating(from.Distance)); /// /// Converts a into one with a of @@ -207,8 +207,8 @@ public static explicit operator Plane(Plane from) /// The source matrix /// The matrix public static explicit operator Plane(Plane from) - => new((Vector3D) from.Normal, Scalar.As(from.Distance)); - + => new((Vector3D)from.Normal, long.CreateTruncating(from.Distance)); + /// /// Returns this plane casted to /// @@ -217,7 +217,7 @@ public static explicit operator Plane(Plane from) [Obsolete("Use AsChecked, AsSaturating, or AsTruncating instead.", error: false)] public Plane As() where TOther : INumberBase { - return new(Normal.As(), Scalar.As(Distance)); + return new(Normal.As(), TOther.CreateTruncating(Distance)); } } } diff --git a/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt index 47ef53fa1c..c532a03b17 100644 --- a/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -567,8 +567,6 @@ Silk.NET.Maths.Rectangle.Rectangle(Silk.NET.Maths.Vector2D origin, T sizeX Silk.NET.Maths.Rectangle.Rectangle(T originX, T originY, Silk.NET.Maths.Vector2D size) -> void Silk.NET.Maths.Rectangle.Rectangle(T originX, T originY, T sizeX, T sizeY) -> void Silk.NET.Maths.Rectangle.Size -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Scalar -Silk.NET.Maths.Scalar Silk.NET.Maths.Sphere Silk.NET.Maths.Sphere.As() -> Silk.NET.Maths.Sphere Silk.NET.Maths.Sphere.Center -> Silk.NET.Maths.Vector3D @@ -673,23 +671,6 @@ Silk.NET.Maths.Vector4D.W -> T Silk.NET.Maths.Vector4D.X -> T Silk.NET.Maths.Vector4D.Y -> T Silk.NET.Maths.Vector4D.Z -> T -static readonly Silk.NET.Maths.Scalar.DegreesPerRadian -> T -static readonly Silk.NET.Maths.Scalar.E -> T -static readonly Silk.NET.Maths.Scalar.Epsilon -> T -static readonly Silk.NET.Maths.Scalar.MaxValue -> T -static readonly Silk.NET.Maths.Scalar.MinusOne -> T -static readonly Silk.NET.Maths.Scalar.MinusTwo -> T -static readonly Silk.NET.Maths.Scalar.MinValue -> T -static readonly Silk.NET.Maths.Scalar.NaN -> T -static readonly Silk.NET.Maths.Scalar.NegativeInfinity -> T -static readonly Silk.NET.Maths.Scalar.One -> T -static readonly Silk.NET.Maths.Scalar.Pi -> T -static readonly Silk.NET.Maths.Scalar.PiOver2 -> T -static readonly Silk.NET.Maths.Scalar.PositiveInfinity -> T -static readonly Silk.NET.Maths.Scalar.RadiansPerDegree -> T -static readonly Silk.NET.Maths.Scalar.Tau -> T -static readonly Silk.NET.Maths.Scalar.Two -> T -static readonly Silk.NET.Maths.Scalar.Zero -> T static Silk.NET.Maths.Box2D.operator !=(Silk.NET.Maths.Box2D value1, Silk.NET.Maths.Box2D value2) -> bool static Silk.NET.Maths.Box2D.operator ==(Silk.NET.Maths.Box2D value1, Silk.NET.Maths.Box2D value2) -> bool static Silk.NET.Maths.Box3D.operator !=(Silk.NET.Maths.Box3D value1, Silk.NET.Maths.Box3D value2) -> bool @@ -1348,70 +1329,6 @@ static Silk.NET.Maths.Ray3D.operator ==(Silk.NET.Maths.Ray3D value1, Silk. static Silk.NET.Maths.Rectangle.FromLTRB(T left, T top, T right, T bottom) -> Silk.NET.Maths.Rectangle static Silk.NET.Maths.Rectangle.operator !=(Silk.NET.Maths.Rectangle value1, Silk.NET.Maths.Rectangle value2) -> bool static Silk.NET.Maths.Rectangle.operator ==(Silk.NET.Maths.Rectangle value1, Silk.NET.Maths.Rectangle value2) -> bool -static Silk.NET.Maths.Scalar.Abs(T x) -> T -static Silk.NET.Maths.Scalar.Acos(T x) -> T -static Silk.NET.Maths.Scalar.Acosh(T x) -> T -static Silk.NET.Maths.Scalar.Add(T left, T right) -> T -static Silk.NET.Maths.Scalar.And(T left, T right) -> T -static Silk.NET.Maths.Scalar.As(TFrom val) -> TTo -static Silk.NET.Maths.Scalar.Asin(T x) -> T -static Silk.NET.Maths.Scalar.Asinh(T x) -> T -static Silk.NET.Maths.Scalar.Atan2(T y, T x) -> T -static Silk.NET.Maths.Scalar.Atan(T x) -> T -static Silk.NET.Maths.Scalar.Atanh(T x) -> T -static Silk.NET.Maths.Scalar.Cbrt(T x) -> T -static Silk.NET.Maths.Scalar.Ceiling(T x) -> T -static Silk.NET.Maths.Scalar.Cos(T x) -> T -static Silk.NET.Maths.Scalar.Cosh(T x) -> T -static Silk.NET.Maths.Scalar.DegreesToRadians(T degrees) -> T -static Silk.NET.Maths.Scalar.Divide(T left, T right) -> T -static Silk.NET.Maths.Scalar.Equal(T left, T right) -> bool -static Silk.NET.Maths.Scalar.Exp(T x) -> T -static Silk.NET.Maths.Scalar.Floor(T x) -> T -static Silk.NET.Maths.Scalar.GreaterThan(T left, T right) -> bool -static Silk.NET.Maths.Scalar.GreaterThanOrEqual(T left, T right) -> bool -static Silk.NET.Maths.Scalar.IEEERemainder(T x, T y) -> T -static Silk.NET.Maths.Scalar.IsFinite(T f) -> bool -static Silk.NET.Maths.Scalar.IsHardwareAccelerated.get -> bool -static Silk.NET.Maths.Scalar.IsInfinity(T f) -> bool -static Silk.NET.Maths.Scalar.IsNaN(T f) -> bool -static Silk.NET.Maths.Scalar.IsNegative(T f) -> bool -static Silk.NET.Maths.Scalar.IsNegativeInfinity(T f) -> bool -static Silk.NET.Maths.Scalar.IsNormal(T f) -> bool -static Silk.NET.Maths.Scalar.IsPositiveInfinity(T f) -> bool -static Silk.NET.Maths.Scalar.IsSubnormal(T f) -> bool -static Silk.NET.Maths.Scalar.LessThan(T left, T right) -> bool -static Silk.NET.Maths.Scalar.LessThanOrEqual(T left, T right) -> bool -static Silk.NET.Maths.Scalar.Log10(T x) -> T -static Silk.NET.Maths.Scalar.Log(T x) -> T -static Silk.NET.Maths.Scalar.Log(T x, T y) -> T -static Silk.NET.Maths.Scalar.Max(T x, T y) -> T -static Silk.NET.Maths.Scalar.Min(T x, T y) -> T -static Silk.NET.Maths.Scalar.Multiply(T left, T right) -> T -static Silk.NET.Maths.Scalar.Negate(T x) -> T -static Silk.NET.Maths.Scalar.Not(T value) -> T -static Silk.NET.Maths.Scalar.NotEqual(T left, T right) -> bool -static Silk.NET.Maths.Scalar.Or(T left, T right) -> T -static Silk.NET.Maths.Scalar.Pow(T x, T y) -> T -static Silk.NET.Maths.Scalar.RadiansToDegrees(T radians) -> T -static Silk.NET.Maths.Scalar.Reciprocal(T x) -> T -static Silk.NET.Maths.Scalar.RotateLeft(T value, int offset) -> T -static Silk.NET.Maths.Scalar.RotateRight(T value, int offset) -> T -static Silk.NET.Maths.Scalar.Round(T x) -> T -static Silk.NET.Maths.Scalar.Round(T x, int digits) -> T -static Silk.NET.Maths.Scalar.Round(T x, int digits, System.MidpointRounding mode) -> T -static Silk.NET.Maths.Scalar.Round(T x, System.MidpointRounding mode) -> T -static Silk.NET.Maths.Scalar.ShiftLeft(T value, int offset) -> T -static Silk.NET.Maths.Scalar.ShiftRight(T value, int offset) -> T -static Silk.NET.Maths.Scalar.Sign(T x) -> int -static Silk.NET.Maths.Scalar.Sin(T x) -> T -static Silk.NET.Maths.Scalar.Sinh(T x) -> T -static Silk.NET.Maths.Scalar.Sqrt(T x) -> T -static Silk.NET.Maths.Scalar.Subtract(T left, T right) -> T -static Silk.NET.Maths.Scalar.Tan(T x) -> T -static Silk.NET.Maths.Scalar.Tanh(T x) -> T -static Silk.NET.Maths.Scalar.Truncate(T x) -> T -static Silk.NET.Maths.Scalar.Xor(T left, T right) -> T static Silk.NET.Maths.Sphere.operator !=(Silk.NET.Maths.Sphere value1, Silk.NET.Maths.Sphere value2) -> bool static Silk.NET.Maths.Sphere.operator ==(Silk.NET.Maths.Sphere value1, Silk.NET.Maths.Sphere value2) -> bool static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Matrix3x2 value) -> Silk.NET.Maths.Matrix3X2 diff --git a/sources/Maths/Maths/Quaternion.Old.cs b/sources/Maths/Maths/Quaternion.Old.cs index 9a4c29648b..cb9b41d5b9 100644 --- a/sources/Maths/Maths/Quaternion.Old.cs +++ b/sources/Maths/Maths/Quaternion.Old.cs @@ -43,10 +43,10 @@ public Quaternion(Vector3D vectorPart, T scalarPart) { Quaternion ans; - ans.X = Scalar.Add(value1.X, value2.X); - ans.Y = Scalar.Add(value1.Y, value2.Y); - ans.Z = Scalar.Add(value1.Z, value2.Z); - ans.W = Scalar.Add(value1.W, value2.W); + ans.X = value1.X + value2.X; + ans.Y = value1.Y + value2.Y; + ans.Z = value1.Z + value2.Z; + ans.W = value1.W + value2.W; return ans; } @@ -66,32 +66,28 @@ public Quaternion(Vector3D vectorPart, T scalarPart) //------------------------------------- // Inverse part. - T ls = Scalar.Add( - Scalar.Add( - Scalar.Add(Scalar.Multiply(value2.X, value2.X), Scalar.Multiply(value2.Y, value2.Y)), - Scalar.Multiply(value2.Z, value2.Z)), Scalar.Multiply(value2.W, value2.W)); - var invNorm = Scalar.Reciprocal(ls); + T ls = (value2.X * value2.X) + (value2.Y * value2.Y) + (value2.Z * value2.Z) + (value2.W * value2.W); + var invNorm = T.One / ls; - var q2x = Scalar.Negate(Scalar.Multiply(value2.X, invNorm)); - var q2y = Scalar.Negate(Scalar.Multiply(value2.Y, invNorm)); - var q2z = Scalar.Negate(Scalar.Multiply(value2.Z, invNorm)); - var q2w = Scalar.Multiply(value2.W, invNorm); + var q2x = -(value2.X * invNorm); + var q2y = -(value2.Y * invNorm); + var q2z = -(value2.Z * invNorm); + var q2w = value2.W * invNorm; //------------------------------------- // Multiply part. // cross(av, bv) - var cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); - var cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); - var cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); + var cx = (q1y * q2z) - (q1z * q2y); + var cy = (q1z * q2x) - (q1x * q2z); + var cz = (q1x * q2y) - (q1y * q2x); - var dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), - Scalar.Multiply(q1z, q2z)); + var dot = (q1x * q2x) + (q1y * q2y) + (q1z * q2z); - ans.X = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2w), Scalar.Multiply(q2x, q1w)), cx); - ans.Y = Scalar.Add(Scalar.Add(Scalar.Multiply(q1y, q2w), Scalar.Multiply(q2y, q1w)), cy); - ans.Z = Scalar.Add(Scalar.Add(Scalar.Multiply(q1z, q2w), Scalar.Multiply(q2z, q1w)), cz); - ans.W = Scalar.Subtract(Scalar.Multiply(q1w, q2w), dot); + ans.X = (q1x * q2w) + (q2x * q1w) + cx; + ans.Y = (q1y * q2w) + (q2y * q1w) + cy; + ans.Z = (q1z * q2w) + (q2z * q1w) + cz; + ans.W = (q1w * q2w) - dot; return ans; } @@ -115,17 +111,16 @@ public Quaternion(Vector3D vectorPart, T scalarPart) T q2w = value2.W; // cross(av, bv) - var cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); - var cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); - var cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); + var cx = (q1y * q2z) - (q1z * q2y); + var cy = (q1z * q2x) - (q1x * q2z); + var cz = (q1x * q2y) - (q1y * q2x); - var dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), - Scalar.Multiply(q1z, q2z)); + var dot = (q1x * q2x) + (q1y * q2y) + (q1z * q2z); - ans.X = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2w), Scalar.Multiply(q2x, q1w)), cx); - ans.Y = Scalar.Add(Scalar.Add(Scalar.Multiply(q1y, q2w), Scalar.Multiply(q2y, q1w)), cy); - ans.Z = Scalar.Add(Scalar.Add(Scalar.Multiply(q1z, q2w), Scalar.Multiply(q2z, q1w)), cz); - ans.W = Scalar.Subtract(Scalar.Multiply(q1w, q2w), dot); + ans.X = (q1x * q2w) + (q2x * q1w) + cx; + ans.Y = (q1y * q2w) + (q2y * q1w) + cy; + ans.Z = (q1z * q2w) + (q2z * q1w) + cz; + ans.W = (q1w * q2w) - dot; return ans; } @@ -138,10 +133,10 @@ public Quaternion(Vector3D vectorPart, T scalarPart) { Quaternion ans; - ans.X = Scalar.Multiply(value1.X, value2); - ans.Y = Scalar.Multiply(value1.Y, value2); - ans.Z = Scalar.Multiply(value1.Z, value2); - ans.W = Scalar.Multiply(value1.W, value2); + ans.X = value1.X * value2; + ans.Y = value1.Y * value2; + ans.Z = value1.Z * value2; + ans.W = value1.W * value2; return ans; } @@ -154,10 +149,10 @@ public Quaternion(Vector3D vectorPart, T scalarPart) { Quaternion ans; - ans.X = Scalar.Subtract(value1.X, value2.X); - ans.Y = Scalar.Subtract(value1.Y, value2.Y); - ans.Z = Scalar.Subtract(value1.Z, value2.Z); - ans.W = Scalar.Subtract(value1.W, value2.W); + ans.X = value1.X - value2.X; + ans.Y = value1.Y - value2.Y; + ans.Z = value1.Z - value2.Z; + ans.W = value1.W - value2.W; return ans; } @@ -169,10 +164,10 @@ public Quaternion(Vector3D vectorPart, T scalarPart) { Quaternion ans; - ans.X = Scalar.Negate(value.X); - ans.Y = Scalar.Negate(value.Y); - ans.Z = Scalar.Negate(value.Z); - ans.W = Scalar.Negate(value.W); + ans.X = -value.X; + ans.Y = -value.Y; + ans.Z = -value.Z; + ans.W = -value.W; return ans; } @@ -181,7 +176,7 @@ public Quaternion(Vector3D vectorPart, T scalarPart) /// The first source Quaternion. /// The second source Quaternion. /// The result of adding the Quaternions. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static Quaternion Add(Quaternion value1, Quaternion value2) => value1 + value2; @@ -206,17 +201,16 @@ public static Quaternion Concatenate(Quaternion value1, Quaternion valu T q2w = value1.W; // cross(av, bv) - var cx = Scalar.Subtract(Scalar.Multiply(q1y, q2z), Scalar.Multiply(q1z, q2y)); - var cy = Scalar.Subtract(Scalar.Multiply(q1z, q2x), Scalar.Multiply(q1x, q2z)); - var cz = Scalar.Subtract(Scalar.Multiply(q1x, q2y), Scalar.Multiply(q1y, q2x)); + var cx = (q1y * q2z) - (q1z * q2y); + var cy = (q1z * q2x) - (q1x * q2z); + var cz = (q1x * q2y) - (q1y * q2x); - var dot = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2x), Scalar.Multiply(q1y, q2y)), - Scalar.Multiply(q1z, q2z)); + var dot = (q1x * q2x) + (q1y * q2y) + (q1z * q2z); - ans.X = Scalar.Add(Scalar.Add(Scalar.Multiply(q1x, q2w), Scalar.Multiply(q2x, q1w)), cx); - ans.Y = Scalar.Add(Scalar.Add(Scalar.Multiply(q1y, q2w), Scalar.Multiply(q2y, q1w)), cy); - ans.Z = Scalar.Add(Scalar.Add(Scalar.Multiply(q1z, q2w), Scalar.Multiply(q2z, q1w)), cz); - ans.W = Scalar.Subtract(Scalar.Multiply(q1w, q2w), dot); + ans.X = (q1x * q2w) + (q2x * q1w) + cx; + ans.Y = (q1y * q2w) + (q2y * q1w) + cy; + ans.Z = (q1z * q2w) + (q2z * q1w) + cz; + ans.W = (q1w * q2w) - dot; return ans; } @@ -228,9 +222,9 @@ public static Quaternion Conjugate(Quaternion value) { Quaternion ans; - ans.X = Scalar.Negate(value.X); - ans.Y = Scalar.Negate(value.Y); - ans.Z = Scalar.Negate(value.Z); + ans.X = -value.X; + ans.Y = -value.Y; + ans.Z = -value.Z; ans.W = value.W; return ans; @@ -245,13 +239,13 @@ public static Quaternion CreateFromAxisAngle(Vector3D axis, T angle) { Quaternion ans; - var halfAngle = Scalar.Divide(angle, Scalar.Two); - var s = Scalar.Sin(halfAngle); - var c = Scalar.Cos(halfAngle); + var halfAngle = angle / T.CreateTruncating(2); + var s = T.Sin(halfAngle); + var c = T.Cos(halfAngle); - ans.X = Scalar.Multiply(axis.X, s); - ans.Y = Scalar.Multiply(axis.Y, s); - ans.Z = Scalar.Multiply(axis.Z, s); + ans.X = axis.X * s; + ans.Y = axis.Y * s; + ans.Z = axis.Z * s; ans.W = c; return ans; @@ -262,47 +256,47 @@ public static Quaternion CreateFromAxisAngle(Vector3D axis, T angle) /// The created Quaternion. public static Quaternion CreateFromRotationMatrix(Matrix4X4 matrix) { - var trace = Scalar.Add(Scalar.Add(matrix.M11, matrix.M22), matrix.M33); + var trace = matrix.M11 + matrix.M22 + matrix.M33; Quaternion q = default; - if (Scalar.GreaterThan(trace, Scalar.Zero)) + if (trace > T.Zero) { - var s = Scalar.Sqrt(Scalar.Add(trace, Scalar.One)); - q.W = Scalar.Divide(s, Scalar.Two); - s = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), s); - q.Y = Scalar.Multiply(Scalar.Subtract(matrix.M31, matrix.M13), s); - q.Z = Scalar.Multiply(Scalar.Subtract(matrix.M12, matrix.M21), s); + var s = T.Sqrt(trace + T.One); + q.W = s / T.CreateTruncating(2); + s = T.One / (T.CreateTruncating(2) * s); + q.X = (matrix.M23 - matrix.M32) * s; + q.Y = (matrix.M31 - matrix.M13) * s; + q.Z = (matrix.M12 - matrix.M21) * s; } else { - if (Scalar.GreaterThanOrEqual(matrix.M11, matrix.M22) && Scalar.GreaterThanOrEqual(matrix.M11, matrix.M33)) + if ((matrix.M11 >= matrix.M22) && (matrix.M11 >= matrix.M33)) { - var s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M11), matrix.M22), matrix.M33)); - var invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Divide(s, Scalar.Two); - q.Y = Scalar.Multiply(Scalar.Add(matrix.M12, matrix.M21), invS); - q.Z = Scalar.Multiply(Scalar.Add(matrix.M13, matrix.M31), invS); - q.W = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), invS); + var s = T.Sqrt(T.One + matrix.M11 - matrix.M22 - matrix.M33); + var invS = T.One / (T.CreateTruncating(2) * s); + q.X = s / T.CreateTruncating(2); + q.Y = (matrix.M12 + matrix.M21) * invS; + q.Z = (matrix.M13 + matrix.M31) * invS; + q.W = (matrix.M23 - matrix.M32) * invS; } - else if (Scalar.GreaterThan(matrix.M22, matrix.M33)) + else if (matrix.M22 > matrix.M33) { - var s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M22), matrix.M11), matrix.M33)); - var invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Multiply(Scalar.Add(matrix.M21, matrix.M12), invS); - q.Y = Scalar.Divide(s, Scalar.Two); - q.Z = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); - q.W = Scalar.Multiply(Scalar.Subtract(matrix.M31, matrix.M13), invS); + var s = T.Sqrt(T.One + matrix.M22 - matrix.M11 - matrix.M33); + var invS = T.One / (T.CreateTruncating(2) * s); + q.X = (matrix.M21 + matrix.M12) * invS; + q.Y = s / T.CreateTruncating(2); + q.Z = (matrix.M32 + matrix.M23) * invS; + q.W = (matrix.M31 - matrix.M13) * invS; } else { - var s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M33), matrix.M11), matrix.M22)); - var invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Multiply(Scalar.Add(matrix.M31, matrix.M13), invS); - q.Y = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); - q.Z = Scalar.Divide(s, Scalar.Two); - q.W = Scalar.Multiply(Scalar.Subtract(matrix.M12, matrix.M21), invS); + var s = T.Sqrt(T.One + matrix.M33 - matrix.M11 - matrix.M22); + var invS = T.One / (T.CreateTruncating(2) * s); + q.X = (matrix.M31 + matrix.M13) * invS; + q.Y = (matrix.M32 + matrix.M23) * invS; + q.Z = s / T.CreateTruncating(2); + q.W = (matrix.M12 - matrix.M21) * invS; } } @@ -314,47 +308,47 @@ public static Quaternion CreateFromRotationMatrix(Matrix4X4 matrix) /// The created Quaternion. public static Quaternion CreateFromRotationMatrix(Matrix3X3 matrix) { - var trace = Scalar.Add(Scalar.Add(matrix.M11, matrix.M22), matrix.M33); + var trace = matrix.M11 + matrix.M22 + matrix.M33; Quaternion q = default; - if (Scalar.GreaterThan(trace, Scalar.Zero)) + if (trace > T.Zero) { - var s = Scalar.Sqrt(Scalar.Add(trace, Scalar.One)); - q.W = Scalar.Divide(s, Scalar.Two); - s = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), s); - q.Y = Scalar.Multiply(Scalar.Subtract(matrix.M31, matrix.M13), s); - q.Z = Scalar.Multiply(Scalar.Subtract(matrix.M12, matrix.M21), s); + var s = T.Sqrt(trace + T.One); + q.W = s / T.CreateTruncating(2); + s = T.One / (T.CreateTruncating(2) * s); + q.X = (matrix.M23 - matrix.M32) * s; + q.Y = (matrix.M31 - matrix.M13) * s; + q.Z = (matrix.M12 - matrix.M21) * s; } else { - if (Scalar.GreaterThanOrEqual(matrix.M11, matrix.M22) && Scalar.GreaterThanOrEqual(matrix.M11, matrix.M33)) + if ((matrix.M11 >= matrix.M22) && (matrix.M11 >= matrix.M33)) { - var s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M11), matrix.M22), matrix.M33)); - var invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Divide(s, Scalar.Two); - q.Y = Scalar.Multiply(Scalar.Add(matrix.M12, matrix.M21), invS); - q.Z = Scalar.Multiply(Scalar.Add(matrix.M13, matrix.M31), invS); - q.W = Scalar.Multiply(Scalar.Subtract(matrix.M23, matrix.M32), invS); + var s = T.Sqrt(T.One + matrix.M11 - matrix.M22 - matrix.M33); + var invS = T.One / (T.CreateTruncating(2) * s); + q.X = s / T.CreateTruncating(2); + q.Y = (matrix.M12 + matrix.M21) * invS; + q.Z = (matrix.M13 + matrix.M31) * invS; + q.W = (matrix.M23 - matrix.M32) * invS; } - else if (Scalar.GreaterThan(matrix.M22, matrix.M33)) + else if (matrix.M22 > matrix.M33) { - var s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M22), matrix.M11), matrix.M33)); - var invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Multiply(Scalar.Add(matrix.M21, matrix.M12), invS); - q.Y = Scalar.Divide(s, Scalar.Two); - q.Z = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); - q.W = Scalar.Multiply(Scalar.Subtract(matrix.M31, matrix.M13), invS); + var s = T.Sqrt(T.One + matrix.M22 - matrix.M11 - matrix.M33); + var invS = T.One / (T.CreateTruncating(2) * s); + q.X = (matrix.M21 + matrix.M12) * invS; + q.Y = s / T.CreateTruncating(2); + q.Z = (matrix.M32 + matrix.M23) * invS; + q.W = (matrix.M31 - matrix.M13) * invS; } else { - var s = Scalar.Sqrt(Scalar.Subtract(Scalar.Subtract(Scalar.Add(Scalar.One, matrix.M33), matrix.M11), matrix.M22)); - var invS = Scalar.Reciprocal(Scalar.Multiply(Scalar.Two, s)); - q.X = Scalar.Multiply(Scalar.Add(matrix.M31, matrix.M13), invS); - q.Y = Scalar.Multiply(Scalar.Add(matrix.M32, matrix.M23), invS); - q.Z = Scalar.Divide(s, Scalar.Two); - q.W = Scalar.Multiply(Scalar.Subtract(matrix.M12, matrix.M21), invS); + var s = T.Sqrt(T.One + matrix.M33 - matrix.M11 - matrix.M22); + var invS = T.One / (T.CreateTruncating(2) * s); + q.X = (matrix.M31 + matrix.M13) * invS; + q.Y = (matrix.M32 + matrix.M23) * invS; + q.Z = s / T.CreateTruncating(2); + q.W = (matrix.M12 - matrix.M21) * invS; } } @@ -372,24 +366,24 @@ public static Quaternion CreateFromYawPitchRoll(T yaw, T pitch, T roll) // pitch upward, then yaw to face into the new heading T sr, cr, sp, cp, sy, cy; - var halfRoll = Scalar.Divide(roll, Scalar.Two); - sr = Scalar.Sin(halfRoll); - cr = Scalar.Cos(halfRoll); + var halfRoll = roll / T.CreateTruncating(2); + sr = T.Sin(halfRoll); + cr = T.Cos(halfRoll); - var halfPitch = Scalar.Divide(pitch, Scalar.Two); - sp = Scalar.Sin(halfPitch); - cp = Scalar.Cos(halfPitch); + var halfPitch = pitch / T.CreateTruncating(2); + sp = T.Sin(halfPitch); + cp = T.Cos(halfPitch); - var halfYaw = Scalar.Divide(yaw, Scalar.Two); - sy = Scalar.Sin(halfYaw); - cy = Scalar.Cos(halfYaw); + var halfYaw = yaw / T.CreateTruncating(2); + sy = T.Sin(halfYaw); + cy = T.Cos(halfYaw); Quaternion result; - result.X = Scalar.Add(Scalar.Multiply(Scalar.Multiply(cy, sp), cr), Scalar.Multiply(Scalar.Multiply(sy, cp), sr)); - result.Y = Scalar.Subtract(Scalar.Multiply(Scalar.Multiply(sy, cp), cr), Scalar.Multiply(Scalar.Multiply(cy, sp), sr)); - result.Z = Scalar.Subtract(Scalar.Multiply(Scalar.Multiply(cy, cp), sr), Scalar.Multiply(Scalar.Multiply(sy, sp), cr)); - result.W = Scalar.Add(Scalar.Multiply(Scalar.Multiply(cy, cp), cr), Scalar.Multiply(Scalar.Multiply(sy, sp), sr)); + result.X = (cy * sp * cr) + (sy * cp * sr); + result.Y = (sy * cp * cr) - (cy * sp * sr); + result.Z = (cy * cp * sr) - (sy * sp * cr); + result.W = (cy * cp * cr) + (sy * sp * sr); return result; } @@ -398,7 +392,7 @@ public static Quaternion CreateFromYawPitchRoll(T yaw, T pitch, T roll) /// The source Quaternion. /// The divisor. /// The result of the division. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static Quaternion Divide(Quaternion value1, Quaternion value2) => value1 / value2; @@ -408,10 +402,10 @@ public static Quaternion Divide(Quaternion value1, Quaternion value2) /// The dot product of the Quaternions. public static T Dot(Quaternion quaternion1, Quaternion quaternion2) { - return Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(quaternion1.X, quaternion2.X), - Scalar.Multiply(quaternion1.Y, quaternion2.Y)), - Scalar.Multiply(quaternion1.Z, quaternion2.Z)), - Scalar.Multiply(quaternion1.W, quaternion2.W)); + return (quaternion1.X * quaternion2.X) + + (quaternion1.Y * quaternion2.Y) + + (quaternion1.Z * quaternion2.Z) + + (quaternion1.W * quaternion2.W); } /// Returns the inverse of a Quaternion. @@ -425,13 +419,13 @@ public static Quaternion Inverse(Quaternion value) Quaternion ans; - T ls = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, value.X), Scalar.Multiply(value.Y, value.Y)), Scalar.Multiply(value.Z, value.Z)), Scalar.Multiply(value.W, value.W)); - var invNorm = Scalar.Reciprocal(ls); + T ls = (value.X * value.X) + (value.Y * value.Y) + (value.Z * value.Z) + (value.W * value.W); + var invNorm = T.One / ls; - ans.X = Scalar.Negate(Scalar.Multiply(value.X, invNorm)); - ans.Y = Scalar.Negate(Scalar.Multiply(value.Y, invNorm)); - ans.Z = Scalar.Negate(Scalar.Multiply(value.Z, invNorm)); - ans.W = Scalar.Multiply(value.W, invNorm); + ans.X = -(value.X * invNorm); + ans.Y = -(value.Y * invNorm); + ans.Z = -(value.Z * invNorm); + ans.W = value.W * invNorm; return ans; } @@ -444,40 +438,38 @@ public static Quaternion Inverse(Quaternion value) public static Quaternion Lerp(Quaternion quaternion1, Quaternion quaternion2, T amount) { var t = amount; - var t1 = Scalar.Subtract(Scalar.One, t); + var t1 = T.One - t; Quaternion r = default; - T dot = Scalar.Add( - Scalar.Add( - Scalar.Add(Scalar.Multiply(quaternion1.X, quaternion2.X), - Scalar.Multiply(quaternion1.Y, quaternion2.Y)), - Scalar.Multiply(quaternion1.Z, quaternion2.Z)), - Scalar.Multiply(quaternion1.W, quaternion2.W)); + T dot = (quaternion1.X * quaternion2.X) + + (quaternion1.Y * quaternion2.Y) + + (quaternion1.Z * quaternion2.Z) + + (quaternion1.W * quaternion2.W); - if (Scalar.GreaterThanOrEqual(dot, Scalar.Zero)) + if (dot >= T.Zero) { - r.X = Scalar.Add(Scalar.Multiply(t1, quaternion1.X), Scalar.Multiply(t, quaternion2.X)); - r.Y = Scalar.Add(Scalar.Multiply(t1, quaternion1.Y), Scalar.Multiply(t, quaternion2.Y)); - r.Z = Scalar.Add(Scalar.Multiply(t1, quaternion1.Z), Scalar.Multiply(t, quaternion2.Z)); - r.W = Scalar.Add(Scalar.Multiply(t1, quaternion1.W), Scalar.Multiply(t, quaternion2.W)); + r.X = (t1 * quaternion1.X) + (t * quaternion2.X); + r.Y = (t1 * quaternion1.Y) + (t * quaternion2.Y); + r.Z = (t1 * quaternion1.Z) + (t * quaternion2.Z); + r.W = (t1 * quaternion1.W) + (t * quaternion2.W); } else { - r.X = Scalar.Subtract(Scalar.Multiply(t1, quaternion1.X), Scalar.Multiply(t, quaternion2.X)); - r.Y = Scalar.Subtract(Scalar.Multiply(t1, quaternion1.Y), Scalar.Multiply(t, quaternion2.Y)); - r.Z = Scalar.Subtract(Scalar.Multiply(t1, quaternion1.Z), Scalar.Multiply(t, quaternion2.Z)); - r.W = Scalar.Subtract(Scalar.Multiply(t1, quaternion1.W), Scalar.Multiply(t, quaternion2.W)); + r.X = (t1 * quaternion1.X) - (t * quaternion2.X); + r.Y = (t1 * quaternion1.Y) - (t * quaternion2.Y); + r.Z = (t1 * quaternion1.Z) - (t * quaternion2.Z); + r.W = (t1 * quaternion1.W) - (t * quaternion2.W); } // Normalize it. - T ls = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(r.X, r.X), Scalar.Multiply(r.Y, r.Y)), Scalar.Multiply(r.Z, r.Z)), Scalar.Multiply(r.W, r.W)); - var invNorm = Scalar.Reciprocal(Scalar.Sqrt(ls)); + T ls = (r.X * r.X) + (r.Y * r.Y) + (r.Z * r.Z) + (r.W * r.W); + var invNorm = T.One / T.Sqrt(ls); - r.X = Scalar.Multiply(r.X, invNorm); - r.Y = Scalar.Multiply(r.Y, invNorm); - r.Z = Scalar.Multiply(r.Z, invNorm); - r.W = Scalar.Multiply(r.W, invNorm); + r.X = r.X * invNorm; + r.Y = r.Y * invNorm; + r.Z = r.Z * invNorm; + r.W = r.W * invNorm; return r; } @@ -486,7 +478,7 @@ public static Quaternion Lerp(Quaternion quaternion1, Quaternion quater /// The Quaternion on the left side of the multiplication. /// The Quaternion on the right side of the multiplication. /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static Quaternion Multiply(Quaternion value1, Quaternion value2) => value1 * value2; @@ -494,14 +486,14 @@ public static Quaternion Multiply(Quaternion value1, Quaternion value2) /// The source Quaternion. /// The scalar value. /// The result of the multiplication. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static Quaternion Multiply(Quaternion value1, T value2) => value1 * value2; /// Flips the sign of each component of the quaternion. /// The source Quaternion. /// The negated Quaternion. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static Quaternion Negate(Quaternion value) => -value; @@ -512,13 +504,13 @@ public static Quaternion Normalize(Quaternion value) { Quaternion ans; - T ls = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(value.X, value.X), Scalar.Multiply(value.Y, value.Y)), Scalar.Multiply(value.Z, value.Z)), Scalar.Multiply(value.W, value.W)); - var invNorm = Scalar.Reciprocal(Scalar.Sqrt(ls)); + T ls = (value.X * value.X) + (value.Y * value.Y) + (value.Z * value.Z) + (value.W * value.W); + var invNorm = T.One / T.Sqrt(ls); - ans.X = Scalar.Multiply(value.X, invNorm); - ans.Y = Scalar.Multiply(value.Y, invNorm); - ans.Z = Scalar.Multiply(value.Z, invNorm); - ans.W = Scalar.Multiply(value.W, invNorm); + ans.X = value.X * invNorm; + ans.Y = value.Y * invNorm; + ans.Z = value.Z * invNorm; + ans.W = value.W * invNorm; return ans; } @@ -532,41 +524,41 @@ public static Quaternion Slerp(Quaternion quaternion1, Quaternion quate { var t = amount; - T cosOmega = Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(quaternion1.X, quaternion2.X), Scalar.Multiply(quaternion1.Y, quaternion2.Y)), Scalar.Multiply(quaternion1.Z, quaternion2.Z)), Scalar.Multiply(quaternion1.W, quaternion2.W)); + T cosOmega = (quaternion1.X * quaternion2.X) + (quaternion1.Y * quaternion2.Y) + (quaternion1.Z * quaternion2.Z) + (quaternion1.W * quaternion2.W); var flip = false; - if (!Scalar.GreaterThanOrEqual(cosOmega, Scalar.Zero)) + if (!(cosOmega >= T.Zero)) { flip = true; - cosOmega = Scalar.Negate(cosOmega); + cosOmega = -cosOmega; } T s1, s2; - if (Scalar.GreaterThan(cosOmega, Scalar.Subtract(Scalar.One, Scalar.As(SlerpEpsilon)))) + if (cosOmega > T.One - T.CreateTruncating(SlerpEpsilon)) { // Too close, do straight linear interpolation. - s1 = Scalar.Subtract(Scalar.One, t); - s2 = flip ? Scalar.Negate(t) : t; + s1 = T.One - t; + s2 = flip ? -t : t; } else { - var omega = Scalar.Acos(cosOmega); - var invSinOmega = Scalar.Reciprocal(Scalar.Sin(omega)); + var omega = T.Acos(cosOmega); + var invSinOmega = T.One / T.Sin(omega); - s1 = Scalar.Multiply(Scalar.Sin(Scalar.Multiply(Scalar.Subtract(Scalar.One, t), omega)), invSinOmega); + s1 = T.Sin((T.One - t) * omega) * invSinOmega; s2 = flip - ? Scalar.Negate(Scalar.Multiply(Scalar.Sin(Scalar.Multiply(t, omega)), invSinOmega)) - : Scalar.Multiply(Scalar.Sin(Scalar.Multiply(t, omega)), invSinOmega); + ? -T.Sin(t * omega) * invSinOmega + : T.Sin(t * omega) * invSinOmega; } Quaternion ans; - ans.X = Scalar.Add(Scalar.Multiply(s1, quaternion1.X), Scalar.Multiply(s2, quaternion2.X)); - ans.Y = Scalar.Add(Scalar.Multiply(s1, quaternion1.Y), Scalar.Multiply(s2, quaternion2.Y)); - ans.Z = Scalar.Add(Scalar.Multiply(s1, quaternion1.Z), Scalar.Multiply(s2, quaternion2.Z)); - ans.W = Scalar.Add(Scalar.Multiply(s1, quaternion1.W), Scalar.Multiply(s2, quaternion2.W)); + ans.X = (s1 * quaternion1.X) + (s2 * quaternion2.X); + ans.Y = (s1 * quaternion1.Y) + (s2 * quaternion2.Y); + ans.Z = (s1 * quaternion1.Z) + (s2 * quaternion2.Z); + ans.W = (s1 * quaternion1.W) + (s2 * quaternion2.W); return ans; } @@ -575,19 +567,19 @@ public static Quaternion Slerp(Quaternion quaternion1, Quaternion quate /// The first source Quaternion. /// The second Quaternion, to be subtracted from the first. /// The result of the subtraction. - [MethodImpl((MethodImplOptions) 768)] + [MethodImpl((MethodImplOptions)768)] public static Quaternion Subtract(Quaternion value1, Quaternion value2) => value1 - value2; /// Calculates the length of the Quaternion. /// The computed length of the Quaternion. public readonly T Length() - => Scalar.Sqrt(LengthSquared()); + => T.Sqrt(LengthSquared()); /// Calculates the length squared of the Quaternion. This operation is cheaper than Length(). /// The length squared of the Quaternion. public readonly T LengthSquared() - => Scalar.Add(Scalar.Add(Scalar.Add(Scalar.Multiply(X, X), Scalar.Multiply(Y, Y)), Scalar.Multiply(Z, Z)), Scalar.Multiply(W, W)); + => (X * X) + (Y * Y) + (Z * Z) + (W * W); /// Returns a String representing this Quaternion instance. /// The string representation. @@ -602,8 +594,8 @@ public override readonly string ToString() /// The source matrix /// The matrix public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); + => new(Half.CreateTruncating(from.X), Half.CreateTruncating(from.Y), Half.CreateTruncating(from.Z), + Half.CreateTruncating(from.W)); /// /// Converts a into one with a of @@ -611,8 +603,8 @@ public static explicit operator Quaternion(Quaternion from) /// The source matrix /// The matrix public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); + => new(float.CreateTruncating(from.X), float.CreateTruncating(from.Y), float.CreateTruncating(from.Z), + float.CreateTruncating(from.W)); /// /// Converts a into @@ -620,8 +612,8 @@ public static explicit operator Quaternion(Quaternion from) /// The source quaternion /// The quaternion public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); + => new(float.CreateTruncating(from.X), float.CreateTruncating(from.Y), float.CreateTruncating(from.Z), + float.CreateTruncating(from.W)); /// /// Converts a into one with a of @@ -629,8 +621,8 @@ public static explicit operator Quaternion(Quaternion from) /// The source matrix /// The matrix public static explicit operator Quaternion(Quaternion from) - => new(Scalar.As(from.X), Scalar.As(from.Y), Scalar.As(from.Z), - Scalar.As(from.W)); + => new(double.CreateTruncating(from.X), double.CreateTruncating(from.Y), double.CreateTruncating(from.Z), + double.CreateTruncating(from.W)); /// /// Returns this quaternion casted to @@ -639,7 +631,7 @@ public static explicit operator Quaternion(Quaternion from) /// The casted quaternion public Quaternion As() where TOther : ITrigonometricFunctions { - return new(Scalar.As(X), Scalar.As(Y), Scalar.As(Z), Scalar.As(W)); + return new(TOther.CreateTruncating(X), TOther.CreateTruncating(Y), TOther.CreateTruncating(Z), TOther.CreateTruncating(W)); } } } diff --git a/sources/Maths/Maths/Quaternion.cs b/sources/Maths/Maths/Quaternion.cs index 16f3b69527..da901aad05 100644 --- a/sources/Maths/Maths/Quaternion.cs +++ b/sources/Maths/Maths/Quaternion.cs @@ -63,7 +63,7 @@ public Quaternion(T x, T y, T z, T w) // TODO: Vector4F/Vector3F constructors /// Returns a representing no rotation. - public static Quaternion Identity { get; } = new Quaternion(Scalar.Zero, Scalar.Zero, Scalar.Zero, Scalar.One); + public static Quaternion Identity { get; } = new Quaternion(T.Zero, T.Zero, T.Zero, T.One); /// Returns a boolean indicating whether the given Object is equal to this instance. public override bool Equals(object? obj) => diff --git a/sources/Maths/Maths/Rectangle.cs b/sources/Maths/Maths/Rectangle.cs index 86198c30b8..ff84de0d20 100644 --- a/sources/Maths/Maths/Rectangle.cs +++ b/sources/Maths/Maths/Rectangle.cs @@ -21,6 +21,7 @@ public struct Rectangle /// [DataMember] public Vector2D Origin; + /// /// The size. /// @@ -88,7 +89,7 @@ public Rectangle(T originX, T originY, T sizeX, T sizeY) /// Half the size of this rectangle. /// [IgnoreDataMember] - public Vector2D HalfSize => Size / Scalar.Two; + public Vector2D HalfSize => Size / T.CreateTruncating(2); /// /// Calculates whether this rectangle contains a point. @@ -99,8 +100,8 @@ public Rectangle(T originX, T originY, T sizeX, T sizeY) public bool Contains(Vector2D point) { var max = Max; - return Scalar.GreaterThanOrEqual(point.X, Origin.X) && Scalar.GreaterThanOrEqual - (point.Y, Origin.Y) && Scalar.LessThanOrEqual(point.X, max.X) && Scalar.LessThanOrEqual(point.Y, max.Y); + return (point.X >= Origin.X) && (point.Y >= Origin.Y) + && (point.X <= max.X) && (point.Y <= max.Y); } /// @@ -113,9 +114,8 @@ public bool Contains(Rectangle other) { var tMax = this.Max; var oMax = other.Max; - return Scalar.GreaterThanOrEqual(other.Origin.X, this.Origin.X) && Scalar.GreaterThanOrEqual - (other.Origin.Y, this.Origin.Y) && Scalar.LessThanOrEqual(oMax.X, tMax.X) && Scalar.LessThanOrEqual - (oMax.Y, tMax.Y); + return (other.Origin.X >= this.Origin.X) && (other.Origin.Y >= this.Origin.Y) + && (oMax.X <= tMax.X) && (oMax.Y <= tMax.Y); } /// @@ -126,9 +126,9 @@ public bool Contains(Rectangle other) public T GetDistanceToNearestEdge(Vector2D point) { var max = Max; - var dx = Scalar.Max(Scalar.Max(Scalar.Subtract(Origin.X, point.X), Scalar.Zero), Scalar.Subtract(point.X, max.X)); - var dy = Scalar.Max(Scalar.Max(Scalar.Subtract(Origin.Y, point.Y), Scalar.Zero), Scalar.Subtract(point.Y, max.Y)); - return Scalar.Sqrt(Scalar.Add(Scalar.Multiply(dx, dx), Scalar.Multiply(dy, dy))); + var dx = T.Max(T.Max(Origin.X - point.X, T.Zero), point.X - max.X); + var dy = T.Max(T.Max(Origin.Y - point.Y, T.Zero), point.Y - max.Y); + return T.Sqrt((dx * dx) + (dy * dy)); } /// @@ -153,7 +153,7 @@ public Rectangle GetScaled(Vector2D scale, Vector2D anchor) var max = (scale * (Max - anchor)) + anchor; return new(min, max - min); } - + /// /// Calculates a new rectangle scaled by the given scale around the given anchor. /// diff --git a/sources/Maths/Maths/Scalar.As.cs b/sources/Maths/Maths/Scalar.As.cs deleted file mode 100644 index 077f4a2239..0000000000 --- a/sources/Maths/Maths/Scalar.As.cs +++ /dev/null @@ -1,3184 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/* - -This file is automatically generated by T4 template - -*/ - - -using System; -using System.Runtime.CompilerServices; -using System.Numerics; - -// casting into non-nullable, unboxing from nullable -#pragma warning disable 8600 -#pragma warning disable 8605 - - -namespace Silk.NET.Maths -{ - /// - /// A collection of operations for working with scalar numeric values. - /// Includes methods like the ones found in and more. - /// Supports , , , , , , , , , , , , , - /// - /// - public partial class Scalar - { - /// - /// Convert from to - /// - /// The value to convert - /// The type converted from - /// The type converted into - /// - /// While in most cases the types can be just explicitly casted, - /// sometimes there is an intermediate cast to float or double. - /// - /// - /// In case of we only consider the real part. - /// - /// The converted value - [MethodImpl(MaxOpt)] - public static TTo As(TFrom val) where TFrom : notnull where TTo : notnull - { - // We rejigged this code a bit to be a bit more strategic about its specialization branch as to not - // exceed RyuJIT's inlining/codegen budgets. In doing this, Mono apparently started producing invalid - // arm assembly, so we now maintain two paths: one for Mono, and one for CoreCLR. The CoreCLR one should - // really be preferred. -#if ANDROID || IOS - - return FromHalfToHalf(val); - - - [MethodImpl(MaxOpt)] - static TTo FromHalfToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (Half) (object) val; - } - - return FromHalfToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (Half) (object) val; - } - - return FromHalfToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (Half) (object) val; - } - - return FromHalfToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (float) (Half) (object) val; - } - - return FromHalfToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (Half) (object) val; - } - - return FromHalfToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToByte(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (Half) (object) val; - } - - return FromHalfToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToShort(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (Half) (object) val; - } - - return FromHalfToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (Half) (object) val; - } - - return FromHalfToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToInt(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (Half) (object) val; - } - - return FromHalfToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (Half) (object) val; - } - - return FromHalfToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToLong(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (Half) (object) val; - } - - return FromHalfToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToULong(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (Half) (object) val; - } - - return FromHalfToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (float) (Half) (object) val; - } - - return FromHalfToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalfToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(Half) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (float) (Half) (object) val; - } - - return FromFloatToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (float) (object) val; - } - - return FromFloatToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (float) (object) val; - } - - return FromFloatToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (float) (object) val; - } - - return FromFloatToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (float) (object) val; - } - - return FromFloatToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (float) (object) val; - } - - return FromFloatToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToByte(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (float) (object) val; - } - - return FromFloatToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToShort(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (float) (object) val; - } - - return FromFloatToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (float) (object) val; - } - - return FromFloatToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToInt(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (float) (object) val; - } - - return FromFloatToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (float) (object) val; - } - - return FromFloatToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToLong(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (float) (object) val; - } - - return FromFloatToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToULong(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (float) (object) val; - } - - return FromFloatToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (float) (object) val; - } - - return FromFloatToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloatToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(float) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (float) (object) val; - } - - return FromDoubleToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (double) (object) val; - } - - return FromDoubleToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (double) (object) val; - } - - return FromDoubleToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (double) (object) val; - } - - return FromDoubleToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (double) (object) val; - } - - return FromDoubleToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (double) (object) val; - } - - return FromDoubleToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToByte(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (double) (object) val; - } - - return FromDoubleToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToShort(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (double) (object) val; - } - - return FromDoubleToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (double) (object) val; - } - - return FromDoubleToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToInt(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (double) (object) val; - } - - return FromDoubleToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (double) (object) val; - } - - return FromDoubleToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToLong(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (double) (object) val; - } - - return FromDoubleToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToULong(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (double) (object) val; - } - - return FromDoubleToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (double) (object) val; - } - - return FromDoubleToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDoubleToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(double) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (double) (object) val; - } - - return FromDecimalToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (double) (decimal) (object) val; - } - - return FromDecimalToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (decimal) (object) val; - } - - return FromDecimalToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (decimal) (object) val; - } - - return FromDecimalToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (decimal) (object) val; - } - - return FromDecimalToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (decimal) (object) val; - } - - return FromDecimalToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToByte(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (decimal) (object) val; - } - - return FromDecimalToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToShort(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (decimal) (object) val; - } - - return FromDecimalToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (decimal) (object) val; - } - - return FromDecimalToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToInt(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (decimal) (object) val; - } - - return FromDecimalToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (decimal) (object) val; - } - - return FromDecimalToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToLong(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (decimal) (object) val; - } - - return FromDecimalToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToULong(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (decimal) (object) val; - } - - return FromDecimalToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (decimal) (object) val; - } - - return FromDecimalToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimalToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(decimal) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (decimal) (object) val; - } - - return FromSByteToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (sbyte) (object) val; - } - - return FromSByteToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (sbyte) (object) val; - } - - return FromSByteToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (sbyte) (object) val; - } - - return FromSByteToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (sbyte) (object) val; - } - - return FromSByteToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (sbyte) (object) val; - } - - return FromSByteToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToByte(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (sbyte) (object) val; - } - - return FromSByteToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToShort(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (sbyte) (object) val; - } - - return FromSByteToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (sbyte) (object) val; - } - - return FromSByteToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToInt(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (sbyte) (object) val; - } - - return FromSByteToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (sbyte) (object) val; - } - - return FromSByteToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToLong(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (sbyte) (object) val; - } - - return FromSByteToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToULong(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (sbyte) (object) val; - } - - return FromSByteToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (sbyte) (object) val; - } - - return FromSByteToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByteToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(sbyte) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (sbyte) (object) val; - } - - return FromByteToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (byte) (object) val; - } - - return FromByteToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (byte) (object) val; - } - - return FromByteToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (byte) (object) val; - } - - return FromByteToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (byte) (object) val; - } - - return FromByteToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (byte) (object) val; - } - - return FromByteToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToByte(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (byte) (object) val; - } - - return FromByteToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToShort(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (byte) (object) val; - } - - return FromByteToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (byte) (object) val; - } - - return FromByteToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToInt(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (byte) (object) val; - } - - return FromByteToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (byte) (object) val; - } - - return FromByteToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToLong(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (byte) (object) val; - } - - return FromByteToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToULong(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (byte) (object) val; - } - - return FromByteToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (byte) (object) val; - } - - return FromByteToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByteToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(byte) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (byte) (object) val; - } - - return FromShortToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (short) (object) val; - } - - return FromShortToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (short) (object) val; - } - - return FromShortToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (short) (object) val; - } - - return FromShortToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (short) (object) val; - } - - return FromShortToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (short) (object) val; - } - - return FromShortToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToByte(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (short) (object) val; - } - - return FromShortToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToShort(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (short) (object) val; - } - - return FromShortToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (short) (object) val; - } - - return FromShortToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToInt(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (short) (object) val; - } - - return FromShortToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (short) (object) val; - } - - return FromShortToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToLong(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (short) (object) val; - } - - return FromShortToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToULong(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (short) (object) val; - } - - return FromShortToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (short) (object) val; - } - - return FromShortToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShortToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(short) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (short) (object) val; - } - - return FromUShortToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (ushort) (object) val; - } - - return FromUShortToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (ushort) (object) val; - } - - return FromUShortToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (ushort) (object) val; - } - - return FromUShortToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (ushort) (object) val; - } - - return FromUShortToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (ushort) (object) val; - } - - return FromUShortToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToByte(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (ushort) (object) val; - } - - return FromUShortToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToShort(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (ushort) (object) val; - } - - return FromUShortToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (ushort) (object) val; - } - - return FromUShortToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToInt(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (ushort) (object) val; - } - - return FromUShortToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (ushort) (object) val; - } - - return FromUShortToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToLong(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (ushort) (object) val; - } - - return FromUShortToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToULong(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (ushort) (object) val; - } - - return FromUShortToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (ushort) (object) val; - } - - return FromUShortToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShortToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(ushort) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (ushort) (object) val; - } - - return FromIntToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (int) (object) val; - } - - return FromIntToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (int) (object) val; - } - - return FromIntToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (int) (object) val; - } - - return FromIntToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (int) (object) val; - } - - return FromIntToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (int) (object) val; - } - - return FromIntToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToByte(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (int) (object) val; - } - - return FromIntToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToShort(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (int) (object) val; - } - - return FromIntToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (int) (object) val; - } - - return FromIntToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToInt(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (int) (object) val; - } - - return FromIntToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (int) (object) val; - } - - return FromIntToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToLong(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (int) (object) val; - } - - return FromIntToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToULong(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (int) (object) val; - } - - return FromIntToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (int) (object) val; - } - - return FromIntToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromIntToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(int) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (int) (object) val; - } - - return FromUIntToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (uint) (object) val; - } - - return FromUIntToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (uint) (object) val; - } - - return FromUIntToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (uint) (object) val; - } - - return FromUIntToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (uint) (object) val; - } - - return FromUIntToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (uint) (object) val; - } - - return FromUIntToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToByte(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (uint) (object) val; - } - - return FromUIntToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToShort(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (uint) (object) val; - } - - return FromUIntToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (uint) (object) val; - } - - return FromUIntToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToInt(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (uint) (object) val; - } - - return FromUIntToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (uint) (object) val; - } - - return FromUIntToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToLong(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (uint) (object) val; - } - - return FromUIntToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToULong(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (uint) (object) val; - } - - return FromUIntToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (uint) (object) val; - } - - return FromUIntToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUIntToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(uint) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (uint) (object) val; - } - - return FromLongToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (long) (object) val; - } - - return FromLongToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (long) (object) val; - } - - return FromLongToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (long) (object) val; - } - - return FromLongToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (long) (object) val; - } - - return FromLongToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (long) (object) val; - } - - return FromLongToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToByte(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (long) (object) val; - } - - return FromLongToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToShort(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (long) (object) val; - } - - return FromLongToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (long) (object) val; - } - - return FromLongToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToInt(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (long) (object) val; - } - - return FromLongToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (long) (object) val; - } - - return FromLongToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToLong(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (long) (object) val; - } - - return FromLongToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToULong(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (long) (object) val; - } - - return FromLongToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (long) (object) val; - } - - return FromLongToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLongToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(long) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (long) (object) val; - } - - return FromULongToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (ulong) (object) val; - } - - return FromULongToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (ulong) (object) val; - } - - return FromULongToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (ulong) (object) val; - } - - return FromULongToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (ulong) (object) val; - } - - return FromULongToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (ulong) (object) val; - } - - return FromULongToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToByte(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (ulong) (object) val; - } - - return FromULongToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToShort(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (ulong) (object) val; - } - - return FromULongToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (ulong) (object) val; - } - - return FromULongToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToInt(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (ulong) (object) val; - } - - return FromULongToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (ulong) (object) val; - } - - return FromULongToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToLong(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (ulong) (object) val; - } - - return FromULongToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToULong(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (ulong) (object) val; - } - - return FromULongToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (ulong) (object) val; - } - - return FromULongToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULongToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(ulong) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (ulong) (object) val; - } - - return FromComplexToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (double) ((Complex) (object) val).Real; - } - - return FromComplexToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) ((Complex) (object) val).Real; - } - - return FromComplexToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) ((Complex) (object) val).Real; - } - - return FromComplexToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) ((Complex) (object) val).Real; - } - - return FromComplexToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) ((Complex) (object) val).Real; - } - - return FromComplexToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToByte(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) ((Complex) (object) val).Real; - } - - return FromComplexToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToShort(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) ((Complex) (object) val).Real; - } - - return FromComplexToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) ((Complex) (object) val).Real; - } - - return FromComplexToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToInt(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) ((Complex) (object) val).Real; - } - - return FromComplexToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) ((Complex) (object) val).Real; - } - - return FromComplexToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToLong(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) ((Complex) (object) val).Real; - } - - return FromComplexToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToULong(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) ((Complex) (object) val).Real; - } - - return FromComplexToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) ((Complex) (object) val).Real; - } - - return FromComplexToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplexToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(Complex) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) ((Complex) (object) val).Real; - } - - return FromBigIntegerToHalf(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToHalf(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (double) (BigInteger) (object) val; - } - - return FromBigIntegerToFloat(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToFloat(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) (BigInteger) (object) val; - } - - return FromBigIntegerToDouble(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToDouble(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) (BigInteger) (object) val; - } - - return FromBigIntegerToDecimal(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToDecimal(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (BigInteger) (object) val; - } - - return FromBigIntegerToSByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToSByte(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) (BigInteger) (object) val; - } - - return FromBigIntegerToByte(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToByte(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) (BigInteger) (object) val; - } - - return FromBigIntegerToShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToShort(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) (BigInteger) (object) val; - } - - return FromBigIntegerToUShort(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToUShort(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) (BigInteger) (object) val; - } - - return FromBigIntegerToInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToInt(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) (BigInteger) (object) val; - } - - return FromBigIntegerToUInt(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToUInt(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) (BigInteger) (object) val; - } - - return FromBigIntegerToLong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToLong(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) (BigInteger) (object) val; - } - - return FromBigIntegerToULong(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToULong(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) (BigInteger) (object) val; - } - - return FromBigIntegerToComplex(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToComplex(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (BigInteger) (object) val; - } - - return FromBigIntegerToBigInteger(val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigIntegerToBigInteger(TFrom val) - { - if (typeof(TFrom) == typeof(BigInteger) && typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (BigInteger) (object) val; - } - - ThrowUnsupportedType(); - return default!; - } -#else - if (typeof(TFrom) == typeof(Half)) - { - return FromHalf((Half) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromHalf(Half val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) (float) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) (float) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) (float) val; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(float)) - { - return FromFloat((float) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromFloat(float val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(double)) - { - return FromDouble((double) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDouble(double val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(decimal)) - { - return FromDecimal((decimal) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromDecimal(decimal val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (double) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(sbyte)) - { - return FromSByte((sbyte) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromSByte(sbyte val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(byte)) - { - return FromByte((byte) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromByte(byte val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(short)) - { - return FromShort((short) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromShort(short val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(ushort)) - { - return FromUShort((ushort) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUShort(ushort val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(int)) - { - return FromInt((int) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromInt(int val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(uint)) - { - return FromUInt((uint) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromUInt(uint val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(long)) - { - return FromLong((long) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromLong(long val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(ulong)) - { - return FromULong((ulong) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromULong(ulong val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(Complex)) - { - return FromComplex((Complex) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromComplex(Complex val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (double) val.Real; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val.Real; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val.Real; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val.Real; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val.Real; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val.Real; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val.Real; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val.Real; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val.Real; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val.Real; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val.Real; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val.Real; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val.Real; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val.Real; - } - - ThrowUnsupportedType(); - return default!; - } - - if (typeof(TFrom) == typeof(BigInteger)) - { - return FromBigInteger((BigInteger) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo FromBigInteger(BigInteger val) - { - if (typeof(TTo) == typeof(Half)) - { - return (TTo) (object) (Half) (double) val; - } - if (typeof(TTo) == typeof(float)) - { - return (TTo) (object) (float) val; - } - if (typeof(TTo) == typeof(double)) - { - return (TTo) (object) (double) val; - } - if (typeof(TTo) == typeof(decimal)) - { - return (TTo) (object) (decimal) val; - } - if (typeof(TTo) == typeof(sbyte)) - { - return (TTo) (object) (sbyte) val; - } - if (typeof(TTo) == typeof(byte)) - { - return (TTo) (object) (byte) val; - } - if (typeof(TTo) == typeof(short)) - { - return (TTo) (object) (short) val; - } - if (typeof(TTo) == typeof(ushort)) - { - return (TTo) (object) (ushort) val; - } - if (typeof(TTo) == typeof(int)) - { - return (TTo) (object) (int) val; - } - if (typeof(TTo) == typeof(uint)) - { - return (TTo) (object) (uint) val; - } - if (typeof(TTo) == typeof(long)) - { - return (TTo) (object) (long) val; - } - if (typeof(TTo) == typeof(ulong)) - { - return (TTo) (object) (ulong) val; - } - if (typeof(TTo) == typeof(Complex)) - { - return (TTo) (object) (Complex) val; - } - if (typeof(TTo) == typeof(BigInteger)) - { - return (TTo) (object) (BigInteger) val; - } - - ThrowUnsupportedType(); - return default!; - } - - ThrowUnsupportedType(); - return default!; -#endif - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.As.tt b/sources/Maths/Maths/Scalar.As.tt deleted file mode 100644 index 68022f463f..0000000000 --- a/sources/Maths/Maths/Scalar.As.tt +++ /dev/null @@ -1,178 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/* - -This file is automatically generated by T4 template - -*/ - -<#@ assembly name="System.Core" #> -<#@ import namespace="System.Linq" #> - -using System; -using System.Runtime.CompilerServices; -using System.Numerics; - -// casting into non-nullable, unboxing from nullable -#pragma warning disable 8600 -#pragma warning disable 8605 - -<# - // T4 is old enough to not have value tuple - - var typesFullNames = new [] { - "Half", - "Float", - "Double", - "Decimal", - "SByte", - "Byte", - "Short", - "UShort", - "Int", - "UInt", - "Long", - "ULong", - "Complex", - "BigInteger" - }; - - var types = new [] { - "Half", - "float", - "double", - "decimal", - "sbyte", - "byte", - "short", - "ushort", - "int", - "uint", - "long", - "ulong", - "Complex", - "BigInteger" - }; - - var intermediateCasts = new System.Collections.Generic.Dictionary(); - // for some reason rider also complains about inline initialization - intermediateCasts["decimal_Half"] = "double"; - intermediateCasts["Half_decimal"] = "float"; - intermediateCasts["Half_Complex"] = "float"; - intermediateCasts["Complex_Half"] = "double"; - intermediateCasts["Half_BigInteger"] = "float"; - intermediateCasts["BigInteger_Half"] = "double"; - - var len = types.Length; -#> - -namespace Silk.NET.Maths -{ - /// - /// A collection of operations for working with scalar numeric values. - /// Includes methods like the ones found in and more. - /// Supports <#= string.Join(", ", types.Select(type => $"")) #> - /// - /// - public partial class Scalar - { - /// - /// Convert from to - /// - /// The value to convert - /// The type converted from - /// The type converted into - /// - /// While in most cases the types can be just explicitly casted, - /// sometimes there is an intermediate cast to float or double. - /// - /// - /// In case of we only consider the real part. - /// - /// The converted value - [MethodImpl(MaxOpt)] - public static TTo As(TFrom val) where TFrom : notnull where TTo : notnull - { - // We rejigged this code a bit to be a bit more strategic about its specialization branch as to not - // exceed RyuJIT's inlining/codegen budgets. In doing this, Mono apparently started producing invalid - // arm assembly, so we now maintain two paths: one for Mono, and one for CoreCLR. The CoreCLR one should - // really be preferred. -#if ANDROID || IOS - - return FromHalfToHalf(val); - -<# for (var i = 0; i < len; i++) { #> -<# for (var j = 0; j < len; j++) { -#> - - [MethodImpl(MaxOpt)] - static TTo From<#= typesFullNames[i] #>To<#= typesFullNames[j] #>(TFrom val) - { - if (typeof(TFrom) == typeof(<#= types[i] #>) && typeof(TTo) == typeof(<#= types[j] #>)) - { -<# -var intermediateType = ""; -if (intermediateCasts.TryGetValue($"{types[i]}_{types[j]}", out var res)) - intermediateType = $" ({res})"; - -#> -<# if (types[i] == "Complex") { #> - return (TTo) (object) (<#= types[j] #>)<#= intermediateType #> ((<#= types[i] #>) (object) val).Real; -<# } else { #> - return (TTo) (object) (<#= types[j] #>)<#= intermediateType #> (<#= types[i] #>) (object) val; -<# } #> - } - -<# - var jNext = (j + 1) % len; - var iNext = i + (jNext == 0 ? 1 : 0); - if (iNext == len) { - #> - ThrowUnsupportedType(); - return default!; -<# } else { #> - return From<#= typesFullNames[iNext] #>To<#= typesFullNames[jNext] #>(val); -<# } #> - } -<# } #> -<# } #> -#else -<# for (var i = 0; i < len; i++) { #> - if (typeof(TFrom) == typeof(<#= types[i] #>)) - { - return From<#= typesFullNames[i] #>((<#= types[i] #>) (object) val); - } - - [MethodImpl(MaxOpt)] - static TTo From<#= typesFullNames[i] #>(<#= types[i] #> val) - { -<# for (var j = 0; j < len; j++) { -#> - if (typeof(TTo) == typeof(<#= types[j] #>)) - { -<# -var intermediateType = ""; -if (intermediateCasts.TryGetValue($"{types[i]}_{types[j]}", out var res)) - intermediateType = $" ({res})"; - -#> -<# if (types[i] == "Complex") { #> - return (TTo) (object) (<#= types[j] #>)<#= intermediateType #> val.Real; -<# } else { #> - return (TTo) (object) (<#= types[j] #>)<#= intermediateType #> val; -<# } #> - } -<# } #> - - ThrowUnsupportedType(); - return default!; - } - -<# } #> - ThrowUnsupportedType(); - return default!; -#endif - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.BaseOps.cs b/sources/Maths/Maths/Scalar.BaseOps.cs deleted file mode 100644 index e9266dc3c8..0000000000 --- a/sources/Maths/Maths/Scalar.BaseOps.cs +++ /dev/null @@ -1,2266 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Numerics; -using System.Runtime.CompilerServices; -#if AdvSIMD -using System.Runtime.Intrinsics.Arm; -#endif -#if SSE -using System.Runtime.Intrinsics.X86; -#endif -// ReSharper disable CompareOfFloatsByEqualityOperator - -// casting into non-nullable, unboxing from nullable -#pragma warning disable 8600 -#pragma warning disable 8605 - -namespace Silk.NET.Maths -{ - public static partial class Scalar - { - internal const MethodImplOptions MaxOpt = MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512; - - internal static void ThrowUnsupportedType() - => throw new NotSupportedException("The given type is unsupported for generic maths."); - - internal static void ThrowOpUnsupportedType() - => throw new NotSupportedException("This operation is not applicable for the given type."); - - internal static void ThrowOpUnsupportedPrecision() - => throw new NotImplementedException - ( - "This operation is not applicable for the given type due to a high-enough precision algorithm not " + - "being available." - ); - - private static void ThrowIndexOutOfRange() => throw new IndexOutOfRangeException(); - - /// - /// Indicates whether members are hardware accelerated. Not all members support hardware acceleration. - /// - public static bool IsHardwareAccelerated => false -#if SSE - || Sse.IsSupported -#endif -#if AdvSIMD - || AdvSimd.IsSupported -#endif - ; - - /// - /// Determines whether the specified value is finite (zero, subnormal, or normal). - /// - /// A number. - /// The type of the specified number. - /// true if the value is finite (zero, subnormal or normal); false otherwise. - [MethodImpl(MaxOpt)] - public static bool IsFinite(T f) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return Half.IsFinite((Half) (object) f); - } - - return Float(f); - - [MethodImpl(MaxOpt)] - static bool Float(T f) - { - if (typeof(T) == typeof(float)) - { - return CoreIsFinite((float) (object) f); - } - - return Double(f); - } - - [MethodImpl(MaxOpt)] - static bool Double(T f) - { - if (typeof(T) == typeof(double)) - { - // double.IsFinite doesn't exist on netstandard2.0 - long bits = BitConverter.DoubleToInt64Bits((double) (object) f); - return (bits & 0x7FFFFFFFFFFFFFFF) < 0x7FF0000000000000; - } - - return Complex(f); - } - - [MethodImpl(MaxOpt)] - static bool Complex(T f) - { - if (typeof(T) == typeof(Complex)) - { -#if NETCOREAPP3_0_OR_GREATER - return System.Numerics.Complex.IsFinite((Complex)(object)f); -#else -// https://source.dot.net/#System.Runtime.Numerics/System/Numerics/Complex.cs,6b0a0cd37123d4d3 - return IsFinite(((Complex)(object)f).Real) && IsFinite(((Complex)(object)f).Imaginary); -#endif - } - - return Other(f); - } - - [MethodImpl(MaxOpt)] - static bool Other(T f) - { - if (typeof(T) == typeof(sbyte) - || typeof(T) == typeof(byte) - || typeof(T) == typeof(ushort) - || typeof(T) == typeof(short) - || typeof(T) == typeof(uint) - || typeof(T) == typeof(int) - || typeof(T) == typeof(ulong) - || typeof(T) == typeof(long) - || typeof(T) == typeof(decimal) - || typeof(T) == typeof(BigInteger) - ) - return true; - - ThrowOpUnsupportedType(); - return false; - } - } - - /// - /// Returns a value indicating whether the specified number evaluates to negative or positive infinity. - /// - /// A number - /// The type of the specified number. - /// true if evaluates to or ; false otherwise. - [MethodImpl(MaxOpt)] - public static bool IsInfinity(T f) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return Half.IsInfinity((Half) (object) f); - } - - return Float(f); - - [MethodImpl(MaxOpt)] - static bool Float(T f) - { - if (typeof(T) == typeof(float)) - { - return float.IsInfinity((float) (object) f); - } - - return Double(f); - } - - [MethodImpl(MaxOpt)] - static bool Double(T f) - { - if (typeof(T) == typeof(double)) - { - return double.IsInfinity((double) (object) f); - } - - return Complex(f); - } - - [MethodImpl(MaxOpt)] - static bool Complex(T f) - { - if (typeof(T) == typeof(Complex)) - { -#if NETCOREAPP3_0_OR_GREATER - return System.Numerics.Complex.IsInfinity((Complex)(object)f); -#else -// https://source.dot.net/#System.Runtime.Numerics/System/Numerics/Complex.cs,fbf803cb00899f67,references - return double.IsInfinity(((Complex)(object)f).Real) || double.IsInfinity(((Complex)(object)f).Imaginary); -#endif - } - - return Other(f); - } - - [MethodImpl(MaxOpt)] - static bool Other(T f) - { - if (typeof(T) == typeof(sbyte) - || typeof(T) == typeof(byte) - || typeof(T) == typeof(ushort) - || typeof(T) == typeof(short) - || typeof(T) == typeof(uint) - || typeof(T) == typeof(int) - || typeof(T) == typeof(ulong) - || typeof(T) == typeof(long) - || typeof(T) == typeof(decimal) - || typeof(T) == typeof(BigInteger) - ) - return false; - - ThrowOpUnsupportedType(); - return false; - } - } - - /// - /// Returns a value that indicates whether the specified value is not a number (). - /// - /// A number - /// The type of the specified number. - /// true if evaluates to ; false otherwise. - [MethodImpl(MaxOpt)] - public static bool IsNaN(T f) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return Half.IsNaN((Half) (object) f); - } - - return Float(f); - - [MethodImpl(MaxOpt)] - static bool Float(T f) - { - if (typeof(T) == typeof(float)) - { - return float.IsNaN((float) (object) f); - } - - return Double(f); - } - - [MethodImpl(MaxOpt)] - static bool Double(T f) - { - if (typeof(T) == typeof(double)) - { - return double.IsNaN((double) (object) f); - } - - return Complex(f); - } - - [MethodImpl(MaxOpt)] - static bool Complex(T f) - { - if (typeof(T) == typeof(Complex)) - { -#if NETCOREAPP3_0_OR_GREATER - return System.Numerics.Complex.IsNaN((Complex)(object)f); -#else - return !IsInfinity((Complex)(object)f) && !IsFinite((Complex)(object)f); -#endif - } - - return Other(f); - } - - [MethodImpl(MaxOpt)] - static bool Other(T f) - { - if (typeof(T) == typeof(sbyte) - || typeof(T) == typeof(byte) - || typeof(T) == typeof(ushort) - || typeof(T) == typeof(short) - || typeof(T) == typeof(uint) - || typeof(T) == typeof(int) - || typeof(T) == typeof(ulong) - || typeof(T) == typeof(long) - || typeof(T) == typeof(decimal) - || typeof(T) == typeof(BigInteger) - ) - return false; - - ThrowOpUnsupportedType(); - return false; - } - } - - /// - /// Determines whether the specified value is negative. - /// - /// A number - /// The type of the specified number. - /// true if the value is negative; false otherwise. - [MethodImpl(MaxOpt)] - public static bool IsNegative(T f) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return Half.IsNegative((Half) (object) f); - } - - return Float(f); - - [MethodImpl(MaxOpt)] - static bool Float(T f) - { - if (typeof(T) == typeof(float)) - { - return CoreIsNegative((float) (object) f); - } - - return Double(f); - } - - [MethodImpl(MaxOpt)] - static bool Double(T f) - { - if (typeof(T) == typeof(double)) - { - return CoreIsNegative((double) (object) f); - } - - return Short(f); - } - - [MethodImpl(MaxOpt)] - static bool Short(T f) - { - if (typeof(T) == typeof(short)) - { - return (short) (object) f < 0; - } - - return Int(f); - } - - [MethodImpl(MaxOpt)] - static bool Int(T f) - { - if (typeof(T) == typeof(int)) - { - return (int) (object) f < 0; - } - - return Long(f); - } - - [MethodImpl(MaxOpt)] - static bool Long(T f) - { - if (typeof(T) == typeof(long)) - { - return (long) (object) f < 0; - } - - return Decimal(f); - } - - [MethodImpl(MaxOpt)] - static bool Decimal(T f) - { - if (typeof(T) == typeof(int)) - { - return (int) (object) f < 0; - } - - return SByte(f); - } - - [MethodImpl(MaxOpt)] - static bool SByte(T f) - { - if (typeof(T) == typeof(int)) - { - return (int) (object) f < 0; - } - - return BigInteger(f); - } - - [MethodImpl(MaxOpt)] - static bool BigInteger(T f) - { - if (typeof(T) == typeof(BigInteger)) - { - return (BigInteger) (object) f < 0; - } - - return Other(f); - } - - [MethodImpl(MaxOpt)] - static bool Other(T f) - { - if (typeof(T) == typeof(byte) - || typeof(T) == typeof(ushort) - || typeof(T) == typeof(uint) - || typeof(T) == typeof(ulong) - - ) - return false; - - /* Complex is unsupported for negativity */ - ThrowOpUnsupportedType(); - return false; - } - } - - /// - /// Returns a value indicating whether the specified number evaluates to negative infinity. - /// - /// A number - /// The type of the specified number. - /// true if evaluates to ; false otherwise. - [MethodImpl(MaxOpt)] - public static bool IsNegativeInfinity(T f) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return Half.IsNegativeInfinity((Half) (object) f); - } - - return Float(f); - - [MethodImpl(MaxOpt)] - static bool Float(T f) - { - if (typeof(T) == typeof(float)) - { - return float.IsNegativeInfinity((float) (object) f); - } - - return Double(f); - } - - [MethodImpl(MaxOpt)] - static bool Double(T f) - { - if (typeof(T) == typeof(double)) - { - return double.IsNegativeInfinity((double) (object) f); - } - - return Other(f); - } - - [MethodImpl(MaxOpt)] - static bool Other(T f) - { - if (typeof(T) == typeof(sbyte) - || typeof(T) == typeof(byte) - || typeof(T) == typeof(ushort) - || typeof(T) == typeof(short) - || typeof(T) == typeof(uint) - || typeof(T) == typeof(int) - || typeof(T) == typeof(ulong) - || typeof(T) == typeof(long) - || typeof(T) == typeof(decimal) - || typeof(T) == typeof(BigInteger) - ) - return false; - - ThrowOpUnsupportedType(); - return false; - } - } - - /// - /// Determines whether the specified value is normal. - /// - /// A number - /// The type of the specified number. - /// true if the value is normal; false otherwise. - [MethodImpl(MaxOpt)] - public static bool IsNormal(T f) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return Half.IsNormal((Half) (object) f); - } - - return Float(f); - - [MethodImpl(MaxOpt)] - static bool Float(T f) - { - if (typeof(T) == typeof(float)) - { - return IsNormal((float) (object) f); - } - - return Double(f); - } - - [MethodImpl(MaxOpt)] - static bool Double(T f) - { - if (typeof(T) == typeof(double)) - { - return IsNormal((double) (object) f); - } - - return Other(f); - } - - [MethodImpl(MaxOpt)] - static bool Other(T f) - { - if (typeof(T) == typeof(sbyte) - || typeof(T) == typeof(byte) - || typeof(T) == typeof(ushort) - || typeof(T) == typeof(short) - || typeof(T) == typeof(uint) - || typeof(T) == typeof(int) - || typeof(T) == typeof(ulong) - || typeof(T) == typeof(long) - || typeof(T) == typeof(decimal) - || typeof(T) == typeof(BigInteger) - ) - return true; - - ThrowOpUnsupportedType(); - return false; - } - } - - /// - /// Returns a value indicating whether the specified number evaluates to positive infinity. - /// - /// A number - /// The type of the specified number. - /// true if evaluates to ; false otherwise. - [MethodImpl(MaxOpt)] - public static bool IsPositiveInfinity(T f) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return Half.IsPositiveInfinity((Half) (object) f); - } - - return Float(f); - - [MethodImpl(MaxOpt)] - static bool Float(T f) - { - if (typeof(T) == typeof(float)) - { - return float.IsPositiveInfinity((float) (object) f); - } - - return Double(f); - } - - [MethodImpl(MaxOpt)] - static bool Double(T f) - { - if (typeof(T) == typeof(double)) - { - return double.IsPositiveInfinity((double) (object) f); - } - - return Other(f); - } - - [MethodImpl(MaxOpt)] - static bool Other(T f) - { - if (typeof(T) == typeof(sbyte) - || typeof(T) == typeof(byte) - || typeof(T) == typeof(ushort) - || typeof(T) == typeof(short) - || typeof(T) == typeof(uint) - || typeof(T) == typeof(int) - || typeof(T) == typeof(ulong) - || typeof(T) == typeof(long) - || typeof(T) == typeof(decimal) - || typeof(T) == typeof(BigInteger) - ) - return false; - - ThrowOpUnsupportedType(); - return false; - } - } - - /// - /// Determines whether the specified value is subnormal. - /// - /// A number - /// The type of the specified number. - /// true if the value is subnormal; false otherwise. - /// This function will throw for types other then , , , because subnormality cannot be determined for other types. - [MethodImpl(MaxOpt)] - public static bool IsSubnormal(T f) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return Half.IsSubnormal((Half) (object) f); - } - - return Float(f); - - [MethodImpl(MaxOpt)] - static bool Float(T f) - { - if (typeof(T) == typeof(float)) - { - return CoreIsSubnormal((float) (object) f); - } - - return Double(f); - } - - [MethodImpl(MaxOpt)] - static bool Double(T f) - { - if (typeof(T) == typeof(double)) - { - return CoreIsSubnormal((double) (object) f); - } - - ThrowOpUnsupportedType(); - return false; - } - } - - /// - /// Returns a value that indicates whether two specified values are equal. - /// - /// The first value to compare. - /// The second value to compare. - /// The type of both values. - /// true if and are equal; otherwise, false. - [MethodImpl(MaxOpt)] - public static bool Equal(T left, T right) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (Half) (object) left == (Half) (object) right; - } - - return Float(left, right); - - [MethodImpl(MaxOpt)] - static bool Float(T left, T right) - { - if (typeof(T) == typeof(float)) - { - return (float) (object) left == (float) (object) right; - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - return (double) (object) left == (double) (object) right; - } - - return Decimal(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Decimal(T left, T right) - { - if (typeof(T) == typeof(decimal)) - { - return (decimal) (object) left == (decimal) (object) right; - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static bool SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (sbyte) (object) left == (sbyte) (object) right; - } - - return Byte(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (byte) (object) left == (byte) (object) right; - } - - return Int(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Int(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (int) (object) left == (int) (object) right; - } - - return UInt(left, right); - } - - [MethodImpl(MaxOpt)] - static bool UInt(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (uint) (object) left == (uint) (object) right; - } - - return Long(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Long(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (long) (object) left == (long) (object) right; - } - - return ULong(left, right); - } - - [MethodImpl(MaxOpt)] - static bool ULong(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (ulong) (object) left == (ulong) (object) right; - } - - return Short(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Short(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (short) (object) left == (short) (object) right; - } - - return UShort(left, right); - } - - [MethodImpl(MaxOpt)] - static bool UShort(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (ushort) (object) left == (ushort) (object) right; - } - - return BigInteger(left, right); - } - - [MethodImpl(MaxOpt)] - static bool BigInteger(T left, T right) - { - if (typeof(T) == typeof(BigInteger)) - { - return (BigInteger) (object) left == (BigInteger) (object) right; - } - - return Complex(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Complex(T left, T right) - { - if (typeof(T) == typeof(Complex)) - { - return (Complex) (object) left == (Complex) (object) right; - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Other(T _, T __) - { - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns a value that indicates whether two specified values are not equal. - /// - /// The first value to compare. - /// The second value to compare. - /// The type of both values. - /// true if and are not equal; otherwise, false. - [MethodImpl(MaxOpt)] - public static bool NotEqual(T left, T right) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (Half) (object) left != (Half) (object) right; - } - - return Float(left, right); - - [MethodImpl(MaxOpt)] - static bool Float(T left, T right) - { - if (typeof(T) == typeof(float)) - { - return (float) (object) left != (float) (object) right; - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - return (double) (object) left != (double) (object) right; - } - - return Decimal(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Decimal(T left, T right) - { - if (typeof(T) == typeof(decimal)) - { - return (decimal) (object) left != (decimal) (object) right; - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static bool SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (sbyte) (object) left != (sbyte) (object) right; - } - - return Byte(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (byte) (object) left != (byte) (object) right; - } - - return Int(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Int(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (int) (object) left != (int) (object) right; - } - - return UInt(left, right); - } - - [MethodImpl(MaxOpt)] - static bool UInt(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (uint) (object) left != (uint) (object) right; - } - - return Long(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Long(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (long) (object) left != (long) (object) right; - } - - return ULong(left, right); - } - - [MethodImpl(MaxOpt)] - static bool ULong(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (ulong) (object) left != (ulong) (object) right; - } - - return Short(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Short(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (short) (object) left != (short) (object) right; - } - - return UShort(left, right); - } - - [MethodImpl(MaxOpt)] - static bool UShort(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (ushort) (object) left != (ushort) (object) right; - } - - return BigInteger(left, right); - } - - [MethodImpl(MaxOpt)] - static bool BigInteger(T left, T right) - { - if (typeof(T) == typeof(BigInteger)) - { - return (BigInteger) (object) left != (BigInteger) (object) right; - } - - return Complex(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Complex(T left, T right) - { - if (typeof(T) == typeof(Complex)) - { - return (Complex) (object) left != (Complex) (object) right; - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Other(T _, T __) - { - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns a value that indicates whether a specified value is greater than another specified value. - /// - /// The first value to compare. - /// The second value to compare. - /// The type of both values. - /// true if is greater than ; otherwise, false. - [MethodImpl(MaxOpt)] - public static bool GreaterThan(T left, T right) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (Half) (object) left > (Half) (object) right; - } - - return Float(left, right); - - [MethodImpl(MaxOpt)] - static bool Float(T left, T right) - { - if (typeof(T) == typeof(float)) - { - return (float) (object) left > (float) (object) right; - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - return (double) (object) left > (double) (object) right; - } - - return Decimal(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Decimal(T left, T right) - { - if (typeof(T) == typeof(decimal)) - { - return (decimal) (object) left > (decimal) (object) right; - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static bool SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (sbyte) (object) left > (sbyte) (object) right; - } - - return Byte(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (byte) (object) left > (byte) (object) right; - } - - return Int(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Int(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (int) (object) left > (int) (object) right; - } - - return UInt(left, right); - } - - [MethodImpl(MaxOpt)] - static bool UInt(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (uint) (object) left > (uint) (object) right; - } - - return Long(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Long(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (long) (object) left > (long) (object) right; - } - - return ULong(left, right); - } - - [MethodImpl(MaxOpt)] - static bool ULong(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (ulong) (object) left > (ulong) (object) right; - } - - return Short(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Short(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (short) (object) left > (short) (object) right; - } - - return UShort(left, right); - } - - [MethodImpl(MaxOpt)] - static bool UShort(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (ushort) (object) left > (ushort) (object) right; - } - - return BigInteger(left, right); - } - - [MethodImpl(MaxOpt)] - static bool BigInteger(T left, T right) - { - if (typeof(T) == typeof(BigInteger)) - { - return (BigInteger) (object) left > (BigInteger) (object) right; - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Other(T _, T __) - { - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns a value that indicates whether a specified value is greater than or equal to another specified value. - /// - /// The first value to compare. - /// The second value to compare. - /// The type of both values. - /// true if is greater than or equal to ; otherwise, false. - [MethodImpl(MaxOpt)] - public static bool GreaterThanOrEqual(T left, T right) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (Half) (object) left >= (Half) (object) right; - } - - return Float(left, right); - - [MethodImpl(MaxOpt)] - static bool Float(T left, T right) - { - if (typeof(T) == typeof(float)) - { - return (float) (object) left >= (float) (object) right; - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - return (double) (object) left >= (double) (object) right; - } - - return Decimal(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Decimal(T left, T right) - { - if (typeof(T) == typeof(decimal)) - { - return (decimal) (object) left >= (decimal) (object) right; - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static bool SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (sbyte) (object) left >= (sbyte) (object) right; - } - - return Byte(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (byte) (object) left >= (byte) (object) right; - } - - return Int(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Int(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (int) (object) left >= (int) (object) right; - } - - return UInt(left, right); - } - - [MethodImpl(MaxOpt)] - static bool UInt(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (uint) (object) left >= (uint) (object) right; - } - - return Long(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Long(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (long) (object) left >= (long) (object) right; - } - - return ULong(left, right); - } - - [MethodImpl(MaxOpt)] - static bool ULong(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (ulong) (object) left >= (ulong) (object) right; - } - - return Short(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Short(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (short) (object) left >= (short) (object) right; - } - - return UShort(left, right); - } - - [MethodImpl(MaxOpt)] - static bool UShort(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (ushort) (object) left >= (ushort) (object) right; - } - - return BigInteger(left, right); - } - - [MethodImpl(MaxOpt)] - static bool BigInteger(T left, T right) - { - if (typeof(T) == typeof(BigInteger)) - { - return (BigInteger) (object) left >= (BigInteger) (object) right; - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Other(T _, T __) - { - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns a value that indicates whether a specified value is less than another specified value. - /// - /// The first value to compare. - /// The second value to compare. - /// The type of both values. - /// true if is less than ; otherwise, false. - [MethodImpl(MaxOpt)] - public static bool LessThan(T left, T right) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (Half) (object) left < (Half) (object) right; - } - - return Float(left, right); - - [MethodImpl(MaxOpt)] - static bool Float(T left, T right) - { - if (typeof(T) == typeof(float)) - { - return (float) (object) left < (float) (object) right; - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - return (double) (object) left < (double) (object) right; - } - - return Decimal(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Decimal(T left, T right) - { - if (typeof(T) == typeof(decimal)) - { - return (decimal) (object) left < (decimal) (object) right; - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static bool SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (sbyte) (object) left < (sbyte) (object) right; - } - - return Byte(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (byte) (object) left < (byte) (object) right; - } - - return Int(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Int(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (int) (object) left < (int) (object) right; - } - - return UInt(left, right); - } - - [MethodImpl(MaxOpt)] - static bool UInt(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (uint) (object) left < (uint) (object) right; - } - - return Long(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Long(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (long) (object) left < (long) (object) right; - } - - return ULong(left, right); - } - - [MethodImpl(MaxOpt)] - static bool ULong(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (ulong) (object) left < (ulong) (object) right; - } - - return Short(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Short(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (short) (object) left < (short) (object) right; - } - - return UShort(left, right); - } - - [MethodImpl(MaxOpt)] - static bool UShort(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (ushort) (object) left < (ushort) (object) right; - } - - return BigInteger(left, right); - } - - [MethodImpl(MaxOpt)] - static bool BigInteger(T left, T right) - { - if (typeof(T) == typeof(BigInteger)) - { - return (BigInteger) (object) left < (BigInteger) (object) right; - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Other(T _, T __) - { - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns a value that indicates whether a specified value is less than or equal to another specified value. - /// - /// The first value to compare. - /// The second value to compare. - /// The type of both values. - /// true if is less than or equal to ; otherwise, false. - [MethodImpl(MaxOpt)] - public static bool LessThanOrEqual(T left, T right) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (Half) (object) left <= (Half) (object) right; - } - - return Float(left, right); - - [MethodImpl(MaxOpt)] - static bool Float(T left, T right) - { - if (typeof(T) == typeof(float)) - { - return (float) (object) left <= (float) (object) right; - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - return (double) (object) left <= (double) (object) right; - } - - return Decimal(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Decimal(T left, T right) - { - if (typeof(T) == typeof(decimal)) - { - return (decimal) (object) left <= (decimal) (object) right; - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static bool SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (sbyte) (object) left <= (sbyte) (object) right; - } - - return Byte(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (byte) (object) left <= (byte) (object) right; - } - - return Int(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Int(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (int) (object) left <= (int) (object) right; - } - - return UInt(left, right); - } - - [MethodImpl(MaxOpt)] - static bool UInt(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (uint) (object) left <= (uint) (object) right; - } - - return Long(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Long(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (long) (object) left <= (long) (object) right; - } - - return ULong(left, right); - } - - [MethodImpl(MaxOpt)] - static bool ULong(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (ulong) (object) left <= (ulong) (object) right; - } - - return Short(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Short(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (short) (object) left <= (short) (object) right; - } - - return UShort(left, right); - } - - [MethodImpl(MaxOpt)] - static bool UShort(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (ushort) (object) left <= (ushort) (object) right; - } - - return BigInteger(left, right); - } - - [MethodImpl(MaxOpt)] - static bool BigInteger(T left, T right) - { - if (typeof(T) == typeof(BigInteger)) - { - return (BigInteger) (object) left <= (BigInteger) (object) right; - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static bool Other(T _, T __) - { - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Adds two specified values. - /// - /// The first value to add. - /// The second value to add. - /// The type of both values. - /// The result of adding and . - [MethodImpl(MaxOpt)] - public static T Add(T left, T right) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) ((float) (Half) (object) left + (float) (Half) (object) right); - } - - return Float(left, right); - - [MethodImpl(MaxOpt)] - static T Float(T left, T right) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) ((float) (object) left + (float) (object) right); - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static T Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) ((double) (object) left + (double) (object) right); - } - - return Decimal(left, right); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T left, T right) - { - if (typeof(T) == typeof(decimal)) - { - return (T) (object) ((decimal) (object) left + (decimal) (object) right); - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static T SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) ((sbyte) (object) left + (sbyte) (object) right); - } - - return Byte(left, right); - } - - [MethodImpl(MaxOpt)] - static T Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) ((byte) (object) left + (byte) (object) right); - } - - return Short(left, right); - } - - [MethodImpl(MaxOpt)] - static T Short(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) ((short) (object) left + (short) (object) right); - } - - return UShort(left, right); - } - - [MethodImpl(MaxOpt)] - static T UShort(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) ((ushort) (object) left + (ushort) (object) right); - } - - return Int(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) ((int) (object) left + (int) (object) right); - } - - return UInt(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) ((uint) (object) left + (uint) (object) right); - } - - return Long(left, right); - } - - [MethodImpl(MaxOpt)] - static T Long(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) ((long) (object) left + (long) (object) right); - } - - return ULong(left, right); - } - - [MethodImpl(MaxOpt)] - static T ULong(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) ((ulong) (object) left + (ulong) (object) right); - } - - return BigInteger(left, right); - } - - [MethodImpl(MaxOpt)] - static T BigInteger(T left, T right) - { - if (typeof(T) == typeof(BigInteger)) - { - return (T)(object)((BigInteger) (object) left + (BigInteger) (object) right); - } - - return Complex(left, right); - } - - [MethodImpl(MaxOpt)] - static T Complex(T left, T right) - { - if (typeof(T) == typeof(Complex)) - { - return (T)(object)((Complex) (object) left + (Complex) (object) right); - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static T Other(T _, T __) - { - ThrowUnsupportedType(); - return default!; - } - } - - /// - /// Subtracts two specified values. - /// - /// The minuend. - /// The subtrahend. - /// The type of both values. - /// The result of subtracting from . - [MethodImpl(MaxOpt)] - public static T Subtract(T left, T right) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) ((float) (Half) (object) left - (float) (Half) (object) right); - } - - return Float(left, right); - - [MethodImpl(MaxOpt)] - static T Float(T left, T right) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) ((float) (object) left - (float) (object) right); - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static T Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) ((double) (object) left - (double) (object) right); - } - - return Decimal(left, right); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T left, T right) - { - if (typeof(T) == typeof(decimal)) - { - return (T) (object) ((decimal) (object) left - (decimal) (object) right); - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static T SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) ((sbyte) (object) left - (sbyte) (object) right); - } - - return Byte(left, right); - } - - [MethodImpl(MaxOpt)] - static T Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) ((byte) (object) left - (byte) (object) right); - } - - return Short(left, right); - } - - [MethodImpl(MaxOpt)] - static T Short(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) ((short) (object) left - (short) (object) right); - } - - return UShort(left, right); - } - - [MethodImpl(MaxOpt)] - static T UShort(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) ((ushort) (object) left - (ushort) (object) right); - } - - return Int(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) ((int) (object) left - (int) (object) right); - } - - return UInt(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) ((uint) (object) left - (uint) (object) right); - } - - return Long(left, right); - } - - [MethodImpl(MaxOpt)] - static T Long(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) ((long) (object) left - (long) (object) right); - } - - return ULong(left, right); - } - - [MethodImpl(MaxOpt)] - static T ULong(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) ((ulong) (object) left - (ulong) (object) right); - } - - return BigInteger(left, right); - } - - [MethodImpl(MaxOpt)] - static T BigInteger(T left, T right) - { - if (typeof(T) == typeof(BigInteger)) - { - return (T)(object)((BigInteger) (object) left - (BigInteger) (object) right); - } - - return Complex(left, right); - } - - [MethodImpl(MaxOpt)] - static T Complex(T left, T right) - { - if (typeof(T) == typeof(Complex)) - { - return (T)(object)((Complex) (object) left - (Complex) (object) right); - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static T Other(T _, T __) - { - ThrowUnsupportedType(); - return default!; - } - } - - /// - /// Multiplies two specified values. - /// - /// The first value to multiply. - /// The second value to multiply. - /// The type of both values. - /// The result of multiplying and . - [MethodImpl(MaxOpt)] - public static T Multiply(T left, T right) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) ((float) (Half) (object) left * (float) (Half) (object) right); - } - - return Float(left, right); - - [MethodImpl(MaxOpt)] - static T Float(T left, T right) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) ((float) (object) left * (float) (object) right); - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static T Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) ((double) (object) left * (double) (object) right); - } - - return Decimal(left, right); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T left, T right) - { - if (typeof(T) == typeof(decimal)) - { - return (T) (object) ((decimal) (object) left * (decimal) (object) right); - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static T SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) ((sbyte) (object) left * (sbyte) (object) right); - } - - return Byte(left, right); - } - - [MethodImpl(MaxOpt)] - static T Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) ((byte) (object) left * (byte) (object) right); - } - - return Short(left, right); - } - - [MethodImpl(MaxOpt)] - static T Short(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) ((short) (object) left * (short) (object) right); - } - - return UShort(left, right); - } - - [MethodImpl(MaxOpt)] - static T UShort(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) ((ushort) (object) left * (ushort) (object) right); - } - - return Int(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) ((int) (object) left * (int) (object) right); - } - - return UInt(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) ((uint) (object) left * (uint) (object) right); - } - - return Long(left, right); - } - - [MethodImpl(MaxOpt)] - static T Long(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) ((long) (object) left * (long) (object) right); - } - - return ULong(left, right); - } - - [MethodImpl(MaxOpt)] - static T ULong(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) ((ulong) (object) left * (ulong) (object) right); - } - - return BigInteger(left, right); - } - - [MethodImpl(MaxOpt)] - static T BigInteger(T left, T right) - { - if (typeof(T) == typeof(BigInteger)) - { - return (T)(object)((BigInteger) (object) left * (BigInteger) (object) right); - } - - return Complex(left, right); - } - - [MethodImpl(MaxOpt)] - static T Complex(T left, T right) - { - if (typeof(T) == typeof(Complex)) - { - return (T)(object)((Complex) (object) left * (Complex) (object) right); - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static T Other(T _, T __) - { - ThrowUnsupportedType(); - return default!; - } - } - - /// - /// Divides two specified values. - /// - /// The dividend. - /// The divisor. - /// The type of both values. - /// The result of dividing by . - [MethodImpl(MaxOpt)] - public static T Divide(T left, T right) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) ((float) (Half) (object) left / (float) (Half) (object) right); - } - - return Float(left, right); - - [MethodImpl(MaxOpt)] - static T Float(T left, T right) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) ((float) (object) left / (float) (object) right); - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static T Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) ((double) (object) left / (double) (object) right); - } - - return Decimal(left, right); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T left, T right) - { - if (typeof(T) == typeof(decimal)) - { - return (T) (object) ((decimal) (object) left / (decimal) (object) right); - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static T SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) ((sbyte) (object) left / (sbyte) (object) right); - } - - return Byte(left, right); - } - - [MethodImpl(MaxOpt)] - static T Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) ((byte) (object) left / (byte) (object) right); - } - - return Short(left, right); - } - - [MethodImpl(MaxOpt)] - static T Short(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) ((short) (object) left / (short) (object) right); - } - - return UShort(left, right); - } - - [MethodImpl(MaxOpt)] - static T UShort(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) ((ushort) (object) left / (ushort) (object) right); - } - - return Int(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) ((int) (object) left / (int) (object) right); - } - - return UInt(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) ((uint) (object) left / (uint) (object) right); - } - - return Long(left, right); - } - - [MethodImpl(MaxOpt)] - static T Long(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) ((long) (object) left / (long) (object) right); - } - - return ULong(left, right); - } - - [MethodImpl(MaxOpt)] - static T ULong(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) ((ulong) (object) left / (ulong) (object) right); - } - - return BigInteger(left, right); - } - - [MethodImpl(MaxOpt)] - static T BigInteger(T left, T right) - { - if (typeof(T) == typeof(BigInteger)) - { - return (T)(object)((BigInteger) (object) left / (BigInteger) (object) right); - } - - return Complex(left, right); - } - - [MethodImpl(MaxOpt)] - static T Complex(T left, T right) - { - if (typeof(T) == typeof(Complex)) - { - return (T)(object)((Complex) (object) left / (Complex) (object) right); - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static T Other(T _, T __) - { - ThrowUnsupportedType(); - return default!; - } - } - - /// - /// Returns the result of multiplying the specified value by negative one. - /// - /// The value to negate - /// The type of the value - /// - /// A number with the value of , but the opposite sign. - /// -or- - /// Zero, if is zero. - /// - [MethodImpl(MaxOpt)] - public static T Negate(T x) where T : notnull => Multiply(x, Scalar.MinusOne); - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Bitwise/Scalar.And.cs b/sources/Maths/Maths/Scalar.Bitwise/Scalar.And.cs deleted file mode 100644 index 5e2250aad4..0000000000 --- a/sources/Maths/Maths/Scalar.Bitwise/Scalar.And.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - static partial class Scalar - { - /// - /// Performs And on supported types - /// - public static T And(T left, T right) where T : unmanaged - { - return Byte(left, right); - - [MethodImpl(MaxOpt)] - static T Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) ((byte) (object) left & (byte) (object) right); - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static T SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) ((sbyte) (object) left & (sbyte) (object) right); - } - - return UInt16(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt16(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) ((ushort) (object) left & (ushort) (object) right); - } - - return Int16(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int16(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) ((short) (object) left & (short) (object) right); - } - - return UInt32(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt32(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) ((uint) (object) left & (uint) (object) right); - } - - return Int32(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int32(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) ((int) (object) left & (int) (object) right); - } - - return UInt64(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt64(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) ((ulong) (object) left & (ulong) (object) right); - } - - return Int64(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int64(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) ((long) (object) left & (long) (object) right); - } - - return Single(left, right); - } - - [MethodImpl(MaxOpt)] - static T Single(T left, T right) - { - if (typeof(T) == typeof(float)) - { - var res = Unsafe.As(ref left) & Unsafe.As(ref right); - return Unsafe.As(ref res); - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static T Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - var res = Unsafe.As(ref left) & Unsafe.As(ref right); - return Unsafe.As(ref res); - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static T Other(T left, T right) - { - ThrowUnsupportedType(); - return default; - } - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Bitwise/Scalar.Not.cs b/sources/Maths/Maths/Scalar.Bitwise/Scalar.Not.cs deleted file mode 100644 index 4db3748511..0000000000 --- a/sources/Maths/Maths/Scalar.Bitwise/Scalar.Not.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - static partial class Scalar - { - /// - /// Performs Not on supported types - /// - public static T Not(T value) where T : unmanaged - { - return Byte(value); - - [MethodImpl(MaxOpt)] - static T Byte(T value) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) (~ (byte) (object) value); - } - - return SByte(value); - } - - [MethodImpl(MaxOpt)] - static T SByte(T value) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) (~ (sbyte) (object) value); - } - - return UInt16(value); - } - - [MethodImpl(MaxOpt)] - static T UInt16(T value) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) (~ (ushort) (object) value); - } - - return Int16(value); - } - - [MethodImpl(MaxOpt)] - static T Int16(T value) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) (~ (short) (object) value); - } - - return UInt32(value); - } - - [MethodImpl(MaxOpt)] - static T UInt32(T value) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) (~ (uint) (object) value); - } - - return Int32(value); - } - - [MethodImpl(MaxOpt)] - static T Int32(T value) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) (~ (int) (object) value); - } - - return UInt64(value); - } - - [MethodImpl(MaxOpt)] - static T UInt64(T value) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) (~ (ulong) (object) value); - } - - return Int64(value); - } - - [MethodImpl(MaxOpt)] - static T Int64(T value) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) (~ (long) (object) value); - } - - return Single(value); - } - - [MethodImpl(MaxOpt)] - static T Single(T value) - { - if (typeof(T) == typeof(float)) - { - var res = ~ Unsafe.As(ref value); - return Unsafe.As(ref res); - } - - return Double(value); - } - - [MethodImpl(MaxOpt)] - static T Double(T value) - { - if (typeof(T) == typeof(double)) - { - var res = ~ Unsafe.As(ref value); - return Unsafe.As(ref res); - } - - return Other(value); - } - - [MethodImpl(MaxOpt)] - static T Other(T value) - { - ThrowUnsupportedType(); - return default; - } - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Bitwise/Scalar.Or.cs b/sources/Maths/Maths/Scalar.Bitwise/Scalar.Or.cs deleted file mode 100644 index 1f893116c0..0000000000 --- a/sources/Maths/Maths/Scalar.Bitwise/Scalar.Or.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - static partial class Scalar - { - /// - /// Performs Or on supported types - /// - public static T Or(T left, T right) where T : unmanaged - { - return Byte(left, right); - - [MethodImpl(MaxOpt)] - static T Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) ((byte) (object) left | (byte) (object) right); - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static T SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) ((sbyte) (object) left | (sbyte) (object) right); - } - - return UInt16(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt16(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) ((ushort) (object) left | (ushort) (object) right); - } - - return Int16(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int16(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) ((short) (object) left | (short) (object) right); - } - - return UInt32(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt32(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) ((uint) (object) left | (uint) (object) right); - } - - return Int32(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int32(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) ((int) (object) left | (int) (object) right); - } - - return UInt64(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt64(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) ((ulong) (object) left | (ulong) (object) right); - } - - return Int64(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int64(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) ((long) (object) left | (long) (object) right); - } - - return Single(left, right); - } - - [MethodImpl(MaxOpt)] - static T Single(T left, T right) - { - if (typeof(T) == typeof(float)) - { - var res = Unsafe.As(ref left) | Unsafe.As(ref right); - return Unsafe.As(ref res); - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static T Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - var res = Unsafe.As(ref left) | Unsafe.As(ref right); - return Unsafe.As(ref res); - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static T Other(T left, T right) - { - ThrowUnsupportedType(); - return default; - } - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Bitwise/Scalar.RotateLeft.cs b/sources/Maths/Maths/Scalar.Bitwise/Scalar.RotateLeft.cs deleted file mode 100644 index 979340447b..0000000000 --- a/sources/Maths/Maths/Scalar.Bitwise/Scalar.RotateLeft.cs +++ /dev/null @@ -1,148 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - static partial class Scalar - { - /// - /// Rotates a given value bitwise. - /// Shifting float and double obeys unsigned integers' behaviour. - /// - public static T RotateLeft(T value, int offset) where T : unmanaged - { - return Byte(value, offset); - - [MethodImpl(MaxOpt)] - static T Byte(T value, int offset) - { - if (typeof(T) == typeof(byte)) - { - var v = (byte) (object) value; - return (T) (object) (byte) ((v << offset) | (v >> (8 - offset))); - } - - return SByte(value, offset); - } - - [MethodImpl(MaxOpt)] - static T SByte(T value, int offset) - { - if (typeof(T) == typeof(sbyte)) - { - var v = (sbyte) (object) value; - return (T) (object) (sbyte) ((v << offset) | (v >> (8 - offset))); - } - - return UShort(value, offset); - } - - [MethodImpl(MaxOpt)] - static T UShort(T value, int offset) - { - if (typeof(T) == typeof(ushort)) - { - var v = (ushort) (object) value; - return (T) (object) (ushort) ((v << offset) | (v >> (16 - offset))); - } - - return Short(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Short(T value, int offset) - { - if (typeof(T) == typeof(short)) - { - var v = (short) (object) value; - return (T) (object) (short) ((v << offset) | (v >> (16 - offset))); - } - - return UInt(value, offset); - } - - [MethodImpl(MaxOpt)] - static T UInt(T value, int offset) - { - if (typeof(T) == typeof(uint)) - { - var v = (uint) (object) value; - return (T) (object) (uint) ((v << offset) | (v >> (32 - offset))); - } - - return Int(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Int(T value, int offset) - { - if (typeof(T) == typeof(int)) - { - var v = (int) (object) value; - return (T) (object) (int) ((v << offset) | (v >> (32 - offset))); - } - - return ULong(value, offset); - } - - [MethodImpl(MaxOpt)] - static T ULong(T value, int offset) - { - if (typeof(T) == typeof(ulong)) - { - var v = (ulong) (object) value; - return (T) (object) (ulong) ((v << offset) | (v >> (64 - offset))); - } - - return Long(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Long(T value, int offset) - { - if (typeof(T) == typeof(long)) - { - var v = (long) (object) value; - return (T) (object) (long) ((v << offset) | (v >> (64 - offset))); - } - - return Float(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Float(T value, int offset) - { - if (typeof(T) == typeof(float)) - { - var v = Unsafe.As(ref value); - var res = (v << offset) | (v >> (32 - offset)); - return Unsafe.As(ref res); - } - - return Double(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Double(T value, int offset) - { - if (typeof(T) == typeof(double)) - { - var v = Unsafe.As(ref value); - var res = (v << offset) | (v >> (64 - offset)); - return Unsafe.As(ref res); - } - - return Other(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Other(T _, int __) - { - ThrowUnsupportedType(); - return default; - } - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Bitwise/Scalar.RotateRight.cs b/sources/Maths/Maths/Scalar.Bitwise/Scalar.RotateRight.cs deleted file mode 100644 index 3324597f08..0000000000 --- a/sources/Maths/Maths/Scalar.Bitwise/Scalar.RotateRight.cs +++ /dev/null @@ -1,148 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - static partial class Scalar - { - /// - /// Rotates a given value bitwise. - /// Shifting float and double obeys unsigned integers' behaviour. - /// - public static T RotateRight(T value, int offset) where T : unmanaged - { - return Byte(value, offset); - - [MethodImpl(MaxOpt)] - static T Byte(T value, int offset) - { - if (typeof(T) == typeof(byte)) - { - var v = (byte) (object) value; - return (T) (object) (byte) ((v >> offset) | (v << (8 - offset))); - } - - return SByte(value, offset); - } - - [MethodImpl(MaxOpt)] - static T SByte(T value, int offset) - { - if (typeof(T) == typeof(sbyte)) - { - var v = (sbyte) (object) value; - return (T) (object) (sbyte) ((v >> offset) | (v << (8 - offset))); - } - - return UShort(value, offset); - } - - [MethodImpl(MaxOpt)] - static T UShort(T value, int offset) - { - if (typeof(T) == typeof(ushort)) - { - var v = (ushort) (object) value; - return (T) (object) (ushort) ((v >> offset) | (v << (16 - offset))); - } - - return Short(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Short(T value, int offset) - { - if (typeof(T) == typeof(short)) - { - var v = (short) (object) value; - return (T) (object) (short) ((v >> offset) | (v << (16 - offset))); - } - - return UInt(value, offset); - } - - [MethodImpl(MaxOpt)] - static T UInt(T value, int offset) - { - if (typeof(T) == typeof(uint)) - { - var v = (uint) (object) value; - return (T) (object) (uint) ((v >> offset) | (v << (32 - offset))); - } - - return Int(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Int(T value, int offset) - { - if (typeof(T) == typeof(int)) - { - var v = (int) (object) value; - return (T) (object) (int) ((v >> offset) | (v << (32 - offset))); - } - - return ULong(value, offset); - } - - [MethodImpl(MaxOpt)] - static T ULong(T value, int offset) - { - if (typeof(T) == typeof(ulong)) - { - var v = (ulong) (object) value; - return (T) (object) (ulong) ((v >> offset) | (v << (64 - offset))); - } - - return Long(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Long(T value, int offset) - { - if (typeof(T) == typeof(long)) - { - var v = (long) (object) value; - return (T) (object) (long) ((v >> offset) | (v << (64 - offset))); - } - - return Float(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Float(T value, int offset) - { - if (typeof(T) == typeof(float)) - { - var v = Unsafe.As(ref value); - var res = (v >> offset) | (v << (32 - offset)); - return Unsafe.As(ref res); - } - - return Double(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Double(T value, int offset) - { - if (typeof(T) == typeof(double)) - { - var v = Unsafe.As(ref value); - var res = (v >> offset) | (v << (64 - offset)); - return Unsafe.As(ref res); - } - - return Other(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Other(T _, int __) - { - ThrowUnsupportedType(); - return default; - } - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Bitwise/Scalar.ShiftLeft.cs b/sources/Maths/Maths/Scalar.Bitwise/Scalar.ShiftLeft.cs deleted file mode 100644 index 52f2b07f21..0000000000 --- a/sources/Maths/Maths/Scalar.Bitwise/Scalar.ShiftLeft.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - static partial class Scalar - { - /// - /// Performs ShiftLeft on supported types - /// - public static T ShiftLeft(T value, int offset) where T : unmanaged - { - return Byte(value, offset); - - [MethodImpl(MaxOpt)] - static T Byte(T value, int offset) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) ((byte) (object) value << offset); - } - - return SByte(value, offset); - } - - [MethodImpl(MaxOpt)] - static T SByte(T value, int offset) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) ((sbyte) (object) value << offset); - } - - return UInt16(value, offset); - } - - [MethodImpl(MaxOpt)] - static T UInt16(T value, int offset) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) ((ushort) (object) value << offset); - } - - return Int16(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Int16(T value, int offset) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) ((short) (object) value << offset); - } - - return UInt32(value, offset); - } - - [MethodImpl(MaxOpt)] - static T UInt32(T value, int offset) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) ((uint) (object) value << offset); - } - - return Int32(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Int32(T value, int offset) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) ((int) (object) value << offset); - } - - return UInt64(value, offset); - } - - [MethodImpl(MaxOpt)] - static T UInt64(T value, int offset) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) ((ulong) (object) value << offset); - } - - return Int64(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Int64(T value, int offset) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) ((long) (object) value << offset); - } - - return Single(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Single(T value, int offset) - { - if (typeof(T) == typeof(float)) - { - var res = Unsafe.As(ref value) << offset; - return Unsafe.As(ref res); - } - - return Double(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Double(T value, int offset) - { - if (typeof(T) == typeof(double)) - { - var res = Unsafe.As(ref value) << offset; - return Unsafe.As(ref res); - } - - return Other(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Other(T value, int offset) - { - ThrowUnsupportedType(); - return default; - } - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Bitwise/Scalar.ShiftRight.cs b/sources/Maths/Maths/Scalar.Bitwise/Scalar.ShiftRight.cs deleted file mode 100644 index 29f844c792..0000000000 --- a/sources/Maths/Maths/Scalar.Bitwise/Scalar.ShiftRight.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - static partial class Scalar - { - /// - /// Performs ShiftRight on supported types - /// - public static T ShiftRight(T value, int offset) where T : unmanaged - { - return Byte(value, offset); - - [MethodImpl(MaxOpt)] - static T Byte(T value, int offset) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) ((byte) (object) value >> offset); - } - - return SByte(value, offset); - } - - [MethodImpl(MaxOpt)] - static T SByte(T value, int offset) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) ((sbyte) (object) value >> offset); - } - - return UInt16(value, offset); - } - - [MethodImpl(MaxOpt)] - static T UInt16(T value, int offset) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) ((ushort) (object) value >> offset); - } - - return Int16(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Int16(T value, int offset) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) ((short) (object) value >> offset); - } - - return UInt32(value, offset); - } - - [MethodImpl(MaxOpt)] - static T UInt32(T value, int offset) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) ((uint) (object) value >> offset); - } - - return Int32(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Int32(T value, int offset) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) ((int) (object) value >> offset); - } - - return UInt64(value, offset); - } - - [MethodImpl(MaxOpt)] - static T UInt64(T value, int offset) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) ((ulong) (object) value >> offset); - } - - return Int64(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Int64(T value, int offset) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) ((long) (object) value >> offset); - } - - return Single(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Single(T value, int offset) - { - if (typeof(T) == typeof(float)) - { - var res = Unsafe.As(ref value) >> offset; - return Unsafe.As(ref res); - } - - return Double(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Double(T value, int offset) - { - if (typeof(T) == typeof(double)) - { - var res = Unsafe.As(ref value) >> offset; - return Unsafe.As(ref res); - } - - return Other(value, offset); - } - - [MethodImpl(MaxOpt)] - static T Other(T value, int offset) - { - ThrowUnsupportedType(); - return default; - } - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Bitwise/Scalar.Xor.cs b/sources/Maths/Maths/Scalar.Bitwise/Scalar.Xor.cs deleted file mode 100644 index 797e946281..0000000000 --- a/sources/Maths/Maths/Scalar.Bitwise/Scalar.Xor.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - static partial class Scalar - { - /// - /// Performs Xor on supported types - /// - public static T Xor(T left, T right) where T : unmanaged - { - return Byte(left, right); - - [MethodImpl(MaxOpt)] - static T Byte(T left, T right) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) ((byte) (object) left ^ (byte) (object) right); - } - - return SByte(left, right); - } - - [MethodImpl(MaxOpt)] - static T SByte(T left, T right) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) ((sbyte) (object) left ^ (sbyte) (object) right); - } - - return UInt16(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt16(T left, T right) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) ((ushort) (object) left ^ (ushort) (object) right); - } - - return Int16(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int16(T left, T right) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) ((short) (object) left ^ (short) (object) right); - } - - return UInt32(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt32(T left, T right) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) ((uint) (object) left ^ (uint) (object) right); - } - - return Int32(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int32(T left, T right) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) ((int) (object) left ^ (int) (object) right); - } - - return UInt64(left, right); - } - - [MethodImpl(MaxOpt)] - static T UInt64(T left, T right) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) ((ulong) (object) left ^ (ulong) (object) right); - } - - return Int64(left, right); - } - - [MethodImpl(MaxOpt)] - static T Int64(T left, T right) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) ((long) (object) left ^ (long) (object) right); - } - - return Single(left, right); - } - - [MethodImpl(MaxOpt)] - static T Single(T left, T right) - { - if (typeof(T) == typeof(float)) - { - var res = Unsafe.As(ref left) ^ Unsafe.As(ref right); - return Unsafe.As(ref res); - } - - return Double(left, right); - } - - [MethodImpl(MaxOpt)] - static T Double(T left, T right) - { - if (typeof(T) == typeof(double)) - { - var res = Unsafe.As(ref left) ^ Unsafe.As(ref right); - return Unsafe.As(ref res); - } - - return Other(left, right); - } - - [MethodImpl(MaxOpt)] - static T Other(T left, T right) - { - ThrowUnsupportedType(); - return default; - } - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Constants.cs b/sources/Maths/Maths/Scalar.Constants.cs deleted file mode 100644 index fb15167d98..0000000000 --- a/sources/Maths/Maths/Scalar.Constants.cs +++ /dev/null @@ -1,387 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Numerics; -using System.Runtime.CompilerServices; - -// casting into non-nullable, unboxing from nullable -#pragma warning disable 8600 -#pragma warning disable 8605 - - -namespace Silk.NET.Maths -{ - /// - /// To be added. - /// - /// To be added. - public static partial class Scalar where T : notnull - { - /// - /// Represents the smallest positive value that is greater than zero. Zero for non-floating point numbers. - /// - public static readonly T Epsilon; - - /// - /// Represents the largest possible value. - /// - public static readonly T MaxValue; - - /// - /// Represents the smallest possible value. - /// - public static readonly T MinValue; - - /// - /// Represents not a number (NaN). Zero for non-floating point numbers. - /// - public static readonly T NaN; - - /// - /// Represents negative infinity. Zero for non-floating point numbers. - /// - public static readonly T NegativeInfinity; - - /// - /// Represents positive infinity. Zero for non-floating point numbers. - /// - public static readonly T PositiveInfinity; - - /// - /// Represents zero. - /// - public static readonly T Zero = default!; - - /// - /// Represents one. - /// - public static readonly T One; - - /// - /// Represents two. - /// - public static readonly T Two; - - /// - /// Represents negative one. - /// - public static readonly T MinusOne; - - /// - /// Represents negative two. - /// - public static readonly T MinusTwo; - - /// - /// Represents the natural logarithmic base, specified by the constant, e. - /// - public static readonly T E; - - /// - /// Represents the ratio of the circumference of a circle to its diameter, specified by the constant, π. - /// - public static readonly T Pi; - - /// - /// Represents Pi divided by two. - /// - public static readonly T PiOver2; - - /// - /// Represents the number of radians in one turn, specified by the constant, τ. - /// - public static readonly T Tau; - - /// - /// Represents the number of degrees in a single radian. - /// - /// - /// This is equivalent to 180 / MathF.Pi - /// - public static readonly T DegreesPerRadian; - - /// - /// Represents the number of radians in a single degree. - /// - /// - /// This is equivalent to MathF.Pi / 180. - /// - public static readonly T RadiansPerDegree; - - internal static readonly bool IntrinsicsApplicable = typeof(T) == typeof(byte) - || typeof(T) == typeof(sbyte) - || typeof(T) == typeof(ushort) - || typeof(T) == typeof(short) - || typeof(T) == typeof(uint) - || typeof(T) == typeof(int) - || typeof(T) == typeof(ulong) - || typeof(T) == typeof(long) - || typeof(T) == typeof(float) - || typeof(T) == typeof(double); - - private const float FloatE = 2.71828175f; - private const float FloatPi = 3.14159274f; - private const float FloatTau = 6.283185307f; - - [MethodImpl(Scalar.MaxOpt)] -#pragma warning disable 8618 // unitialized fields - static Scalar() -#pragma warning restore 8618 - { - // This won't inline as nicely on platforms that aren't .NET 5, however there's no other way to yield the - // constant folding benefits that come with the fields being static readonly. - // - // We have used local functions elsewhere to get around this elsewhere, however there's no sane way we can - // do that with local functions. - // - // This will inline fine on .NET 5, though. See also: https://github.com/dotnet/runtime/issues/38106 - if (typeof(T) == typeof(Half)) - { - Epsilon = (T) (object) Half.Epsilon; - MaxValue = (T) (object) Half.MaxValue; - MinValue = (T) (object) Half.MinValue; - NaN = (T) (object) Half.NaN; - NegativeInfinity = (T) (object) Half.NegativeInfinity; - PositiveInfinity = (T) (object) Half.PositiveInfinity; - One = (T) (object) (Half) 1; - Two = (T) (object) (Half) 2; - MinusOne = (T) (object) (Half) (-1f); - MinusTwo = (T) (object) (Half) (-2f); - E = (T) (object) (Half) FloatE; - Pi = (T) (object) (Half) FloatPi; - Tau = (T) (object) (Half) FloatTau; - } - else if (typeof(T) == typeof(float)) - { - Epsilon = (T) (object) float.Epsilon; - MaxValue = (T) (object) float.MaxValue; - MinValue = (T) (object) float.MinValue; - NaN = (T) (object) float.NaN; - NegativeInfinity = (T) (object) float.NegativeInfinity; - PositiveInfinity = (T) (object) float.PositiveInfinity; - One = (T) (object) 1f; - Two = (T) (object) 2f; - MinusOne = (T) (object) -1f; - MinusTwo = (T) (object) -2f; - E = (T) (object) FloatE; - Pi = (T) (object) FloatPi; - Tau = (T) (object) FloatTau; - } - else if (typeof(T) == typeof(double)) - { - Epsilon = (T) (object) double.Epsilon; - MaxValue = (T) (object) double.MaxValue; - MinValue = (T) (object) double.MinValue; - NaN = (T) (object) double.NaN; - NegativeInfinity = (T) (object) double.NegativeInfinity; - PositiveInfinity = (T) (object) double.PositiveInfinity; - One = (T) (object) 1d; - Two = (T) (object) 2d; - MinusOne = (T) (object) -1d; - MinusTwo = (T) (object) -2d; - E = (T) (object) Math.E; - Pi = (T) (object) Math.PI; -#if !NET5_0 - Tau = Scalar.Multiply(Pi, Two); -#else - Tau = (T) (object) Math.Tau; -#endif - } - else if (typeof(T) == typeof(decimal)) - { - Epsilon = default!; - MaxValue = (T) (object) decimal.MaxValue; - MinValue = (T) (object) decimal.MinValue; - NaN = default!; - NegativeInfinity = default!; - PositiveInfinity = default!; - One = (T) (object) (decimal) 1; - Two = (T) (object) (decimal) 2; - MinusOne = (T) (object) (decimal) -1; - MinusTwo = (T) (object) (decimal) -2; - E = (T) (object) (decimal) Math.E; - Pi = (T) (object) (decimal) Math.PI; - Tau = Scalar.Multiply(Pi, Two); - } - else if (typeof(T) == typeof(short)) - { - Epsilon = default!; - MaxValue = (T) (object) short.MaxValue; - MinValue = (T) (object) short.MinValue; - NaN = default!; - NegativeInfinity = default!; - PositiveInfinity = default!; - One = (T) (object) (short) 1; - Two = (T) (object) (short) 2; - MinusOne = (T) (object) (short) -1; - MinusTwo = (T) (object) (short) -2; - E = (T) (object) (short) FloatE; - Pi = (T) (object) (short) FloatPi; - Tau = (T) (object) (short) FloatTau; - } - else if (typeof(T) == typeof(ushort)) - { - Epsilon = default!; - MaxValue = (T) (object) ushort.MaxValue; - MinValue = (T) (object) ushort.MinValue; - NaN = default!; - NegativeInfinity = default!; - PositiveInfinity = default!; - One = (T) (object) (ushort) 1; - Two = (T) (object) (ushort) 2; - MinusOne = default!; - MinusTwo = default!; - E = (T) (object) (ushort) FloatE; - Pi = (T) (object) (ushort) FloatPi; - Tau = (T) (object) (ushort) FloatTau; - } - else if (typeof(T) == typeof(sbyte)) - { - Epsilon = default!; - MaxValue = (T) (object) sbyte.MaxValue; - MinValue = (T) (object) sbyte.MinValue; - NaN = default!; - NegativeInfinity = default!; - PositiveInfinity = default!; - One = (T) (object) (sbyte) 1; - Two = (T) (object) (sbyte) 2; - MinusOne = (T) (object) (sbyte) -1; - MinusTwo = (T) (object) (sbyte) -2; - E = (T) (object) (sbyte) FloatE; - Pi = (T) (object) (sbyte) FloatPi; - Tau = (T) (object) (sbyte) FloatTau; - } - else if (typeof(T) == typeof(byte)) - { - Epsilon = default!; - MaxValue = (T) (object) byte.MaxValue; - MinValue = (T) (object) byte.MinValue; - NaN = default!; - NegativeInfinity = default!; - PositiveInfinity = default!; - One = (T) (object) (byte) 1; - Two = (T) (object) (byte) 2; - MinusOne = default!; - MinusTwo = default!; - E = (T) (object) (byte) FloatE; - Pi = (T) (object) (byte) FloatPi; - Tau = (T) (object) (byte) FloatTau; - } - else if (typeof(T) == typeof(int)) - { - Epsilon = default!; - MaxValue = (T) (object) int.MaxValue; - MinValue = (T) (object) int.MinValue; - NaN = default!; - NegativeInfinity = default!; - PositiveInfinity = default!; - One = (T) (object) 1; - Two = (T) (object) 2; - MinusOne = (T) (object) -1; - MinusTwo = (T) (object) -2; - E = (T) (object) (int) FloatE; - Pi = (T) (object) (int) FloatPi; - Tau = (T) (object) (int) FloatTau; - } - else if (typeof(T) == typeof(uint)) - { - Epsilon = default!; - MaxValue = (T) (object) uint.MaxValue; - MinValue = (T) (object) uint.MinValue; - NaN = default!; - NegativeInfinity = default!; - PositiveInfinity = default!; - One = (T) (object) 1u; - Two = (T) (object) 2u; - MinusOne = default!; - MinusTwo = default!; - E = (T) (object) (uint) FloatE; - Pi = (T) (object) (uint) FloatPi; - Tau = (T) (object) (uint) FloatTau; - } - else if (typeof(T) == typeof(long)) - { - Epsilon = default!; - MaxValue = (T) (object) long.MaxValue; - MinValue = (T) (object) long.MinValue; - NaN = default!; - NegativeInfinity = default!; - PositiveInfinity = default!; - One = (T) (object) 1L; - Two = (T) (object) 2L; - MinusOne = (T) (object) -1L; - MinusTwo = (T) (object) -2L; - E = (T) (object) (long) FloatE; - Pi = (T) (object) (long) FloatPi; - Tau = (T) (object) (long) FloatTau; - } - else if (typeof(T) == typeof(ulong)) - { - Epsilon = default!; - MaxValue = (T) (object) ulong.MaxValue; - MinValue = (T) (object) ulong.MinValue; - NaN = default!; - NegativeInfinity = default!; - PositiveInfinity = default!; - One = (T) (object) 1ul; - Two = (T) (object) 2ul; - MinusOne = default!; - MinusTwo = default!; - E = (T) (object) (ulong) FloatE; - Pi = (T) (object) (ulong) FloatPi; - Tau = (T) (object) (ulong) FloatTau; - } - else if (typeof(T) == typeof(BigInteger)) - { - Epsilon = default!; - MaxValue = default!; - MinValue = default!; - NaN = default!; - NegativeInfinity = default!; - PositiveInfinity = default!; - One = (T) (object) BigInteger.One; - Two = (T) (object) (BigInteger) 2; - MinusOne = default!; - MinusTwo = default!; - E = (T) (object) (BigInteger) FloatE; - Pi = (T) (object) (BigInteger) FloatPi; - Tau = (T) (object) (BigInteger) FloatTau; - } - else if (typeof(T) == typeof(Complex)) - { - Epsilon = (T) (object) (Complex)double.Epsilon; - MaxValue = default!; - MinValue = default!; -#if NETCOREAPP3_0_OR_GREATER - NaN = (T) (object) Complex.NaN; -#else -// https://source.dot.net/#System.Runtime.Numerics/System/Numerics/Complex.cs,d2c68d149ad2b6de - NaN = (T) (object) new Complex(double.NaN, double.NaN); -#endif - NegativeInfinity = default!; - PositiveInfinity = default!; - One = (T) (object) (Complex) 1; - Two = (T) (object) (Complex) 2; - MinusOne = (T) (object) (Complex) (-1d); - MinusTwo = (T) (object) (Complex) (-2d); - E = (T) (object) (Complex) Math.E; - Pi = (T) (object) (Complex) Math.PI; -#if !NET5_0 - Tau = Scalar.Multiply(Pi, Two); -#else - Tau = (T) (object) (Complex) Math.Tau; -#endif - } - else - { - // if it's none of these cases, don't do the general cases. - return; - } - - PiOver2 = Scalar.Divide(Pi, Two); - DegreesPerRadian = Scalar.Divide(Scalar.As(180), Pi); - RadiansPerDegree = Scalar.Divide(Pi, Scalar.As(180)); - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Conversions.cs b/sources/Maths/Maths/Scalar.Conversions.cs deleted file mode 100644 index 19e83e4f72..0000000000 --- a/sources/Maths/Maths/Scalar.Conversions.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// casting into non-nullable, unboxing from nullable -#pragma warning disable 8600 -#pragma warning disable 8605 - -namespace Silk.NET.Maths -{ - public partial class Scalar - { - /// - /// Convert degrees to radians. - /// - /// An angle in degrees. - /// The angle expressed in radians. - public static T DegreesToRadians(T degrees) where T : notnull => Multiply(degrees, Scalar.RadiansPerDegree); - - /// - /// Convert radians to degrees. - /// - /// An angle in radians. - /// The angle expressed in degrees. - public static T RadiansToDegrees(T radians) where T : notnull => Multiply(radians, Scalar.DegreesPerRadian); - } -} diff --git a/sources/Maths/Maths/Scalar.Exp.cs b/sources/Maths/Maths/Scalar.Exp.cs deleted file mode 100644 index 3588353b27..0000000000 --- a/sources/Maths/Maths/Scalar.Exp.cs +++ /dev/null @@ -1,244 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// ported / adopted from https://github.com/amd/aocl-libm-ose/tree/master/src/optmized - -/* - * Copyright (C) 2008-2020 Advanced Micro Devices, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -using System; -using System.Runtime.CompilerServices; -#if SSE -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -#endif - -namespace Silk.NET.Maths -{ - public static partial class Scalar - { - private static ulong[] InitExp() - { -#if POH - var two_to_jby64 = GC.AllocateUninitializedArray(64, true); -#else - var two_to_jby64 = new ulong[64]; -#endif - int i = 0; - two_to_jby64[i++] = 0x3ff0000000000000; - two_to_jby64[i++] = 0x3fefec9a3e778061; - two_to_jby64[i++] = 0x3fefd9b0d3158574; - two_to_jby64[i++] = 0x3fefc74518759bc8; - two_to_jby64[i++] = 0x3fefb5586cf9890f; - two_to_jby64[i++] = 0x3fefa3ec32d3d1a2; - two_to_jby64[i++] = 0x3fef9301d0125b51; - two_to_jby64[i++] = 0x3fef829aaea92de0; - two_to_jby64[i++] = 0x3fef72b83c7d517b; - two_to_jby64[i++] = 0x3fef635beb6fcb75; - two_to_jby64[i++] = 0x3fef54873168b9aa; - two_to_jby64[i++] = 0x3fef463b88628cd6; - two_to_jby64[i++] = 0x3fef387a6e756238; - two_to_jby64[i++] = 0x3fef2b4565e27cdd; - two_to_jby64[i++] = 0x3fef1e9df51fdee1; - two_to_jby64[i++] = 0x3fef1285a6e4030b; - two_to_jby64[i++] = 0x3fef06fe0a31b715; - two_to_jby64[i++] = 0x3feefc08b26416ff; - two_to_jby64[i++] = 0x3feef1a7373aa9cb; - two_to_jby64[i++] = 0x3feee7db34e59ff7; - two_to_jby64[i++] = 0x3feedea64c123422; - two_to_jby64[i++] = 0x3feed60a21f72e2a; - two_to_jby64[i++] = 0x3feece086061892d; - two_to_jby64[i++] = 0x3feec6a2b5c13cd0; - two_to_jby64[i++] = 0x3feebfdad5362a27; - two_to_jby64[i++] = 0x3feeb9b2769d2ca7; - two_to_jby64[i++] = 0x3feeb42b569d4f82; - two_to_jby64[i++] = 0x3feeaf4736b527da; - two_to_jby64[i++] = 0x3feeab07dd485429; - two_to_jby64[i++] = 0x3feea76f15ad2148; - two_to_jby64[i++] = 0x3feea47eb03a5585; - two_to_jby64[i++] = 0x3feea23882552225; - two_to_jby64[i++] = 0x3feea09e667f3bcd; - two_to_jby64[i++] = 0x3fee9fb23c651a2f; - two_to_jby64[i++] = 0x3fee9f75e8ec5f74; - two_to_jby64[i++] = 0x3fee9feb564267c9; - two_to_jby64[i++] = 0x3feea11473eb0187; - two_to_jby64[i++] = 0x3feea2f336cf4e62; - two_to_jby64[i++] = 0x3feea589994cce13; - two_to_jby64[i++] = 0x3feea8d99b4492ed; - two_to_jby64[i++] = 0x3feeace5422aa0db; - two_to_jby64[i++] = 0x3feeb1ae99157736; - two_to_jby64[i++] = 0x3feeb737b0cdc5e5; - two_to_jby64[i++] = 0x3feebd829fde4e50; - two_to_jby64[i++] = 0x3feec49182a3f090; - two_to_jby64[i++] = 0x3feecc667b5de565; - two_to_jby64[i++] = 0x3feed503b23e255d; - two_to_jby64[i++] = 0x3feede6b5579fdbf; - two_to_jby64[i++] = 0x3feee89f995ad3ad; - two_to_jby64[i++] = 0x3feef3a2b84f15fb; - two_to_jby64[i++] = 0x3feeff76f2fb5e47; - two_to_jby64[i++] = 0x3fef0c1e904bc1d2; - two_to_jby64[i++] = 0x3fef199bdd85529c; - two_to_jby64[i++] = 0x3fef27f12e57d14b; - two_to_jby64[i++] = 0x3fef3720dcef9069; - two_to_jby64[i++] = 0x3fef472d4a07897c; - two_to_jby64[i++] = 0x3fef5818dcfba487; - two_to_jby64[i++] = 0x3fef69e603db3285; - two_to_jby64[i++] = 0x3fef7c97337b9b5f; - two_to_jby64[i++] = 0x3fef902ee78b3ff6; - two_to_jby64[i++] = 0x3fefa4afa2a490da; - two_to_jby64[i++] = 0x3fefba1bee615a27; - two_to_jby64[i++] = 0x3fefd0765b6e4540; - two_to_jby64[i++] = 0x3fefe7c1819e90d8; - - return two_to_jby64; - } - - private static ulong[] __two_to_jby64 = InitExp(); - - [MethodImpl(MaxOpt)] - private static float CoreFastExp(float x) - { - [MethodImpl(MaxOpt)] - static unsafe uint top12f(float x) => asuint32(x) >> 20; - - [MethodImpl(MaxOpt)] - static unsafe uint asuint32(float x) - { -#if SSE - if (Sse.IsSupported) - return Vector128.CreateScalarUnsafe(x).AsUInt32().ToScalar(); // ToScalar "relies" on Sse (the fallback is garbage) - else -#endif - return *(uint*) &x; // this produces bad codegen on < net5 - } - - [MethodImpl(MaxOpt)] - static unsafe float asfloat(uint x) - { -#if SSE - if (Sse.IsSupported) - return Vector128.CreateScalarUnsafe(x).AsSingle().ToScalar(); // ToScalar "relies" on Sse (the fallback is garbage) - else -#endif - return *(float*) &x; // this produces bad codegen on < net5 - } - - [MethodImpl(MaxOpt)] - static unsafe ulong asuint64(double x) - { -#if SSE - if (Sse.IsSupported) - return Vector128.CreateScalarUnsafe(x).AsUInt64().ToScalar(); // ToScalar "relies" on Sse (the fallback is garbage) - else -#endif - return *(ulong*) &x; // this produces bad codegen on < net5 - } - - [MethodImpl(MaxOpt)] - static unsafe double asdouble(ulong x) - { -#if SSE - if (Sse.IsSupported) - return Vector128.CreateScalarUnsafe(x).AsDouble().ToScalar(); // ToScalar "relies" on Sse (the fallback is garbage) - else -#endif - return *(double*) &x; // this produces bad codegen on < net5 - } - - double q, dn, r, z; - ulong n, j; - - uint top = top12f(x); - - if ((top <= top12f(88.0f))) // inverted for likeliness - { - goto ENDCHECK; - } - else - { - if (float.IsNaN(x)) - return x; - - if (float.IsNegativeInfinity(x)) - return 0.0f; - - const float EXPF_FARG_MAX = 3.5990256e+33f; - // const int EXP_Y_INF = 3; - // const int EXP_Y_ZERO = 2; - const float EXPF_FARG_MIN = -103.972076416f; - const uint PINFBITPATT_SP32 = 0x7f800000; - - if (x > EXPF_FARG_MAX) - { - if (asuint32(x) == PINFBITPATT_SP32) - return asfloat(PINFBITPATT_SP32); - - return float.PositiveInfinity; - } - - if (x < EXPF_FARG_MIN) - { - return 1f; - } - } - - ENDCHECK: - const float EXPF_TBLSZ_BY_LN2 = 92.3324826169f; - const float EXPF_HUGE = 6.7553994e+15f; - const float EXPF_LN2_BY_TBLSZ = 0.01083042469f; - const int EXPF_N = 6; - const int EXPF_TABLE_SIZE = (1 << EXPF_N); - z = x * EXPF_TBLSZ_BY_LN2; - - /* - * n = (int) scale(x) - * dn = (double) n - */ - dn = z + EXPF_HUGE; - - n = asuint64(dn); - - dn -= EXPF_HUGE; - - r = x - dn * EXPF_LN2_BY_TBLSZ; - - j = n % EXPF_TABLE_SIZE; - - double qtmp = 0.5f + (0.26567055393f * r); - - double r2 = r * r; - - double tbl = asdouble(__two_to_jby64[j] + (n << (52 - EXPF_N))); - - q = r + (r2 * qtmp); - - double result = tbl + tbl * q; - - return (float) (result); - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Inverse.cs b/sources/Maths/Maths/Scalar.Inverse.cs deleted file mode 100644 index f92d5f5c22..0000000000 --- a/sources/Maths/Maths/Scalar.Inverse.cs +++ /dev/null @@ -1,185 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Numerics; -using System.Runtime.CompilerServices; - -// casting into non-nullable, unboxing from nullable -#pragma warning disable 8600 -#pragma warning disable 8605 - -namespace Silk.NET.Maths -{ - public static partial class Scalar - { - /// - /// Calculates the reciprocal of a number. - /// - /// The number. - /// The type of . - /// The reciprocal of the given number. - [MethodImpl(MaxOpt)] - public static T Reciprocal(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) (1f / (float) (Half) (object) x); - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) (1f / (float) (object) x); - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) (1d / (double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - return (T) (object) (decimal.One / (decimal) (object) x); - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) (((sbyte) 1) / (sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) (((byte) 1) / (byte) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) (((ushort) 1) / (ushort) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) (((short) 1) / (short) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (((uint) 1) / (uint) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (((int) 1) / (int) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - - return (T) (object) (((ulong) 1) / (ulong) (object) x); - - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (((long) 1) / (long) (object) x); - } - - return BigInteger(x); - } - - [MethodImpl(MaxOpt)] - static T BigInteger(T x) - { - if (typeof(T) == typeof(BigInteger)) - { - return (T)(object)(1 / (BigInteger)(object)x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T)(object)(1 / (Complex)(object)x); - } - - return Other(x); - } - - [MethodImpl(MaxOpt)] - static T Other(T _) - { - ThrowUnsupportedType(); - return default!; - } - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Log.cs b/sources/Maths/Maths/Scalar.Log.cs deleted file mode 100644 index a286fda059..0000000000 --- a/sources/Maths/Maths/Scalar.Log.cs +++ /dev/null @@ -1,307 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// ported / adopted from https://github.com/amd/aocl-libm-ose/tree/master/src/optmized - -/* - * Copyright (C) 2008-2020 Advanced Micro Devices, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -using System; -using System.Runtime.CompilerServices; -#if SSE -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -#endif - -namespace Silk.NET.Maths -{ - public static partial class Scalar - { - private static uint[] InitLog() - { -#if POH - var logTblLookup = GC.AllocateUninitializedArray(771, true); -#else - var logTblLookup = new uint[771]; -#endif - int i = 0; - logTblLookup[i++] = 0x40000000; logTblLookup[i++] = 0x0; logTblLookup[i++] = 0x0; logTblLookup[i++] = 0x3fff00ff; logTblLookup[i++] = 0x3b7f8000; logTblLookup[i++] = 0x32aa2b11; logTblLookup[i++] = 0x3ffe03f8; logTblLookup[i++] = 0x3bff0000; logTblLookup[i++] = 0x3429ac42; logTblLookup[i++] = - 0x3ffd08e5; logTblLookup[i++] = 0x3c3ee000; logTblLookup[i++] = 0x350ebf02; logTblLookup[i++] = 0x3ffc0fc1; logTblLookup[i++] = 0x3c7e0000; logTblLookup[i++] = 0x35a8b0fc; logTblLookup[i++] = 0x3ffb1885; logTblLookup[i++] = 0x3c9e7000; logTblLookup[i++] = -0x36244347; logTblLookup[i++] = 0x3ffa232d; logTblLookup[i++] = 0x3cbdc000; logTblLookup[i++] = 0x368d83eb; logTblLookup[i++] = 0x3ff92fb2; logTblLookup[i++] = 0x3cdcf000; logTblLookup[i++] = 0x36e013d8; logTblLookup[i++] = 0x3ff83e10; logTblLookup[i++] = -0x3cfc1000; logTblLookup[i++] = 0x361b0e78; logTblLookup[i++] = 0x3ff74e40; logTblLookup[i++] = 0x3d0d8000; logTblLookup[i++] = 0x36d98924; logTblLookup[i++] = 0x3ff6603e; logTblLookup[i++] = 0x3d1cf000; logTblLookup[i++] = 0x3687b9ff; logTblLookup[i++] = -0x3ff57404; logTblLookup[i++] = 0x3d2c5000; logTblLookup[i++] = 0x36375f92; logTblLookup[i++] = 0x3ff4898d; logTblLookup[i++] = 0x3d3ba000; logTblLookup[i++] = 0x3631ec66; logTblLookup[i++] = 0x3ff3a0d5; logTblLookup[i++] = 0x3d4ae000; logTblLookup[i++] = -0x36830ec9; logTblLookup[i++] = 0x3ff2b9d6; logTblLookup[i++] = 0x3d5a1000; logTblLookup[i++] = 0x36dd7119; logTblLookup[i++] = 0x3ff1d48c; logTblLookup[i++] = 0x3d693000; logTblLookup[i++] = 0x3735c56e; logTblLookup[i++] = 0x3ff0f0f1; logTblLookup[i++] = -0x3d785000; logTblLookup[i++] = 0x35c30046; logTblLookup[i++] = 0x3ff00f01; logTblLookup[i++] = 0x3d83a000; logTblLookup[i++] = 0x37cc1acc; logTblLookup[i++] = 0x3fef2eb7; logTblLookup[i++] = 0x3d8b2000; logTblLookup[i++] = 0x379b7752; logTblLookup[i++] = -0x3fee500f; logTblLookup[i++] = 0x3d929000; logTblLookup[i++] = 0x37fb1785; logTblLookup[i++] = 0x3fed7304; logTblLookup[i++] = 0x3d9a0000; logTblLookup[i++] = 0x37ebcb0e; logTblLookup[i++] = 0x3fec9791; logTblLookup[i++] = 0x3da17000; logTblLookup[i++] = -0x375cbea6; logTblLookup[i++] = 0x3febbdb3; logTblLookup[i++] = 0x3da8d000; logTblLookup[i++] = 0x37839f83; logTblLookup[i++] = 0x3feae564; logTblLookup[i++] = 0x3db03000; logTblLookup[i++] = 0x36b1526f; logTblLookup[i++] = 0x3fea0ea1; logTblLookup[i++] = -0x3db78000; logTblLookup[i++] = 0x37528ae5; logTblLookup[i++] = 0x3fe93965; logTblLookup[i++] = 0x3dbed000; logTblLookup[i++] = 0x36ecdaf6; logTblLookup[i++] = 0x3fe865ac; logTblLookup[i++] = 0x3dc61000; logTblLookup[i++] = 0x37a2eb19; logTblLookup[i++] = -0x3fe79373; logTblLookup[i++] = 0x3dcd5000; logTblLookup[i++] = 0x37a12310; logTblLookup[i++] = 0x3fe6c2b4; logTblLookup[i++] = 0x3dd49000; logTblLookup[i++] = 0x36da7496; logTblLookup[i++] = 0x3fe5f36d; logTblLookup[i++] = 0x3ddbc000; logTblLookup[i++] = -0x37482bb1; logTblLookup[i++] = 0x3fe52598; logTblLookup[i++] = 0x3de2f000; logTblLookup[i++] = 0x36a91eb8; logTblLookup[i++] = 0x3fe45933; logTblLookup[i++] = 0x3dea1000; logTblLookup[i++] = 0x3789eb36; logTblLookup[i++] = 0x3fe38e39; logTblLookup[i++] = -0x3df13000; logTblLookup[i++] = 0x3783b715; logTblLookup[i++] = 0x3fe2c4a7; logTblLookup[i++] = 0x3df85000; logTblLookup[i++] = 0x36430046; logTblLookup[i++] = 0x3fe1fc78; logTblLookup[i++] = 0x3dff6000; logTblLookup[i++] = 0x371131dc; logTblLookup[i++] = -0x3fe135aa; logTblLookup[i++] = 0x3e033000; logTblLookup[i++] = 0x380a8965; logTblLookup[i++] = 0x3fe07038; logTblLookup[i++] = 0x3e06b000; logTblLookup[i++] = 0x383f3e68; logTblLookup[i++] = 0x3fdfac1f; logTblLookup[i++] = 0x3e0a3000; logTblLookup[i++] = -0x3842c234; logTblLookup[i++] = 0x3fdee95c; logTblLookup[i++] = 0x3e0db000; logTblLookup[i++] = 0x38156a98; logTblLookup[i++] = 0x3fde27eb; logTblLookup[i++] = 0x3e113000; logTblLookup[i++] = 0x375e3215; logTblLookup[i++] = 0x3fdd67c9; logTblLookup[i++] = -0x3e14a000; logTblLookup[i++] = 0x38297c10; logTblLookup[i++] = 0x3fdca8f1; logTblLookup[i++] = 0x3e181000; logTblLookup[i++] = 0x386b8c72; logTblLookup[i++] = 0x3fdbeb62; logTblLookup[i++] = 0x3e1b8000; logTblLookup[i++] = 0x387e100f; logTblLookup[i++] = -0x3fdb2f17; logTblLookup[i++] = 0x3e1ef000; logTblLookup[i++] = 0x38615876; logTblLookup[i++] = 0x3fda740e; logTblLookup[i++] = 0x3e226000; logTblLookup[i++] = 0x3815b666; logTblLookup[i++] = 0x3fd9ba42; logTblLookup[i++] = 0x3e25d000; logTblLookup[i++] = -0x36dbce69; logTblLookup[i++] = 0x3fd901b2; logTblLookup[i++] = 0x3e293000; logTblLookup[i++] = 0x37e5e3a2; logTblLookup[i++] = 0x3fd84a5a; logTblLookup[i++] = 0x3e2c9000; logTblLookup[i++] = 0x381c6ccc; logTblLookup[i++] = 0x3fd79436; logTblLookup[i++] = -0x3e2ff000; logTblLookup[i++] = 0x38183854; logTblLookup[i++] = 0x3fd6df44; logTblLookup[i++] = 0x3e335000; logTblLookup[i++] = 0x37cd4273; logTblLookup[i++] = 0x3fd62b81; logTblLookup[i++] = 0x3e36b000; logTblLookup[i++] = 0x35fe719d; logTblLookup[i++] = -0x3fd578e9; logTblLookup[i++] = 0x3e3a0000; logTblLookup[i++] = 0x37f8f540; logTblLookup[i++] = 0x3fd4c77b; logTblLookup[i++] = 0x3e3d5000; logTblLookup[i++] = 0x38448108; logTblLookup[i++] = 0x3fd41733; logTblLookup[i++] = 0x3e40a000; logTblLookup[i++] = -0x386050a2; logTblLookup[i++] = 0x3fd3680d; logTblLookup[i++] = 0x3e43f000; logTblLookup[i++] = 0x38503290; logTblLookup[i++] = 0x3fd2ba08; logTblLookup[i++] = 0x3e474000; logTblLookup[i++] = 0x38146f44; logTblLookup[i++] = 0x3fd20d21; logTblLookup[i++] = -0x3e4a9000; logTblLookup[i++] = 0x373539e9; logTblLookup[i++] = 0x3fd16154; logTblLookup[i++] = 0x3e4dd000; logTblLookup[i++] = 0x381b173f; logTblLookup[i++] = 0x3fd0b6a0; logTblLookup[i++] = 0x3e511000; logTblLookup[i++] = 0x385e0ff1; logTblLookup[i++] = -0x3fd00d01; logTblLookup[i++] = 0x3e545000; logTblLookup[i++] = 0x38767e44; logTblLookup[i++] = 0x3fcf6475; logTblLookup[i++] = 0x3e579000; logTblLookup[i++] = 0x3864a740; logTblLookup[i++] = 0x3fcebcf9; logTblLookup[i++] = 0x3e5ad000; logTblLookup[i++] = -0x3828cf48; logTblLookup[i++] = 0x3fce168a; logTblLookup[i++] = 0x3e5e1000; logTblLookup[i++] = 0x3786742e; logTblLookup[i++] = 0x3fcd7127; logTblLookup[i++] = 0x3e614000; logTblLookup[i++] = 0x38342ac6; logTblLookup[i++] = 0x3fcccccd; logTblLookup[i++] = -0x3e647000; logTblLookup[i++] = 0x387be3cd; logTblLookup[i++] = 0x3fcc2978; logTblLookup[i++] = 0x3e67b000; logTblLookup[i++] = 0x36d53827; logTblLookup[i++] = 0x3fcb8728; logTblLookup[i++] = 0x3e6ae000; logTblLookup[i++] = 0x3685ad3f; logTblLookup[i++] = -0x3fcae5d8; logTblLookup[i++] = 0x3e6e0000; logTblLookup[i++] = 0x385e5056; logTblLookup[i++] = 0x3fca4588; logTblLookup[i++] = 0x3e713000; logTblLookup[i++] = 0x3803b715; logTblLookup[i++] = 0x3fc9a634; logTblLookup[i++] = 0x3e746000; logTblLookup[i++] = -0x3494aa97; logTblLookup[i++] = 0x3fc907da; logTblLookup[i++] = 0x3e778000; logTblLookup[i++] = 0x37adcbdc; logTblLookup[i++] = 0x3fc86a79; logTblLookup[i++] = 0x3e7aa000; logTblLookup[i++] = 0x38052b26; logTblLookup[i++] = 0x3fc7ce0c; logTblLookup[i++] = -0x3e7dc000; logTblLookup[i++] = 0x380c36af; logTblLookup[i++] = 0x3fc73294; logTblLookup[i++] = 0x3e807000; logTblLookup[i++] = 0x37d88b5b; logTblLookup[i++] = 0x3fc6980c; logTblLookup[i++] = 0x3e820000; logTblLookup[i++] = 0x371652d3; logTblLookup[i++] = -0x3fc5fe74; logTblLookup[i++] = 0x3e838000; logTblLookup[i++] = 0x38dc2fe7; logTblLookup[i++] = 0x3fc565c8; logTblLookup[i++] = 0x3e851000; logTblLookup[i++] = 0x3892713a; logTblLookup[i++] = 0x3fc4ce08; logTblLookup[i++] = 0x3e86a000; logTblLookup[i++] = -0x37d6af35; logTblLookup[i++] = 0x3fc43730; logTblLookup[i++] = 0x3e882000; logTblLookup[i++] = 0x38c5fcd7; logTblLookup[i++] = 0x3fc3a13e; logTblLookup[i++] = 0x3e89b000; logTblLookup[i++] = 0x38070294; logTblLookup[i++] = 0x3fc30c31; logTblLookup[i++] = -0x3e8b3000; logTblLookup[i++] = 0x38ae55d6; logTblLookup[i++] = 0x3fc27806; logTblLookup[i++] = 0x3e8cc000; logTblLookup[i++] = 0x3652dd42; logTblLookup[i++] = 0x3fc1e4bc; logTblLookup[i++] = 0x3e8e4000; logTblLookup[i++] = 0x3818c16a; logTblLookup[i++] = -0x3fc15250; logTblLookup[i++] = 0x3e8fc000; logTblLookup[i++] = 0x387f9e49; logTblLookup[i++] = 0x3fc0c0c1; logTblLookup[i++] = 0x3e914000; logTblLookup[i++] = 0x38a0fde8; logTblLookup[i++] = 0x3fc0300c; logTblLookup[i++] = 0x3e92c000; logTblLookup[i++] = -0x38b00870; logTblLookup[i++] = 0x3fbfa030; logTblLookup[i++] = 0x3e944000; logTblLookup[i++] = 0x38ad09ef; logTblLookup[i++] = 0x3fbf112b; logTblLookup[i++] = 0x3e95c000; logTblLookup[i++] = 0x38981d5c; logTblLookup[i++] = 0x3fbe82fa; logTblLookup[i++] = -0x3e974000; logTblLookup[i++] = 0x3862bae1; logTblLookup[i++] = 0x3fbdf59d; logTblLookup[i++] = 0x3e98c000; logTblLookup[i++] = 0x37e392a9; logTblLookup[i++] = 0x3fbd6910; logTblLookup[i++] = 0x3e9a3000; logTblLookup[i++] = 0x38eecd4c; logTblLookup[i++] = -0x3fbcdd53; logTblLookup[i++] = 0x3e9bb000; logTblLookup[i++] = 0x38933160; logTblLookup[i++] = 0x3fbc5264; logTblLookup[i++] = 0x3e9d3000; logTblLookup[i++] = 0x3798aad3; logTblLookup[i++] = 0x3fbbc841; logTblLookup[i++] = 0x3e9ea000; logTblLookup[i++] = -0x38a7d2e1; logTblLookup[i++] = 0x3fbb3ee7; logTblLookup[i++] = 0x3ea02000; logTblLookup[i++] = 0x37421a1b; logTblLookup[i++] = 0x3fbab656; logTblLookup[i++] = 0x3ea19000; logTblLookup[i++] = 0x386f2a05; logTblLookup[i++] = 0x3fba2e8c; logTblLookup[i++] = -0x3ea30000; logTblLookup[i++] = 0x38c5e10e; logTblLookup[i++] = 0x3fb9a786; logTblLookup[i++] = 0x3ea48000; logTblLookup[i++] = 0x35d00801; logTblLookup[i++] = 0x3fb92144; logTblLookup[i++] = 0x3ea5f000; logTblLookup[i++] = 0x37bf2aef; logTblLookup[i++] = -0x3fb89bc3; logTblLookup[i++] = 0x3ea76000; logTblLookup[i++] = 0x38173260; logTblLookup[i++] = 0x3fb81703; logTblLookup[i++] = 0x3ea8d000; logTblLookup[i++] = 0x382d872e; logTblLookup[i++] = 0x3fb79301; logTblLookup[i++] = 0x3eaa4000; logTblLookup[i++] = -0x3822c3ae; logTblLookup[i++] = 0x3fb70fbb; logTblLookup[i++] = 0x3eabb000; logTblLookup[i++] = 0x37ee2e8b; logTblLookup[i++] = 0x3fb68d31; logTblLookup[i++] = 0x3ead2000; logTblLookup[i++] = 0x372ac3d3; logTblLookup[i++] = 0x3fb60b61; logTblLookup[i++] = -0x3eae8000; logTblLookup[i++] = 0x38dedfac; logTblLookup[i++] = 0x3fb58a48; logTblLookup[i++] = 0x3eaff000; logTblLookup[i++] = 0x38983854; logTblLookup[i++] = 0x3fb509e7; logTblLookup[i++] = 0x3eb16000; logTblLookup[i++] = 0x3802f2ba; logTblLookup[i++] = -0x3fb48a3a; logTblLookup[i++] = 0x3eb2c000; logTblLookup[i++] = 0x38dab982; logTblLookup[i++] = 0x3fb40b41; logTblLookup[i++] = 0x3eb43000; logTblLookup[i++] = 0x38481e9b; logTblLookup[i++] = 0x3fb38cfa; logTblLookup[i++] = 0x3eb59000; logTblLookup[i++] = -0x38dd911b; logTblLookup[i++] = 0x3fb30f63; logTblLookup[i++] = 0x3eb70000; logTblLookup[i++] = 0x380eaa2c; logTblLookup[i++] = 0x3fb2927c; logTblLookup[i++] = 0x3eb86000; logTblLookup[i++] = 0x38a1713c; logTblLookup[i++] = 0x3fb21643; logTblLookup[i++] = -0x3eb9c000; logTblLookup[i++] = 0x38ebfb5e; logTblLookup[i++] = 0x3fb19ab6; logTblLookup[i++] = 0x3ebb3000; logTblLookup[i++] = 0x379c2474; logTblLookup[i++] = 0x3fb11fd4; logTblLookup[i++] = 0x3ebc9000; logTblLookup[i++] = 0x38255fdd; logTblLookup[i++] = -0x3fb0a59b; logTblLookup[i++] = 0x3ebdf000; logTblLookup[i++] = 0x385e0a38; logTblLookup[i++] = 0x3fb02c0b; logTblLookup[i++] = 0x3ebf5000; logTblLookup[i++] = 0x38783b83; logTblLookup[i++] = 0x3fafb322; logTblLookup[i++] = 0x3ec0b000; logTblLookup[i++] = -0x38741da1; logTblLookup[i++] = 0x3faf3ade; logTblLookup[i++] = 0x3ec21000; logTblLookup[i++] = 0x3851da1f; logTblLookup[i++] = 0x3faec33e; logTblLookup[i++] = 0x3ec37000; logTblLookup[i++] = 0x38119a33; logTblLookup[i++] = 0x3fae4c41; logTblLookup[i++] = -0x3ec4d000; logTblLookup[i++] = 0x374e1b05; logTblLookup[i++] = 0x3fadd5e6; logTblLookup[i++] = 0x3ec62000; logTblLookup[i++] = 0x38dbe42c; logTblLookup[i++] = 0x3fad602b; logTblLookup[i++] = 0x3ec78000; logTblLookup[i++] = 0x388f439b; logTblLookup[i++] = -0x3faceb10; logTblLookup[i++] = 0x3ec8e000; logTblLookup[i++] = 0x37cfd68b; logTblLookup[i++] = 0x3fac7692; logTblLookup[i++] = 0x3eca3000; logTblLookup[i++] = 0x38ca0e11; logTblLookup[i++] = 0x3fac02b0; logTblLookup[i++] = 0x3ecb9000; logTblLookup[i++] = -0x38234113; logTblLookup[i++] = 0x3fab8f6a; logTblLookup[i++] = 0x3ecce000; logTblLookup[i++] = 0x38cac08c; logTblLookup[i++] = 0x3fab1cbe; logTblLookup[i++] = 0x3ece4000; logTblLookup[i++] = 0x37d605b8; logTblLookup[i++] = 0x3faaaaab; logTblLookup[i++] = -0x3ecf9000; logTblLookup[i++] = 0x3891f660; logTblLookup[i++] = 0x3faa392f; logTblLookup[i++] = 0x3ed0e000; logTblLookup[i++] = 0x38e0326b; logTblLookup[i++] = 0x3fa9c84a; logTblLookup[i++] = 0x3ed24000; logTblLookup[i++] = 0x378121cb; logTblLookup[i++] = -0x3fa957fb; logTblLookup[i++] = 0x3ed39000; logTblLookup[i++] = 0x3824966c; logTblLookup[i++] = 0x3fa8e83f; logTblLookup[i++] = 0x3ed4e000; logTblLookup[i++] = 0x386c9a9a; logTblLookup[i++] = 0x3fa87917; logTblLookup[i++] = 0x3ed63000; logTblLookup[i++] = -0x388c612c; logTblLookup[i++] = 0x3fa80a81; logTblLookup[i++] = 0x3ed78000; logTblLookup[i++] = 0x38949924; logTblLookup[i++] = 0x3fa79c7b; logTblLookup[i++] = 0x3ed8d000; logTblLookup[i++] = 0x388f075f; logTblLookup[i++] = 0x3fa72f05; logTblLookup[i++] = -0x3eda2000; logTblLookup[i++] = 0x38777bcd; logTblLookup[i++] = 0x3fa6c21e; logTblLookup[i++] = 0x3edb7000; logTblLookup[i++] = 0x38359d3d; logTblLookup[i++] = 0x3fa655c4; logTblLookup[i++] = 0x3edcc000; logTblLookup[i++] = 0x37b12d26; logTblLookup[i++] = -0x3fa5e9f7; logTblLookup[i++] = 0x3ede0000; logTblLookup[i++] = 0x38f04587; logTblLookup[i++] = 0x3fa57eb5; logTblLookup[i++] = 0x3edf5000; logTblLookup[i++] = 0x38a6ced4; logTblLookup[i++] = 0x3fa513fd; logTblLookup[i++] = 0x3ee0a000; logTblLookup[i++] = -0x381ff116; logTblLookup[i++] = 0x3fa4a9cf; logTblLookup[i++] = 0x3ee1e000; logTblLookup[i++] = 0x38ebd3e7; logTblLookup[i++] = 0x3fa44029; logTblLookup[i++] = 0x3ee33000; logTblLookup[i++] = 0x3874e3ff; logTblLookup[i++] = 0x3fa3d70a; logTblLookup[i++] = -0x3ee47000; logTblLookup[i++] = 0x38fbe3cd; logTblLookup[i++] = 0x3fa36e72; logTblLookup[i++] = 0x3ee5c000; logTblLookup[i++] = 0x3860744d; logTblLookup[i++] = 0x3fa3065e; logTblLookup[i++] = 0x3ee70000; logTblLookup[i++] = 0x38d785c3; logTblLookup[i++] = -0x3fa29ecf; logTblLookup[i++] = 0x3ee85000; logTblLookup[i++] = 0x37c75ce4; logTblLookup[i++] = 0x3fa237c3; logTblLookup[i++] = 0x3ee99000; logTblLookup[i++] = 0x387e7e01; logTblLookup[i++] = 0x3fa1d13a; logTblLookup[i++] = 0x3eead000; logTblLookup[i++] = -0x38bfcd71; logTblLookup[i++] = 0x3fa16b31; logTblLookup[i++] = 0x3eec1000; logTblLookup[i++] = 0x38f392c5; logTblLookup[i++] = 0x3fa105a9; logTblLookup[i++] = 0x3eed6000; logTblLookup[i++] = 0x3754f8b1; logTblLookup[i++] = 0x3fa0a0a1; logTblLookup[i++] = -0x3eeea000; logTblLookup[i++] = 0x37d40984; logTblLookup[i++] = 0x3fa03c17; logTblLookup[i++] = 0x3eefe000; logTblLookup[i++] = 0x38059907; logTblLookup[i++] = 0x3f9fd80a; logTblLookup[i++] = 0x3ef12000; logTblLookup[i++] = 0x38081a7c; logTblLookup[i++] = -0x3f9f747a; logTblLookup[i++] = 0x3ef26000; logTblLookup[i++] = 0x37e350d1; logTblLookup[i++] = 0x3f9f1166; logTblLookup[i++] = 0x3ef3a000; logTblLookup[i++] = 0x3784c3ad; logTblLookup[i++] = 0x3f9eaecd; logTblLookup[i++] = 0x3ef4d000; logTblLookup[i++] = -0x38fd32cc; logTblLookup[i++] = 0x3f9e4cad; logTblLookup[i++] = 0x3ef61000; logTblLookup[i++] = 0x38cce923; logTblLookup[i++] = 0x3f9deb07; logTblLookup[i++] = 0x3ef75000; logTblLookup[i++] = 0x38906320; logTblLookup[i++] = 0x3f9d89d9; logTblLookup[i++] = -0x3ef89000; logTblLookup[i++] = 0x380f5faf; logTblLookup[i++] = 0x3f9d2922; logTblLookup[i++] = 0x3ef9c000; logTblLookup[i++] = 0x38f2de41; logTblLookup[i++] = 0x3f9cc8e1; logTblLookup[i++] = 0x3efb0000; logTblLookup[i++] = 0x3891fd38; logTblLookup[i++] = -0x3f9c6917; logTblLookup[i++] = 0x3efc4000; logTblLookup[i++] = 0x37946dfd; logTblLookup[i++] = 0x3f9c09c1; logTblLookup[i++] = 0x3efd7000; logTblLookup[i++] = 0x38ac47bc; logTblLookup[i++] = 0x3f9baadf; logTblLookup[i++] = 0x3efeb000; logTblLookup[i++] = -0x379e41ec; logTblLookup[i++] = 0x3f9b4c70; logTblLookup[i++] = 0x3effe000; logTblLookup[i++] = 0x3897042c; logTblLookup[i++] = 0x3f9aee73; logTblLookup[i++] = 0x3f008000; logTblLookup[i++] = 0x397d5893; logTblLookup[i++] = 0x3f9a90e8; logTblLookup[i++] = -0x3f012000; logTblLookup[i++] = 0x392952d3; logTblLookup[i++] = 0x3f9a33cd; logTblLookup[i++] = 0x3f01c000; logTblLookup[i++] = 0x389eefce; logTblLookup[i++] = 0x3f99d723; logTblLookup[i++] = 0x3f025000; logTblLookup[i++] = 0x396fced5; logTblLookup[i++] = -0x3f997ae7; logTblLookup[i++] = 0x3f02f000; logTblLookup[i++] = 0x390a5e93; logTblLookup[i++] = 0x3f991f1a; logTblLookup[i++] = 0x3f039000; logTblLookup[i++] = 0x37f97073; logTblLookup[i++] = 0x3f98c3bb; logTblLookup[i++] = 0x3f042000; logTblLookup[i++] = -0x392e4426; logTblLookup[i++] = 0x3f9868c8; logTblLookup[i++] = 0x3f04c000; logTblLookup[i++] = 0x385e9eae; logTblLookup[i++] = 0x3f980e41; logTblLookup[i++] = 0x3f055000; logTblLookup[i++] = 0x393b5f67; logTblLookup[i++] = 0x3f97b426; logTblLookup[i++] = -0x3f05f000; logTblLookup[i++] = 0x3865c84a; logTblLookup[i++] = 0x3f975a75; logTblLookup[i++] = 0x3f068000; logTblLookup[i++] = 0x3931e65d; logTblLookup[i++] = 0x3f97012e; logTblLookup[i++] = 0x3f072000; logTblLookup[i++] = 0x38130ba4; logTblLookup[i++] = -0x3f96a850; logTblLookup[i++] = 0x3f07b000; logTblLookup[i++] = 0x39120e4e; logTblLookup[i++] = 0x3f964fda; logTblLookup[i++] = 0x3f084000; logTblLookup[i++] = 0x3979cf17; logTblLookup[i++] = 0x3f95f7cc; logTblLookup[i++] = 0x3f08e000; logTblLookup[i++] = -0x38b81788; logTblLookup[i++] = 0x3f95a025; logTblLookup[i++] = 0x3f097000; logTblLookup[i++] = 0x3938caca; logTblLookup[i++] = 0x3f9548e5; logTblLookup[i++] = 0x3f0a1000; logTblLookup[i++] = 0x37809491; logTblLookup[i++] = 0x3f94f209; logTblLookup[i++] = -0x3f0aa000; logTblLookup[i++] = 0x38c3d2f5; logTblLookup[i++] = 0x3f949b93; logTblLookup[i++] = 0x3f0b3000; logTblLookup[i++] = 0x392e55d6; logTblLookup[i++] = 0x3f944581; logTblLookup[i++] = 0x3f0bc000; logTblLookup[i++] = 0x39755dec; logTblLookup[i++] = -0x3f93efd2; logTblLookup[i++] = 0x3f0c6000; logTblLookup[i++] = 0x385c1fec; logTblLookup[i++] = 0x3f939a86; logTblLookup[i++] = 0x3f0cf000; logTblLookup[i++] = 0x38e6b468; logTblLookup[i++] = 0x3f93459c; logTblLookup[i++] = 0x3f0d8000; logTblLookup[i++] = -0x392a5abf; logTblLookup[i++] = 0x3f92f114; logTblLookup[i++] = 0x3f0e1000; logTblLookup[i++] = 0x395c0fb9; logTblLookup[i++] = 0x3f929cec; logTblLookup[i++] = 0x3f0eb000; logTblLookup[i++] = 0x3707f33c; logTblLookup[i++] = 0x3f924925; logTblLookup[i++] = -0x3f0f4000; logTblLookup[i++] = 0x383ebce1; logTblLookup[i++] = 0x3f91f5bd; logTblLookup[i++] = 0x3f0fd000; logTblLookup[i++] = 0x38a34b87; logTblLookup[i++] = 0x3f91a2b4; logTblLookup[i++] = 0x3f106000; logTblLookup[i++] = 0x38dcd193; logTblLookup[i++] = -0x3f915009; logTblLookup[i++] = 0x3f10f000; logTblLookup[i++] = 0x3905fe33; logTblLookup[i++] = 0x3f90fdbc; logTblLookup[i++] = 0x3f118000; logTblLookup[i++] = 0x39186bdf; logTblLookup[i++] = 0x3f90abcc; logTblLookup[i++] = 0x3f121000; logTblLookup[i++] = -0x3925b7a4; logTblLookup[i++] = 0x3f905a38; logTblLookup[i++] = 0x3f12a000; logTblLookup[i++] = 0x392de74c; logTblLookup[i++] = 0x3f900901; logTblLookup[i++] = 0x3f133000; logTblLookup[i++] = 0x3931009a; logTblLookup[i++] = 0x3f8fb824; logTblLookup[i++] = -0x3f13c000; logTblLookup[i++] = 0x392f0945; logTblLookup[i++] = 0x3f8f67a2; logTblLookup[i++] = 0x3f145000; logTblLookup[i++] = 0x392806fb; logTblLookup[i++] = 0x3f8f177a; logTblLookup[i++] = 0x3f14e000; logTblLookup[i++] = 0x391bff61; logTblLookup[i++] = -0x3f8ec7ab; logTblLookup[i++] = 0x3f157000; logTblLookup[i++] = 0x390af813; logTblLookup[i++] = 0x3f8e7835; logTblLookup[i++] = 0x3f160000; logTblLookup[i++] = 0x38e9ed45; logTblLookup[i++] = 0x3f8e2918; logTblLookup[i++] = 0x3f169000; logTblLookup[i++] = -0x38b4012f; logTblLookup[i++] = 0x3f8dda52; logTblLookup[i++] = 0x3f172000; logTblLookup[i++] = 0x38686dc8; logTblLookup[i++] = 0x3f8d8be3; logTblLookup[i++] = 0x3f17b000; logTblLookup[i++] = 0x37aa6542; logTblLookup[i++] = 0x3f8d3dcb; logTblLookup[i++] = -0x3f183000; logTblLookup[i++] = 0x396b99a8; logTblLookup[i++] = 0x3f8cf009; logTblLookup[i++] = 0x3f18c000; logTblLookup[i++] = 0x393d07d4; logTblLookup[i++] = 0x3f8ca29c; logTblLookup[i++] = 0x3f195000; logTblLookup[i++] = 0x39099c89; logTblLookup[i++] = -0x3f8c5584; logTblLookup[i++] = 0x3f19e000; logTblLookup[i++] = 0x38a2ba33; logTblLookup[i++] = 0x3f8c08c1; logTblLookup[i++] = 0x3f1a7000; logTblLookup[i++] = 0x37a27674; logTblLookup[i++] = 0x3f8bbc51; logTblLookup[i++] = 0x3f1af000; logTblLookup[i++] = -0x395276ea; logTblLookup[i++] = 0x3f8b7034; logTblLookup[i++] = 0x3f1b8000; logTblLookup[i++] = 0x390bdaa4; logTblLookup[i++] = 0x3f8b246b; logTblLookup[i++] = 0x3f1c1000; logTblLookup[i++] = 0x3880fe58; logTblLookup[i++] = 0x3f8ad8f3; logTblLookup[i++] = -0x3f1c9000; logTblLookup[i++] = 0x397069ab; logTblLookup[i++] = 0x3f8a8dcd; logTblLookup[i++] = 0x3f1d2000; logTblLookup[i++] = 0x391b9f3f; logTblLookup[i++] = 0x3f8a42f8; logTblLookup[i++] = 0x3f1db000; logTblLookup[i++] = 0x38844a00; logTblLookup[i++] = -0x3f89f874; logTblLookup[i++] = 0x3f1e3000; logTblLookup[i++] = 0x3963fffc; logTblLookup[i++] = 0x3f89ae41; logTblLookup[i++] = 0x3f1ec000; logTblLookup[i++] = 0x39013539; logTblLookup[i++] = 0x3f89645c; logTblLookup[i++] = 0x3f1f5000; logTblLookup[i++] = -0x37ce4dad; logTblLookup[i++] = 0x3f891ac7; logTblLookup[i++] = 0x3f1fd000; logTblLookup[i++] = 0x392dc269; logTblLookup[i++] = 0x3f88d181; logTblLookup[i++] = 0x3f206000; logTblLookup[i++] = 0x38749102; logTblLookup[i++] = 0x3f888889; logTblLookup[i++] = -0x3f20e000; logTblLookup[i++] = 0x3947f423; logTblLookup[i++] = 0x3f883fde; logTblLookup[i++] = 0x3f217000; logTblLookup[i++] = 0x389c6de0; logTblLookup[i++] = 0x3f87f781; logTblLookup[i++] = 0x3f21f000; logTblLookup[i++] = 0x394ff17d; logTblLookup[i++] = -0x3f87af70; logTblLookup[i++] = 0x3f228000; logTblLookup[i++] = 0x389a5134; logTblLookup[i++] = 0x3f8767ab; logTblLookup[i++] = 0x3f230000; logTblLookup[i++] = 0x3945e10e; logTblLookup[i++] = 0x3f872033; logTblLookup[i++] = 0x3f239000; logTblLookup[i++] = -0x38687e67; logTblLookup[i++] = 0x3f86d905; logTblLookup[i++] = 0x3f241000; logTblLookup[i++] = 0x3929e8f5; logTblLookup[i++] = 0x3f869223; logTblLookup[i++] = 0x3f24a000; logTblLookup[i++] = 0x37aa0e8c; logTblLookup[i++] = 0x3f864b8a; logTblLookup[i++] = -0x3f252000; logTblLookup[i++] = 0x38f85db0; logTblLookup[i++] = 0x3f86053c; logTblLookup[i++] = 0x3f25a000; logTblLookup[i++] = 0x395eb4ab; logTblLookup[i++] = 0x3f85bf37; logTblLookup[i++] = 0x3f263000; logTblLookup[i++] = 0x38735f9a; logTblLookup[i++] = -0x3f85797c; logTblLookup[i++] = 0x3f26b000; logTblLookup[i++] = 0x39169d1d; logTblLookup[i++] = 0x3f853408; logTblLookup[i++] = 0x3f273000; logTblLookup[i++] = 0x396c08dc; logTblLookup[i++] = 0x3f84eedd; logTblLookup[i++] = 0x3f27c000; logTblLookup[i++] = -0x38747ea0; logTblLookup[i++] = 0x3f84a9fa; logTblLookup[i++] = 0x3f284000; logTblLookup[i++] = 0x3909e601; logTblLookup[i++] = 0x3f84655e; logTblLookup[i++] = 0x3f28c000; logTblLookup[i++] = 0x3952605d; logTblLookup[i++] = 0x3f842108; logTblLookup[i++] = -0x3f295000; logTblLookup[i++] = 0x37b4996f; logTblLookup[i++] = 0x3f83dcf9; logTblLookup[i++] = 0x3f29d000; logTblLookup[i++] = 0x38ad05ba; logTblLookup[i++] = 0x3f839930; logTblLookup[i++] = 0x3f2a5000; logTblLookup[i++] = 0x391233cd; logTblLookup[i++] = -0x3f8355ad; logTblLookup[i++] = 0x3f2ad000; logTblLookup[i++] = 0x3949aa5a; logTblLookup[i++] = 0x3f83126f; logTblLookup[i++] = 0x3f2b5000; logTblLookup[i++] = 0x397ceada; logTblLookup[i++] = 0x3f82cf75; logTblLookup[i++] = 0x3f2be000; logTblLookup[i++] = -0x382fe66e; logTblLookup[i++] = 0x3f828cc0; logTblLookup[i++] = 0x3f2c6000; logTblLookup[i++] = 0x38adb5cd; logTblLookup[i++] = 0x3f824a4e; logTblLookup[i++] = 0x3f2ce000; logTblLookup[i++] = 0x38fb25fb; logTblLookup[i++] = 0x3f820821; logTblLookup[i++] = -0x3f2d6000; logTblLookup[i++] = 0x3920261b; logTblLookup[i++] = 0x3f81c636; logTblLookup[i++] = 0x3f2de000; logTblLookup[i++] = 0x393e9874; logTblLookup[i++] = 0x3f81848e; logTblLookup[i++] = 0x3f2e6000; logTblLookup[i++] = 0x3958ee36; logTblLookup[i++] = -0x3f814328; logTblLookup[i++] = 0x3f2ee000; logTblLookup[i++] = 0x396f2b8a; logTblLookup[i++] = 0x3f810204; logTblLookup[i++] = 0x3f2f7000; logTblLookup[i++] = 0x35aa4906; logTblLookup[i++] = 0x3f80c122; logTblLookup[i++] = 0x3f2ff000; logTblLookup[i++] = -0x3776d68c; logTblLookup[i++] = 0x3f808081; logTblLookup[i++] = 0x3f307000; logTblLookup[i++] = 0x37cbd11e; logTblLookup[i++] = 0x3f804020; logTblLookup[i++] = 0x3f30f000; logTblLookup[i++] = 0x37fbf692; logTblLookup[i++] = 0x3f800000; logTblLookup[i++] = -0x3f317000; logTblLookup[i++] = 0x3805fdf4; - - return logTblLookup; - } - - private static uint[] _logTblLookup = InitLog(); - - [MethodImpl(MaxOpt)] - private static unsafe float CoreFastLog(float x) - { - [MethodImpl(MaxOpt)] - static unsafe uint asuint(float x) - { -#if SSE - if (Sse.IsSupported) - return Vector128.CreateScalarUnsafe(x).AsUInt32().ToScalar(); // ToScalar "relies" on Sse (the fallback is garbage) - else -#endif - return *(uint*) &x; // this produces bad codegen on < net5 - } - - [MethodImpl(MaxOpt)] - static unsafe float asfloat(uint x) - { -#if SSE - if (Sse.IsSupported) - return Vector128.CreateScalarUnsafe(x).AsSingle().ToScalar(); // ToScalar "relies" on Sse (the fallback is garbage) - else -#endif - return *(float*) &x; // this produces bad codegen on < net5 - } - - uint ux = asuint(x); - - - if (ux - 0x00800000 < 0x7f800000 - 0x00800000) // inverted because likeliness - { - goto EndCheck; - } - else - { - /* x < 0x1p-126 or inf or nan. */ - if (ux * 2 == 0) /* log(0) = -inf */ - return float.NegativeInfinity; - if (ux == 0x7f800000) /* log(inf) = inf */ - return x; - if ((ux & 0x80000000) > 0 || ux * 2 >= 0xff000000) - return float.NaN; - - /* - * 'x' has to be denormal, Normalize it - * there is a possibility that only the last (23'rd) bit is set - * Hence multiply by 2^23 to bring to 1.xxxxx format. - */ - ux = asuint(x * 8388608); - ux -= 23 << 23; - } - - EndCheck: - const int EXPSHIFTBITS_SP32 = 23; // number of bits to shift left to get the exponent - // exponent bias, calculated as (2^(k-1)) - 1, were k = number of bits used to encode the exponent - const int EMAX_SP32 = 127; - const int MANTBITS_SP32 = 0x007fffff; // the bits the mantissa takes up - - int expo = (int) ((ux >> EXPSHIFTBITS_SP32) - EMAX_SP32); - float f_expo = (float) expo; - - const uint NEAR_ONE_LO = 0b111111011100000000000000000000; // BitConverter.SingleToInt32Bits(1 - 1 * 0.0625f); - const uint NEAR_ONE_HI = 0b111111110101010000000000000000; // BitConverter.SingleToInt32Bits(1 + 1.0625f * 0.0625f); - - // Values not very close to 1, !(e^(-1/16) <= x <= e^(1/16) - if (ux - NEAR_ONE_LO >= NEAR_ONE_HI - NEAR_ONE_LO) - { - /* - * Here onwards, 'x' is neither -ve, nor close to 1 - */ - uint mant, mant1, idx; - float y, f, finv, r, r2, q, w; - - const int MASK_MANT_ALL7 = 0b_1111111_10000000_00000000; - // const int MASK_MANT8 = 0x00008000; - mant = ux & MANTBITS_SP32; - mant1 = ux & MASK_MANT_ALL7; - /*This step is needed for more accuracy */ - /* mant1 += ((ux & MASK_MANT8) << 1); */ - - const int LOGF_N = 8; - idx = mant1 >> (EXPSHIFTBITS_SP32 - LOGF_N); - - const int HALFEXPBITS_SP32 = 0b_111111_00000000_00000000_00000000; - y = asfloat(mant | HALFEXPBITS_SP32); - f = asfloat(mant1 | HALFEXPBITS_SP32); - - float f_128_head; - float f_128_tail; -#if POH - var tbl = ((uint*)Unsafe.AsPointer(ref _logTblLookup[0])) + (idx * 3); - finv = asfloat(tbl[0]); - f_128_head = asfloat(tbl[1]); - f_128_tail = asfloat(tbl[2]); -#else - fixed (uint* tbl = _logTblLookup) - { - var p = tbl + (idx * 3); - finv = asfloat(p[0]); - f_128_head = asfloat(p[1]); - f_128_tail = asfloat(p[2]); - } -#endif - - r = (f - y) * finv; - const float C1 = .5f; - const float C2 = 3.333333432674407958984375E-1f; // 1/3 - - r2 = r * r; /* r^2 */ - q = r + (r2 * (C1 + r * C2)); - - const float LOG2_TAIL = 1.18725025653839111328f * 0.00000762939f; - q = (f_expo * LOG2_TAIL) - q; - - const float LOG2_HEAD = 1.3862762451171875f * 0.5f; - w = (LOG2_HEAD * f_expo) + f_128_head; - - q = f_128_tail + q + w; - - return q; - - } - else - { - [MethodImpl(MaxOpt)] - static float InlineLog1Pf(float x) - { - float r, r2, w; - - r = x - 1.0f; - - w = r / (2.0f + r); - - float correction = w * r; - - w += w; - - float w2 = w * w; - - const float A1 = 8.33333333333317923934e-02f; - const float A2 = 1.25000000037717509602e-02f; - - r2 = (w * w2 * (A1 + A2 * w2)) - correction; - - float f = r2 + r; - - return f; - } - - return InlineLog1Pf(x); - } - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.MathFPort.MissingMethods.cs b/sources/Maths/Maths/Scalar.MathFPort.MissingMethods.cs deleted file mode 100644 index 638c0d03f0..0000000000 --- a/sources/Maths/Maths/Scalar.MathFPort.MissingMethods.cs +++ /dev/null @@ -1,379 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - partial class Scalar - { - ///////////////////////////////////////////////// BEGIN GO CODE /////////////////////////////////////////////// - - // Adapted from https://golang.org/src/math/atanh.go - // ==================================================== - // Copyright 2010 The Go Authors. All rights reserved. - // Use of this source code is governed by a BSD-style - // license that can be found in the LICENSE file. - // ==================================================== - // The original C code, the long comment, and the constants - // below are from FreeBSD's /usr/src/lib/msun/src/e_atanh.c - // and came with this notice. The go code is a simplified - // version of the original C. - // ==================================================== - // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - // - // Developed at SunPro, a Sun Microsystems, Inc. business. - // Permission to use, copy, modify, and distribute this - // software is freely granted, provided that this notice - // is preserved. - // ==================================================== - [MethodImpl(MaxOpt)] - private static double CoreAtanh(double x) - { - const double nearZero = 1.0 / (1 << 28); // 2**-28 - // special cases - if (x < -1 || x > 1 || double.IsNaN(x)) - { - return double.NaN; - } - - switch (x) - { - case 1: - { - return double.PositiveInfinity; - } - case -1: - { - return double.NegativeInfinity; - } - } - - var sign = false; - if (x < 0) - { - x = -x; - sign = true; - } - - double temp; - if (x < nearZero) - { - temp = x; - } - else if (x < 0.5) - { - temp = x + x; - temp = 0.5 * Log1P(temp + temp * x / (1 - x)); - } - else - { - temp = 0.5 * Log1P((x + x) / (1 - x)); - } - - if (sign) - { - temp = -temp; - } - - return temp; - } - - // Adapted from: https://golang.org/src/math/log1p.go - // ==================================================== - // Copyright 2010 The Go Authors. All rights reserved. - // Use of this source code is governed by a BSD-style - // license that can be found in the LICENSE file. - // ==================================================== - // The original C code, the long comment, and the constants - // below are from FreeBSD's /usr/src/lib/msun/src/s_log1p.c - // and came with this notice. The go code is a simplified - // version of the original C. - // ==================================================== - // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - // - // Developed at SunPro, a Sun Microsystems, Inc. business. - // Permission to use, copy, modify, and distribute this - // software is freely granted, provided that this notice - // is preserved. - // ==================================================== - - [MethodImpl(MaxOpt)] - private static unsafe double Log1P(double x) - { - const double sqrt2M1 = 4.142135623730950488017e-01; // Sqrt(2)-1 = 0x3fda827999fcef34 - const double sqrt2HalfM1 = -2.928932188134524755992e-01; // Sqrt(2)/2-1 = 0xbfd2bec333018866 - const double small = 1.0 / (1 << 29); // 2**-29 = 0x3e20000000000000 - const double tiny = 1.0 / (1L << 54); // 2**-54 - const double two53 = 1L << 53; // 2**53 - const double ln2Hi = 6.93147180369123816490e-01; // 3fe62e42fee00000 - const double ln2Lo = 1.90821492927058770002e-10; // 3dea39ef35793c76 - const double lp1 = 6.666666666666735130e-01; // 3FE5555555555593 - const double lp2 = 3.999999999940941908e-01; // 3FD999999997FA04 - const double lp3 = 2.857142874366239149e-01; // 3FD2492494229359 - const double lp4 = 2.222219843214978396e-01; // 3FCC71C51D8E78AF - const double lp5 = 1.818357216161805012e-01; // 3FC7466496CB03DE - const double lp6 = 1.531383769920937332e-01; // 3FC39A09D078C69F - const double lp7 = 1.479819860511658591e-01; // 3FC2F112DF3E5244 - - // special cases - if (x < -1 || double.IsNaN(x)) - { - // includes -Inf - return double.NaN; - } - - if (x == -1) - { - return double.NegativeInfinity; - } - - if (double.IsPositiveInfinity(x)) - { - return double.PositiveInfinity; - } - - var absx = x; - if (absx < 0) - { - absx = -absx; - } - - double f = default; - ulong iu = default; - var k = 1; - if (absx < sqrt2M1) - { - // |x| < Sqrt(2)-1 - if (absx < small) - { - // |x| < 2**-29 - if (absx < tiny) - { - // |x| < 2**-54 - return x; - } - - return x - x * x * 0.5; - } - - if (x > sqrt2HalfM1) - { - // Sqrt(2)/2-1 < x - // (Sqrt(2)/2-1) < x < (Sqrt(2)-1) - k = 0; - f = x; - iu = 1; - } - } - - double c = default; - if (k != 0) - { - double u; - if (absx < two53) - { - // 1<<53 - u = 1.0 + x; - var ius = BitConverter.DoubleToInt64Bits(u); - iu = *(ulong*) &ius; - k = (int) ((iu >> 52) - 1023); - // correction term - if (k > 0) - { - c = 1.0 - (u - x); - } - else - { - c = x - (u - 1.0); - } - - c /= u; - } - else - { - u = x; - var ius = BitConverter.DoubleToInt64Bits(u); - iu = *(ulong*) &ius; - k = (int) ((iu >> 52) - 1023); - c = 0; - } - - iu &= 0x000fffffffffffff; - if (iu < 0x0006a09e667f3bcd) - { - // mantissa of Sqrt(2) - var uu = iu | 0x3ff0000000000000; - u = BitConverter.Int64BitsToDouble(*(long*) &uu); // normalize u - } - else - { - k++; - var uu = iu | 0x3fe0000000000000; - u = BitConverter.Int64BitsToDouble(*(long*) &uu); // normalize u/2 - iu = (0x0010000000000000 - iu) >> 2; - } - - f = u - 1.0; // Sqrt(2)/2 < u < Sqrt(2) - } - - var hfsq = 0.5 * f * f; - double s, r, z; - if (iu == 0) - { - // |f| < 2**-20 - if (f == 0) - { - if (k == 0) - { - return 0; - } - - c += k * ln2Lo; - return k * ln2Hi + c; - } - - r = hfsq * (1.0 - 0.66666666666666666 * f); // avoid division - if (k == 0) - { - return f - r; - } - - return k * ln2Hi - (r - (k * ln2Lo + c) - f); - } - - s = f / (2.0 + f); - z = s * s; - - r = z * (lp1 + z * (lp2 + z * (lp3 + z * (lp4 + z * (lp5 + z * (lp6 + z * lp7)))))); - if (k == 0) - { - return f - (hfsq - s * (hfsq + r)); - } - - return k * ln2Hi - (hfsq - (s * (hfsq + r) + (k * ln2Lo + c)) - f); - } - - // Adapted from: https://golang.org/src/math/acosh.go - // ==================================================== - // Copyright 2010 The Go Authors. All rights reserved. - // Use of this source code is governed by a BSD-style - // license that can be found in the LICENSE file. - // ==================================================== - // The original C code, the long comment, and the constants - // below are from FreeBSD's /usr/src/lib/msun/src/e_acosh.c - // and came with this notice. The go code is a simplified - // version of the original C. - // ==================================================== - // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - // - // Developed at SunPro, a Sun Microsystems, Inc. business. - // Permission to use, copy, modify, and distribute this - // software is freely granted, provided that this notice - // is preserved. - // ==================================================== - [MethodImpl(MaxOpt)] - private static double CoreAcosh(double x) - { - const double ln2 = 6.93147180559945286227e-01; // 0x3FE62E42FEFA39EF - const double large = 1 << 28; // 2**28 - // first case is special case - if (x < 1 || double.IsNaN(x)) - { - return double.NaN; - } - - if (x == 1) - { - return 0; - } - - if (x >= large) - { - return Log(x) + ln2; // x > 2**28 - } - - if (x > 2) - { - return Log(2 * x - 1 / (x + Sqrt(x * x - 1))); // 2**28 > x > 2 - } - - var t = x - 1; - return Log1P(t + Sqrt(2 * t + t * t)); // 2 >= x > 1 - } - - // Adapted from: https://golang.org/src/math/asinh.go - // ==================================================== - // Copyright 2010 The Go Authors. All rights reserved. - // Use of this source code is governed by a BSD-style - // license that can be found in the LICENSE file. - // ==================================================== - // The original C code, the long comment, and the constants - // below are from FreeBSD's /usr/src/lib/msun/src/s_asinh.c - // and came with this notice. The go code is a simplified - // version of the original C. - // ==================================================== - // Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - // - // Developed at SunPro, a Sun Microsystems, Inc. business. - // Permission to use, copy, modify, and distribute this - // software is freely granted, provided that this notice - // is preserved. - // ==================================================== - [MethodImpl(MaxOpt)] - private static double CoreAsinh(double x) - { - const double ln2 = 6.93147180559945286227e-01; // 0x3FE62E42FEFA39EF - const double nearZero = 1.0 / (1 << 28); // 2**-28 - const double large = 1 << 28; // 2**28 - // special cases - if (IsNaN(x) || double.IsInfinity(x)) - { - return x; - } - - var sign = false; - if (x < 0) - { - x = -x; - sign = true; - } - - double temp; - if (x > large) - { - temp = Log(x) + ln2; // |x| > 2**28 - } - else if (x > 2) - { - temp = Log(2 * x + 1 / (Sqrt(x * x + 1) + x)); // 2**28 > |x| > 2.0 - } - else if (x < nearZero) - { - temp = x; // |x| < 2**-28 - } - else - { - temp = Log1P(x + x * x / (1 + Sqrt(1 + x * x))); // 2.0 > |x| > 2**-28 - } - - if (sign) - { - temp = -temp; - } - - return temp; - } - - ////////////////////////////////////////////////// END GO CODE //////////////////////////////////////////////// - - [MethodImpl(MaxOpt)] - private static double CoreCbrt(double x) -#if NETSTANDARD2_0 - => Math.Ceiling(Math.Pow(x, 1d / 3)); -#else - => Math.Cbrt(x); -#endif - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.MathFPort.cs b/sources/Maths/Maths/Scalar.MathFPort.cs deleted file mode 100644 index f42d9d3897..0000000000 --- a/sources/Maths/Maths/Scalar.MathFPort.cs +++ /dev/null @@ -1,5658 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Numerics; -using System.Runtime.CompilerServices; -#if SSE || AdvSIMD -using System.Runtime.Intrinsics; -#endif -#if SSE -using System.Runtime.Intrinsics.X86; -#endif -#if AdvSIMD -using System.Runtime.Intrinsics.Arm; -#endif - -// it doesn't like default because it may be null -#pragma warning disable 8603 - -namespace Silk.NET.Maths -{ - public static partial class Scalar - { - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // This partial contains the helper methods which forward to MathF or Math, used a lot within Silk.NET.Maths - // - // For the most part, these are pretty direct forwards. However there are a lot of unnecessary up-casts in a lot - // of places. Possible tasks could be: - // a) TODO identifying where we're up-casting unnecessarily - // (it's done a lot throughout this file as System.Math pretty much only supports double) - // b) TODO removing unnecessary up-casts with dedicated, managed methods. - // c) TODO implement any unimplemented methods - // Ctrl+F for ThrowOpUnsupportedPrecision - // - // These should be done around 2.0 Preview 5 time, but if you're reading this comment after 2.0's initial - // release then feel free to PR in some of these changes as we clearly have failed. - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - /// - /// Returns the absolute value of a number. - /// - /// The value to get the absolute of - /// The type of - /// The absolute of the given value - [MethodImpl(MaxOpt)] - public static unsafe T Abs(T x) where T : unmanaged - { - if (typeof(T) == typeof(Half)) - { -#if NET5_0 && INTRINSICS - if (Sse2.IsSupported) - { - return (T)(object)(Half)Sse.And(Vector128.CreateScalarUnsafe((float) (Half) (object) x), Vector128.Create(-0.0f)).ToScalar(); - } - else if (AdvSimd.IsSupported) - { - return (T)(object)(Half)AdvSimd.And(Vector128.CreateScalarUnsafe((float) (Half) (object) x), Vector128.Create(-0.0f)).ToScalar(); - } - else -#elif NETCOREAPP3_1 && INTRINSICS - if (Sse.IsSupported) - { - return (T)(object)(Half)Sse.And(Vector128.CreateScalarUnsafe((float) (Half) (object) x), Vector128.CreateScalarUnsafe(-0.0f)).ToScalar(); - } - else -#endif - { - var v = *(ushort*) &x; - v &= 0x7FFF; - return *(T*) &v; - } - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if NET5_0 && INTRINSICS - if (Sse.IsSupported) - { - return (T)(object)(float)Sse.And(Vector128.CreateScalarUnsafe((float)(object)x), Vector128.Create((uint)0x7FFF_FFFF).AsSingle()).ToScalar(); - } - else if (AdvSimd.IsSupported) - { - return (T) (object) (float)AdvSimd.AbsScalar(Vector64.CreateScalarUnsafe((float) (object) x)).ToScalar(); - } - else -#elif NETCOREAPP3_1 && INTRINSICS - if (Sse.IsSupported) - { - return (T)(object)(float)Sse.And(Vector128.CreateScalarUnsafe((float)(object)x), Vector128.CreateScalarUnsafe((uint)0x7FFF_FFFF).AsSingle()).ToScalar(); - } - else -#endif - { - var v = *(uint*) &x; - v &= 0x7FFF_FFFF; - return *(T*) &v; - } - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { -#if NET5_0 && INTRINSICS - if (Sse2.IsSupported) - { - return (T)(object)(double)Sse2.And(Vector128.CreateScalarUnsafe((double)(object)x), Vector128.Create((ulong)0x7FFF_FFFF_FFFF_FFF).AsDouble()).ToScalar(); - } - else if (AdvSimd.IsSupported) - { - return (T) (object) (double)AdvSimd.AbsScalar(Vector64.CreateScalar((double) (object) x)).ToScalar(); - } - else -#elif NETCOREAPP3_1 && INTRINSICS - if (Sse2.IsSupported) - { - return (T)(object)(double)Sse2.And(Vector128.CreateScalarUnsafe((double)(object)x), Vector128.CreateScalarUnsafe((ulong)0x7FFF_FFFF_FFFF_FFF).AsDouble()).ToScalar(); - } - else -#endif - { - var v = *(ulong*) &x; - v &= 0x7FFF_FFFF_FFFF_FFFF; - return *(T*) &v; - } - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { -#if SSE - if (Ssse3.IsSupported) - { - return (T)(object)(sbyte)Ssse3.Abs(Vector128.CreateScalar((sbyte) (object) x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T) (object) (sbyte)AdvSimd.Abs(Vector64.CreateScalar((sbyte) (object) x)).ToScalar(); - } -#endif - var px = (sbyte) (object) x; - sbyte mask = (sbyte) (px >> (sizeof(sbyte) - 1)); - return (T) (object) (sbyte) ((px + mask) ^ mask); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return x; - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { -#if SSE - if (Ssse3.IsSupported) - { - return (T)(object)(int)Ssse3.Abs(Vector128.CreateScalar((int) (object) x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T) (object)(int) AdvSimd.Abs(Vector64.CreateScalar((int) (object) x)).ToScalar(); - } -#endif - var px = (int) (object) x; - int mask = (int) (px >> (sizeof(int) - 1)); - return (T) (object) (int) ((px + mask) ^ mask); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return x; - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - var px = (long) (object) x; - long mask = (long) (px >> (sizeof(long) - 1)); - return (T) (object) (long) ((px + mask) ^ mask); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return x; - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { -#if SSE - if (Ssse3.IsSupported) - { - return (T)(object)(short)Ssse3.Abs(Vector128.CreateScalar((short) (object) x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T) (object)(short)AdvSimd.Abs(Vector64.CreateScalar((short) (object) x)).ToScalar(); - } -#endif - var px = (short) (object) x; - short mask = (short) (px >> (sizeof(short) - 1)); - return (T) (object) (short) ((px + mask) ^ mask); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return x; - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - return (T)(object) new Complex(System.Numerics.Complex.Abs((Complex)(object)x), 0); - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - return (T) (object) Math.Abs((decimal) (object) x); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the angle whose cosine is the specified number. - /// - /// A number representing a cosine, where must be greater than or equal to -1, but less than or equal to 1. - /// The type of - /// - ///An angle, θ, measured in radians, such that 0 ≤ θ ≤ π. - /// - /// -or- - /// - /// NaN if x < -1 or x > 1 or x equals NaN. - /// - [MethodImpl(MaxOpt)] - public static T Acos(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Acos((float) (Half) (object) x); // KIPLING -#else - return (T) (object) (Half) MathF.Abs((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Acos((float) (object) x); // KIPLING -#else - return (T) (object) MathF.Acos((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.Acos((double) (object) x); - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Acos((sbyte) (object) x); // KIPLING - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Acos((byte) (object) x); // KIPLING - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Acos((int) (object) x); // KIPLING - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Acos((uint) (object) x); // KIPLING - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Acos((long) (object) x); // KIPLING - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Acos((ulong) (object) x); // KIPLING - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Acos((short) (object) x); // KIPLING - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Acos((ushort) (object) x); // KIPLING - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Acos((Complex) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the angle whose hyperbolic cosine is the specified number. - /// - /// A number representing a hyperbolic cosine, where must be greater than or equal to 1, but less than or equal to . - /// The type of . - /// - /// An angle, θ, measured in radians, such that 0 ≤ θ ≤ ∞. - /// - /// -or- - /// - /// NaN if x < 1 or x equals NaN. - /// - [MethodImpl(MaxOpt)] - public static T Acosh(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) (float) CoreAcosh((float) (Half) (object) x); - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) CoreAcosh((float) (object) x); - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) CoreAcosh((double) (object) x); - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) CoreAcosh((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) CoreAcosh((byte) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) CoreAcosh((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (byte) CoreAcosh((byte) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) CoreAcosh((long) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) CoreAcosh((ulong) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) CoreAcosh((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) CoreAcosh((int) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the angle whose sine is the specified number. - /// - /// A number representing a sine, where must be greater than or equal to -1, but less than or equal to 1. - /// The type of - /// An angle, θ, measured in radians, such that -π/2 ≤ θ ≤ π/2. - /// - /// -or- - /// - /// NaN if x < -1 or x > 1 or x equals NaN. - /// - [MethodImpl(MaxOpt)] - public static T Asin(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Asin((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Abs((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Asin((float) (object) x); -#else - return (T) (object) MathF.Asin((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.Asin((double) (object) x); - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Asin((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Asin((byte) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Asin((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Asin((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Asin((long) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Asin((ulong) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Asin((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Asin((ushort) (object) x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Asin((Complex) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the angle whose hyperbolic sine is the specified number. - /// - /// A number representing a hyperbolic sine, where must be greater than or equal to , but less than or equal to . - /// - /// - [MethodImpl(MaxOpt)] - public static T Asinh(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) (float) CoreAsinh((float) (Half) (object) x); - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) CoreAsinh((float) (object) x); - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) CoreAsinh((double) (object) x); - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) CoreAsinh((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) CoreAsinh((byte) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) CoreAsinh((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) CoreAsinh((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) CoreAsinh((long) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) CoreAsinh((ulong) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) CoreAsinh((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) CoreAsinh((ushort) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the angle whose tangent is the specified number. - /// - /// A number representing a tangent. - /// The type of . - /// - ///An angle, θ, measured in radians, such that -π/2 ≤ θ ≤ π/2. - /// - /// -or- - /// - /// NaN if equals , -π/2 rounded to double precision (-1.5707963267949) if equals , or π/2 rounded to double precision (1.5707963267949) if equals . - /// - [MethodImpl(MaxOpt)] - public static T Atan(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Atan((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Abs((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Atan((float) (object) x); -#else - return (T) (object) MathF.Atan((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.Atan((double) (object) x); - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Atan((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Atan((byte) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Atan((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Atan((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Atan((long) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Atan((ulong) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Atan((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Atan((ushort) (object) x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Atan((Complex) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the angle whose hyperbolic tangent is the specified number. - /// - /// A number representing a hyperbolic tangent, where must be greater than or equal to -1, but less than or equal to 1. - /// The type of . - /// - /// An angle, θ, measured in radians, such that -∞ < θ < -1, or 1 < θ < ∞. - /// - /// -or- - /// - /// if x < -1 or x > 1 or x equals . - /// - [MethodImpl(MaxOpt)] - public static T Atanh(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) Atanh((float) (Half) (object) x); - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) Atanh((float) (object) x); - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) CoreAtanh((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) CoreAtanh((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) CoreAtanh((byte) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) CoreAtanh((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) CoreAtanh((ushort) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) CoreAtanh((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) CoreAtanh((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) CoreAtanh((long) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) CoreAtanh((ulong) (object) x); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the cube root of a specified number. - /// - /// The number whose cube root is to be found. - /// The type of - /// - /// The cube root of . - /// - /// -or- - /// - /// if is equals . - /// - [MethodImpl(MaxOpt)] - public static T Cbrt(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) CoreCbrt((float) (Half) (object) x); - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) CoreCbrt((float) (object) x); - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) CoreCbrt((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) CoreCbrt((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) CoreCbrt((byte) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) CoreCbrt((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) CoreCbrt((ushort) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) CoreCbrt((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) CoreCbrt((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) CoreCbrt((long) (object) x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Pow((Complex) (object) x, 1.0/3); // TODO: find a more efficient impl? - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) CoreCbrt((ulong) (object) x); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the smallest integral value that is greater than or equal to the specified single-precision floating-point number. - /// - /// A number. - /// The type of . - /// The smallest integral value that is greater than or equal to . If is equal to , , or , that value is returned. Note that this method returns instead of an integral type. - [MethodImpl(MaxOpt)] - public static T Ceiling(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) Math.Ceiling((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Ceiling((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Ceiling((float) (object) x); -#else - return (T) (object) MathF.Ceiling((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.Ceiling((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - return (T) (object) Math.Ceiling((decimal) (object) x); - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return x; - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return x; - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return x; - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return x; - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return x; - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return x; - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return x; - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return x; - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the cosine of the specified angle. - /// - /// An angle, measured in radians. - /// The type of . - /// The cosine of . If is equal to , , or , this method returns . - [MethodImpl(MaxOpt)] - public static T Cos(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) Math.Cos((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Cos((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Cos((float) (object) x); -#else - return (T) (object) MathF.Cos((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.Cos((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Cos((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Cos((byte) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Cos((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Cos((ushort) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Cos((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Cos((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Cos((long) (object) x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Cos((Complex) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Cos((ulong) (object) x); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the hyperbolic cosine of the specified angle. - /// - /// An angle, measured in radians. - /// The type of . - /// The hyperbolic cosine of . If equal to or , is returned. If is equal to , is returned. - [MethodImpl(MaxOpt)] - public static T Cosh(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) Math.Cosh((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Cosh((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Cosh((float) (object) x); -#else - return (T) (object) MathF.Cosh((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.Cosh((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Cosh((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Cosh((byte) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Cosh((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Cosh((ushort) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Cosh((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Cosh((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Cosh((long) (object) x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Cosh((Complex) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Cosh((ulong) (object) x); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns e raised to the specified power. - /// - /// A number specifying a power. - /// The type of . - /// The number e raised to the power . If equals or , that value is returned. If equals , 0 is returned. - [MethodImpl(MaxOpt)] - public static T Exp(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) CoreFastExp((float) (Half) (object) x); - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) CoreFastExp((float) (object) x); - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.Exp((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Exp((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Exp((byte) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Exp((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Exp((ushort) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Exp((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Exp((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Exp((long) (object) x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Exp((Complex) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Exp((ulong) (object) x); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the largest integral value less than or equal to the specified single-precision floating-point number. - /// - /// A number. - /// The type of . - /// The largest integral value less than or equal to . If is equal to , , or , that value is returned. - [MethodImpl(MaxOpt)] - public static T Floor(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if SSE - if (Sse41.IsSupported) - { - return (T)(object)(Half)Sse41.FloorScalar(Vector128.CreateScalarUnsafe((float) (Half) (object) x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(Half)AdvSimd.FloorScalar(Vector64.CreateScalarUnsafe((float) (Half) (object) x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (Half) Math.Floor((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Floor((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if SSE - if (Sse41.IsSupported) - { - return (T)(object)Sse41.FloorScalar(Vector128.CreateScalarUnsafe((float) (object) x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)AdvSimd.FloorScalar(Vector64.CreateScalarUnsafe((float) (object) x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (float) Math.Floor((float) (object) x); -#else - return (T) (object) MathF.Floor((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { -#if SSE - if (Sse41.IsSupported) - { - return (T)(object)Sse41.FloorScalar(Vector128.CreateScalarUnsafe((double) (object) x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)AdvSimd.FloorScalar(Vector64.CreateScalar((double) (object) x)).ToScalar(); - } -#endif - return (T) (object) Math.Floor((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { -#if SSE - if (Sse41.IsSupported) - { - return (T)(object)(decimal)Sse41.FloorScalar(Vector128.CreateScalarUnsafe((double)(decimal) (object) x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(decimal)AdvSimd.FloorScalar(Vector64.CreateScalar((double)(decimal) (object) x)).ToScalar(); - } -#endif - return (T) (object) Math.Floor((decimal) (object) x); - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return x; - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return x; - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return x; - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return x; - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return x; - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return x; - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return x; - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return x; - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns an integer that indicates the sign of a single-precision floating-point number. - /// - /// A number. - /// The type of - /// - /// A number that indicates the sign of , as shown in the following table. - /// - /// - /// Return value - /// Meaning - /// - /// - /// -1 - /// is less than zero. - /// - /// - /// 0 - /// is equal to zero. - /// - /// - /// 1 - /// is greater than zero. - /// - /// - /// - /// - /// For unsigned numbers this will never return -1, but will return 0 when is 0 - /// - /// is equal to - [MethodImpl(MaxOpt)] - public static int Sign(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return Math.Sign((float) (Half) (object) x); -#else - return MathF.Sign((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static int Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return Math.Sign((float) (object) x); -#else - return MathF.Sign((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static int Double(T x) - { - if (typeof(T) == typeof(double)) - { - return Math.Sign((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static int Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - return Math.Sign((decimal) (object) x); - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static int SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return Math.Sign((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static int Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return ((byte) (object) x) > 0 ? 1 : 0; - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static int Short(T x) - { - if (typeof(T) == typeof(short)) - { - return Math.Sign((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static int UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return ((ushort) (object) x) > 0 ? 1 : 0; - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static int Int(T x) - { - if (typeof(T) == typeof(int)) - { - return Math.Sign((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static int UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return ((uint) (object) x) > 0 ? 1 : 0; - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static int Long(T x) - { - if (typeof(T) == typeof(long)) - { - return Math.Sign((long) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static int ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return ((ulong) (object) x) > 0 ? 1 : 0; - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the sine of the specified angle. - /// - /// An angle, measured in radians. - /// The type of . - /// The sine of . If is equal to , , or , this method returns . - [MethodImpl(MaxOpt)] - public static T Sin(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) (float) Sin_Ported((float) (Half) (object) x); - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) (float) Sin_Ported((float) (object) x); - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) (double) Math.Sin((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Sin((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Sin((byte) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Sin((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Sin((ushort) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Sin((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Sin((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Sin((long) (object) x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Sin((Complex) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Sin((ulong) (object) x); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the hyperbolic sine of the specified angle. - /// - /// An angle, measured in radians. - /// Type of . - /// The hyperbolic sine of . If is equal to , , or this method returns . - [MethodImpl(MaxOpt)] - public static T Sinh(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Sinh((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Sinh((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Sinh((float) (object) x); -#else - return (T) (object) MathF.Sinh((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) (double) Math.Sinh((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Sinh((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Sinh((byte) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Sinh((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Sinh((ushort) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Sinh((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Sinh((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Sinh((long) (object) x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Sinh((Complex) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Sinh((ulong) (object) x); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the square root of a specified number. - /// - /// The number whose square root is to be found. - /// The type of . - /// - /// One of the values in the following table. - /// - /// - /// parameter - /// Return value - /// - /// - /// Zero or positive - /// The positive square root of . - /// - /// - /// Negative - /// - /// - /// - /// Equals - /// - /// - /// - /// Equals - /// - /// - /// - /// - [MethodImpl(MaxOpt)] - public static T Sqrt(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if SSE - if (Sse42.IsSupported) - { - return (T)(object)(Half)(float)Sse.SqrtScalar(Vector128.CreateScalarUnsafe((float)(Half)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(Half)(float)AdvSimd.SqrtScalar(Vector64.CreateScalarUnsafe((float)(Half)(object)x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (Half) (float) Math.Sqrt((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Sqrt((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if SSE - if (Sse.IsSupported) - { - return (T)(object)(float)Sse.SqrtScalar(Vector128.CreateScalarUnsafe((float)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(float)AdvSimd.SqrtScalar(Vector64.CreateScalarUnsafe((float)(object)x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (float) Math.Sqrt((float) (object) x); -#else - return (T) (object) MathF.Sqrt((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { -#if SSE - if (Sse2.IsSupported) - { - return (T)(object)(double)Sse2.SqrtScalar(Vector128.CreateScalarUnsafe((double)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(double)AdvSimd.SqrtScalar(Vector64.CreateScalar((double)(object)x)).ToScalar(); - } -#endif - return (T) (object) (double) Math.Sqrt((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { -#if SSE - if (Sse.IsSupported) - { - return (T)(object)(sbyte)(float)Sse.SqrtScalar(Vector128.CreateScalarUnsafe((float)(sbyte)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(sbyte)(float)AdvSimd.SqrtScalar(Vector64.CreateScalarUnsafe((float)(sbyte)(object)x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (sbyte) (float) Math.Sqrt((float) (sbyte) (object) x); -#else - return (T) (object) (sbyte)(float)MathF.Sqrt((float) (sbyte)(object) x); -#endif - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { -#if SSE - if (Sse.IsSupported) - { - return (T)(object)(byte)(float)Sse.SqrtScalar(Vector128.CreateScalarUnsafe((float)(byte)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(byte)(float)AdvSimd.SqrtScalar(Vector64.CreateScalarUnsafe((float)(byte)(object)x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (byte) (float) Math.Sqrt((float) (byte) (object) x); -#else - return (T) (object) (byte)(float)MathF.Sqrt((float) (byte)(object) x); -#endif - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { -#if SSE - if (Sse.IsSupported) - { - return (T)(object)(short)(float)Sse.SqrtScalar(Vector128.CreateScalarUnsafe((float)(short)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(short)(float)AdvSimd.SqrtScalar(Vector64.CreateScalarUnsafe((float)(short)(object)x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (short) (float) Math.Sqrt((float) (short) (object) x); -#else - return (T) (object) (short)(float)MathF.Sqrt((float) (short)(object) x); -#endif - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { -#if SSE - if (Sse.IsSupported) - { - return (T)(object)(ushort)(float)Sse.SqrtScalar(Vector128.CreateScalarUnsafe((float)(ushort)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(ushort)(float)AdvSimd.SqrtScalar(Vector64.CreateScalarUnsafe((float)(ushort)(object)x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (ushort) (float) Math.Sqrt((float) (ushort) (object) x); -#else - return (T) (object) (ushort)(float)MathF.Sqrt((float) (ushort)(object) x); -#endif - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { -#if SSE - if (Sse.IsSupported) - { - return (T)(object)(int)(float)Sse.SqrtScalar(Vector128.CreateScalarUnsafe((float)(int)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(int)(float)AdvSimd.SqrtScalar(Vector64.CreateScalarUnsafe((float)(int)(object)x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (int) (float) Math.Sqrt((float) (int) (object) x); -#else - return (T) (object) (int)(float)MathF.Sqrt((float) (int)(object) x); -#endif - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { -#if SSE - if (Sse.IsSupported) - { - return (T)(object)(uint)(float)Sse.SqrtScalar(Vector128.CreateScalarUnsafe((float)(uint)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(uint)(float)AdvSimd.SqrtScalar(Vector64.CreateScalarUnsafe((float)(uint)(object)x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (uint) (float) Math.Sqrt((float) (uint) (object) x); -#else - return (T) (object) (uint)(float)MathF.Sqrt((float) (uint)(object) x); -#endif - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { -#if SSE - if (Sse.IsSupported) - { - return (T)(object)(long)(float)Sse.SqrtScalar(Vector128.CreateScalarUnsafe((float)(long)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(long)(float)AdvSimd.SqrtScalar(Vector64.CreateScalarUnsafe((float)(long)(object)x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (long) (float) Math.Sqrt((float) (long) (object) x); -#else - return (T) (object) (long)(float)MathF.Sqrt((float) (long)(object) x); -#endif - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - // TODO: vectorized implementation? - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Sqrt((Complex) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { -#if SSE - if (Sse.IsSupported) - { - return (T)(object)(ulong)(float)Sse.SqrtScalar(Vector128.CreateScalarUnsafe((float)(ulong)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(ulong)(float)AdvSimd.SqrtScalar(Vector64.CreateScalarUnsafe((float)(ulong)(object)x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (ulong) (float) Math.Sqrt((float) (ulong) (object) x); -#else - return (T) (object) (ulong)(float)MathF.Sqrt((float) (ulong)(object) x); -#endif - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the tangent of the specified angle. - /// - /// An angle, measured in radians. - /// The type of . - /// The tangent of . If is equal to , , or , this method returns . - [MethodImpl(MaxOpt)] - public static T Tan(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Tan((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Tan((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Tan((float) (object) x); -#else - return (T) (object) MathF.Tan((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) (double) Math.Tan((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Tan((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Tan((byte) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Tan((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Tan((ushort) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Tan((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Tan((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Tan((long) (object) x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Tan((Complex) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Tan((ulong) (object) x); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the hyperbolic tangent of the specified angle. - /// - /// An angle, measured in radians. - /// The type of . - /// The hyperbolic tangent of . If is equal to , this method returns -1. If is equal to , this method returns 1. If is equal to , this method returns . - [MethodImpl(MaxOpt)] - public static T Tanh(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Tanh((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Tanh((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Tanh((float) (object) x); -#else - return (T) (object) MathF.Tanh((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) (double) Math.Tanh((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Tanh((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Tanh((byte) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Tanh((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Tanh((ushort) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Tanh((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Tanh((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Tanh((long) (object) x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Tanh((Complex) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Tanh((ulong) (object) x); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Calculates the integral part of a specified single-precision floating-point number. - /// - /// A number to truncate. - /// - /// - /// The integral part of ; that is, the number that remains after any fractional digits have been discarded, or one of the values listed in the following table. - /// - /// - /// - /// Return value - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - [MethodImpl(MaxOpt)] - public static T Truncate(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Truncate((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Truncate((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Truncate((float) (object) x); -#else - return (T) (object) MathF.Truncate((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) (double) Math.Truncate((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - return (T) (object) (decimal) Math.Truncate((decimal) (object) x); - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return x; - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return x; - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return x; - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return x; - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return x; - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return x; - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return x; - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return x; - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the natural (base e) logarithm of a specified number. - /// - /// The number whose logarithm is to be found. - /// The type of . - /// - /// One of the values in the following table. - /// - /// - /// parameter - /// Return value - /// - /// - /// Positive - /// The natural logarithm of ; that is, ln , or log e - /// - /// - /// Zero - /// - /// - /// - /// Negative - /// - /// - /// - /// Equal to - /// - /// - /// - /// Equal to - /// - /// - /// - /// - [MethodImpl(MaxOpt)] - public static T Log(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) CoreFastLog((float) (Half) (object) x); - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) CoreFastLog((float) (object) x); - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) (double) Math.Log((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Log((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Log((byte) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Log((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Log((ushort) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Log((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Log((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Log((long) (object) x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Log((Complex) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Log((ulong) (object) x); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the base 10 logarithm of a specified number. - /// - /// The number whose logarithm is to be found. - /// The type of . - /// - /// One of the values in the following table. - /// - /// - /// parameter - /// Return value - /// - /// - /// Positive - /// The base 10 log of ; that is log 10 - /// - /// - /// Zero - /// - /// - /// - /// Negative - /// - /// - /// - /// Equal to - /// - /// - /// - /// Equal to - /// - /// - /// - /// - [MethodImpl(MaxOpt)] - public static T Log10(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Log10((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Log10((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Log10((float) (object) x); -#else - return (T) (object) MathF.Log10((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) (double) Math.Log10((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Log10((sbyte) (object) x); - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Log10((byte) (object) x); - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Log10((short) (object) x); - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Log10((ushort) (object) x); - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Log10((int) (object) x); - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Log10((uint) (object) x); - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Log10((long) (object) x); - } - - return Complex(x); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Log10((Complex) (object) x); - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Log10((ulong) (object) x); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Rounds a single-precision floating-point value to the nearest integral value, and rounds midpoint values to the nearest even number. - /// - /// A number to be rounded. - /// The type of . - /// - /// The integer nearest . If the fractional component of is halfway between two integers, one of which is even and the other odd, then the even number is returned. Note that this method returns instead of an integral type - /// - /// - /// This method uses the default rounding convention of . - /// - [MethodImpl(MaxOpt)] - public static T Round(T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Round((float) (Half) (object) x); -#else - return (T) (object) (Half) MathF.Round((float) (Half) (object) x); -#endif - } - - return Float(x); - - [MethodImpl(MaxOpt)] - static T Float(T x) - { - if (typeof(T) == typeof(float)) - { -#if SSE - if (Sse42.IsSupported) - { - return (T)(object)(float)Sse41.RoundToNearestIntegerScalar(Vector128.CreateScalarUnsafe((float)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(float)AdvSimd.RoundToNearestScalar(Vector64.CreateScalar((float)(object)x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (float) Math.Round((float) (object) x); -#else - return (T) (object) MathF.Round((float) (object) x); -#endif - } - - return Double(x); - } - - [MethodImpl(MaxOpt)] - static T Double(T x) - { - if (typeof(T) == typeof(double)) - { -#if SSE - if (Sse42.IsSupported) - { - return (T)(object)(double)Sse41.RoundToNearestIntegerScalar(Vector128.CreateScalarUnsafe((double)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - return (T)(object)(double)AdvSimd.RoundToNearestScalar(Vector64.CreateScalar((double)(object)x)).ToScalar(); - } -#endif - return (T) (object) (double) Math.Round((double) (object) x); - } - - return Decimal(x); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x) - { - if (typeof(T) == typeof(decimal)) - { - return (T) (object) (decimal) Math.Round((decimal) (object) x); - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return x; - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return x; - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return x; - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return x; - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return x; - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return x; - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return x; - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return x; - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the remainder resulting from the division of a specified number by another specified number. - /// - /// A dividend. - /// A divisor. - /// The type of and . - /// - /// A number equal to - ( Q), where Q is the quotient of / rounded to the nearest integer (if / falls halfway between two integers, the even integer is returned). - /// - /// If - ( Q) is zero, the value +0 is returned if is positive, or -0 if is negative. - /// - /// If = 0, NaN is returned. - /// - [MethodImpl(MaxOpt)] - public static T IEEERemainder(T x, T y) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.IEEERemainder - ((float) (Half) (object) x, (float) (Half) (object) y); -#else - return (T) (object) (Half) MathF.IEEERemainder((float) (Half) (object) x, (float) (Half) (object) y); -#endif - } - - return Float(x, y); - - [MethodImpl(MaxOpt)] - static T Float(T x, T y) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.IEEERemainder((float) (object) x, (float) (object) y); -#else - return (T) (object) MathF.IEEERemainder((float) (object) x, (float) (object) y); -#endif - } - - return Double(x, y); - } - - [MethodImpl(MaxOpt)] - static T Double(T x, T y) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.IEEERemainder((double) (object) x, (double) (object) y); - } - - return Decimal(x, y); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x, T y) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x, y); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x, T y) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.IEEERemainder((sbyte) (object) x, (sbyte) (object) y); - } - - return Byte(x, y); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x, T y) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.IEEERemainder((byte) (object) x, (byte) (object) y); - } - - return Short(x, y); - } - - [MethodImpl(MaxOpt)] - static T Short(T x, T y) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.IEEERemainder((short) (object) x, (short) (object) y); - } - - return UShort(x, y); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x, T y) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.IEEERemainder((ushort) (object) x, (ushort) (object) y); - } - - return Int(x, y); - } - - [MethodImpl(MaxOpt)] - static T Int(T x, T y) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.IEEERemainder((int) (object) x, (int) (object) y); - } - - return UInt(x, y); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x, T y) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.IEEERemainder((uint) (object) x, (uint) (object) y); - } - - return Long(x, y); - } - - [MethodImpl(MaxOpt)] - static T Long(T x, T y) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.IEEERemainder((long) (object) x, (long) (object) y); - } - - return ULong(x, y); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x, T y) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.IEEERemainder((ulong) (object) x, (ulong) (object) y); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the logarithm of a specified number in a specified base. - /// - /// The number whose logarithm is to be found. - /// The base. - /// The type of and . - /// - /// One of the values in the following table. (+Infinity denotes , -Infinity denotes , and NaN denotes .) - /// - /// - /// - /// newBase - /// Return value - /// - /// - /// >0 - /// (0<newBase<1) -or- (newBase>1) - /// lognewBase(a) - /// - /// - /// <0 - /// (any value) - /// NaN - /// - /// - /// (any value) - /// newBase<0 - /// NaN - /// - /// - /// != 1 - /// newBase = 0 - /// NaN - /// - /// - /// != 1 - /// newBase = +Infinity - /// NaN - /// - /// - /// = NaN - /// (any value) - /// NaN - /// - /// - /// (any value) - /// newBase = NaN - /// NaN - /// - /// - /// (any value) - /// newBase = 1 - /// NaN - /// - /// - /// = 0 - /// 0 < newBase < 1 - /// +Infinity - /// - /// - /// = 0 - /// newBase > 1 - /// -Infinity - /// - /// - /// = +Infinity - /// 0 < newBase < 1 - /// -Infinity - /// - /// - /// = +Infinity - /// newBase > 1 - /// +Infinity - /// - /// - /// = 1 - /// newBase = 0 - /// 0 - /// - /// - /// = 1 - /// newBase = +Infinity - /// 0 - /// - /// - /// - [MethodImpl(MaxOpt)] - public static T Log(T x, T y) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Log((float) (Half) (object) x, (float) (Half) (object) y); -#else - return (T) (object) (Half) MathF.Log((float) (Half) (object) x, (float) (Half) (object) y); -#endif - } - - return Float(x, y); - - [MethodImpl(MaxOpt)] - static T Float(T x, T y) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Log((float) (object) x, (float) (object) y); -#else - return (T) (object) MathF.Log((float) (object) x, (float) (object) y); -#endif - } - - return Double(x, y); - } - - [MethodImpl(MaxOpt)] - static T Double(T x, T y) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.Log((double) (object) x, (double) (object) y); - } - - return Decimal(x, y); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x, T y) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x, y); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x, T y) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Log((sbyte) (object) x, (sbyte) (object) y); - } - - return Byte(x, y); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x, T y) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Log((byte) (object) x, (byte) (object) y); - } - - return Short(x, y); - } - - [MethodImpl(MaxOpt)] - static T Short(T x, T y) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Log((short) (object) x, (short) (object) y); - } - - return UShort(x, y); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x, T y) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Log((ushort) (object) x, (ushort) (object) y); - } - - return Int(x, y); - } - - [MethodImpl(MaxOpt)] - static T Int(T x, T y) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Log((int) (object) x, (int) (object) y); - } - - return UInt(x, y); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x, T y) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Log((uint) (object) x, (uint) (object) y); - } - - return Long(x, y); - } - - [MethodImpl(MaxOpt)] - static T Long(T x, T y) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Log((long) (object) x, (long) (object) y); - } - - return Complex(x, y); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x, T y) - { - if (typeof(T) == typeof(Complex)) - { - // Complex.Log is not defined on two complex numbers - var baseValue = (Complex) (object) y; - if (baseValue.Imaginary is 0) - return (T) (object) (Complex) System.Numerics.Complex.Log((Complex) (object) x, baseValue.Real); - // log(x, y) = log(x) / log(y) - return (T) (object) (System.Numerics.Complex.Log((Complex) (object) x) / System.Numerics.Complex.Log(baseValue)); - } - - return ULong(x, y); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x, T y) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Log((ulong) (object) x, (ulong) (object) y); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the larger of two numbers. - /// - /// The first of two numbers to compare. - /// The second of two numbers to compare. - /// The type of and . - /// Parameter or , whichever is larger. If , or , or both and are equal to , is returned. - [MethodImpl(MaxOpt)] - public static T Max(T x, T y) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Max((float) (Half) (object) x, (float) (Half) (object) y); -#else - return (T) (object) (Half) MathF.Max((float) (Half) (object) x, (float) (Half) (object) y); -#endif - } - - return Float(x, y); - - [MethodImpl(MaxOpt)] - static T Float(T x, T y) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Max((float) (object) x, (float) (object) y); -#else - return (T) (object) MathF.Max((float) (object) x, (float) (object) y); -#endif - } - - return Double(x, y); - } - - [MethodImpl(MaxOpt)] - static T Double(T x, T y) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.Max((double) (object) x, (double) (object) y); - } - - return Decimal(x, y); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x, T y) - { - if (typeof(T) == typeof(decimal)) - { - return (T) (object) (decimal) Math.Max((decimal) (object) x, (decimal) (object) y); - } - - return SByte(x, y); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x, T y) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Max((sbyte) (object) x, (sbyte) (object) y); - } - - return Byte(x, y); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x, T y) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Max((byte) (object) x, (byte) (object) y); - } - - return Short(x, y); - } - - [MethodImpl(MaxOpt)] - static T Short(T x, T y) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Max((short) (object) x, (short) (object) y); - } - - return UShort(x, y); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x, T y) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Max((ushort) (object) x, (ushort) (object) y); - } - - return Int(x, y); - } - - [MethodImpl(MaxOpt)] - static T Int(T x, T y) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Max((int) (object) x, (int) (object) y); - } - - return UInt(x, y); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x, T y) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Max((uint) (object) x, (uint) (object) y); - } - - return Long(x, y); - } - - [MethodImpl(MaxOpt)] - static T Long(T x, T y) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Max((long) (object) x, (long) (object) y); - } - - return ULong(x, y); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x, T y) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Max((ulong) (object) x, (ulong) (object) y); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the smaller of two numbers. - /// - /// The first of two numbers to compare. - /// The second of two numbers to compare. - /// The type of and . - /// Parameter or , whichever is smaller. If , or , or both and are equal to , is returned. - [MethodImpl(MaxOpt)] - public static T Min(T x, T y) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Min((float) (Half) (object) x, (float) (Half) (object) y); -#else - return (T) (object) (Half) MathF.Min((float) (Half) (object) x, (float) (Half) (object) y); -#endif - } - - return Float(x, y); - - [MethodImpl(MaxOpt)] - static T Float(T x, T y) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Min((float) (object) x, (float) (object) y); -#else - return (T) (object) MathF.Min((float) (object) x, (float) (object) y); -#endif - } - - return Double(x, y); - } - - [MethodImpl(MaxOpt)] - static T Double(T x, T y) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.Min((double) (object) x, (double) (object) y); - } - - return Decimal(x, y); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x, T y) - { - if (typeof(T) == typeof(decimal)) - { - return (T) (object) (decimal) Math.Min((decimal) (object) x, (decimal) (object) y); - } - - return SByte(x, y); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x, T y) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Min((sbyte) (object) x, (sbyte) (object) y); - } - - return Byte(x, y); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x, T y) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Min((byte) (object) x, (byte) (object) y); - } - - return Short(x, y); - } - - [MethodImpl(MaxOpt)] - static T Short(T x, T y) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Min((short) (object) x, (short) (object) y); - } - - return UShort(x, y); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x, T y) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Min((ushort) (object) x, (ushort) (object) y); - } - - return Int(x, y); - } - - [MethodImpl(MaxOpt)] - static T Int(T x, T y) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Min((int) (object) x, (int) (object) y); - } - - return UInt(x, y); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x, T y) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Min((uint) (object) x, (uint) (object) y); - } - - return Long(x, y); - } - - [MethodImpl(MaxOpt)] - static T Long(T x, T y) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Min((long) (object) x, (long) (object) y); - } - - return ULong(x, y); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x, T y) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Min((ulong) (object) x, (ulong) (object) y); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns a specified number raised to the specified power. - /// - /// A number to be raised to a power. - /// A number that specifies a power. - /// The type of and . - /// The number raised to the power . - /// - /// , , and . - /// - /// |Parameters|Return value| - /// |----------------|------------------| - /// |`x` or `y` = `NaN`.|`NaN`| - /// |`x` = Any value except `NaN`; `y` = 0.|1| - /// |`x` = `NegativeInfinity`; `y` < 0.|0| - /// |`x` = `NegativeInfinity`; `y` is a positive odd integer.|`NegativeInfinity`| - /// |`x` = `NegativeInfinity`; `y` is positive but not an odd integer.|`PositiveInfinity`| - /// |`x` < 0 but not `NegativeInfinity`; `y` is not an integer, `NegativeInfinity`, or `PositiveInfinity`.|`NaN`| - /// |`x` = -1; `y` = `NegativeInfinity` or `PositiveInfinity`.|`NaN`| - /// |-1 < `x` < 1; `y` = `NegativeInfinity`.|`PositiveInfinity`| - /// |-1 < `x` < 1; `y` = `PositiveInfinity`.|0| - /// |`x` < -1 or `x` > 1; `y` = `NegativeInfinity`.|0| - /// |`x` < -1 or `x` > 1; `y` = `PositiveInfinity`.|`PositiveInfinity`| - /// |`x` = 0; `y` < 0.|`PositiveInfinity`| - /// |`x` = 0; `y` > 0.|0| - /// |`x` = 1; `y` is any value except `NaN`.|1| - /// |`x` = `PositiveInfinity`; `y` < 0.|0| - /// |`x` = `PositiveInfinity`; `y` > 0.|`PositiveInfinity`| - /// - /// ]]> - /// - [MethodImpl(MaxOpt)] - public static T Pow(T x, T y) where T : notnull - { - if (typeof(T) == typeof(Half)) - { - return (T) (object) (Half) CoreFastPow((float) (Half) (object) x, (float) (Half) (object) y); - } - - return Float(x, y); - - [MethodImpl(MaxOpt)] - static T Float(T x, T y) - { - if (typeof(T) == typeof(float)) - { - return (T) (object) CoreFastPow((float) (object) x, (float) (object) y); - } - - return Double(x, y); - } - - [MethodImpl(MaxOpt)] - static T Double(T x, T y) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.Pow((double) (object) x, (double) (object) y); - } - - return Decimal(x, y); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x, T y) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x, y); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x, T y) - { - if (typeof(T) == typeof(sbyte)) - { - var py = (sbyte) (object) y; - var px = (sbyte) (object) x; - if (py != 0) - { - var oabsy = Abs(py); - var absy = oabsy; - sbyte result = 1; - while (true) - { - if ((absy & 1) != 0) - result *= px; - absy >>= 1; - if (absy == 0) - break; - px *= px; - } - - if (oabsy == py) - return (T) (object) result; - return (T) (object) (sbyte) Scalar.Reciprocal(result); - } - else - { - if (px != 0) return (T) (object) (sbyte) 1; - else return (T) (object) (sbyte) 0; - } - } - - return Byte(x, y); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x, T y) - { - if (typeof(T) == typeof(byte)) - { - var py = (byte) (object) y; - var px = (byte) (object) x; - if (py != 0) - { - var oabsy = py; - var absy = oabsy; - byte result = 1; - while (true) - { - if ((absy & 1) != 0) - result *= px; - absy >>= 1; - if (absy == 0) - break; - px *= px; - } - - return (T) (object) result; - } - else - { - if (px != 0) return (T) (object) (byte) 1; - else return (T) (object) (byte) 0; - } - } - - return Short(x, y); - } - - [MethodImpl(MaxOpt)] - static T Short(T x, T y) - { - if (typeof(T) == typeof(short)) - { - var py = (short) (object) y; - var px = (short) (object) x; - if (py != 0) - { - var oabsy = Abs(py); - var absy = oabsy; - short result = 1; - while (true) - { - if ((absy & 1) != 0) - result *= px; - absy >>= 1; - if (absy == 0) - break; - px *= px; - } - - if (oabsy == py) - return (T) (object) result; - return (T) (object) (short) Scalar.Reciprocal(result); - } - else - { - if (px != 0) return (T) (object) (short) 1; - else return (T) (object) (short) 0; - } - } - - return UShort(x, y); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x, T y) - { - if (typeof(T) == typeof(ushort)) - { - var py = (ushort) (object) y; - var px = (ushort) (object) x; - if (py != 0) - { - var oabsy = py; - var absy = oabsy; - ushort result = 1; - while (true) - { - if ((absy & 1) != 0) - result *= px; - absy >>= 1; - if (absy == 0) - break; - px *= px; - } - - return (T) (object) result; - } - else - { - if (px != 0) return (T) (object) (ushort) 1; - else return (T) (object) (ushort) 0; - } - } - - return Int(x, y); - } - - [MethodImpl(MaxOpt)] - static T Int(T x, T y) - { - if (typeof(T) == typeof(int)) - { - var py = (int) (object) y; - var px = (int) (object) x; - if (py != 0) - { - var oabsy = Abs(py); - var absy = oabsy; - int result = 1; - while (true) - { - if ((absy & 1) != 0) - result *= px; - absy >>= 1; - if (absy == 0) - break; - px *= px; - } - - if (oabsy == py) - return (T) (object) result; - return (T) (object) (int) Scalar.Reciprocal(result); - } - else - { - if (px != 0) return (T) (object) (int) 1; - else return (T) (object) (int) 0; - } - } - - return UInt(x, y); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x, T y) - { - if (typeof(T) == typeof(uint)) - { - var py = (uint) (object) y; - var px = (uint) (object) x; - if (py != 0) - { - var oabsy = py; - var absy = oabsy; - uint result = 1; - while (true) - { - if ((absy & 1) != 0) - result *= px; - absy >>= 1; - if (absy == 0) - break; - px *= px; - } - - return (T) (object) result; - } - else - { - if (px != 0) return (T) (object) (uint) 1; - else return (T) (object) (uint) 0; - } - } - - return Long(x, y); - } - - [MethodImpl(MaxOpt)] - static T Long(T x, T y) - { - if (typeof(T) == typeof(long)) - { - var py = (long) (object) y; - var px = (long) (object) x; - if (py != 0) - { - var oabsy = Abs(py); - var absy = oabsy; - long result = 1; - while (true) - { - if ((absy & 1) != 0) - result *= px; - absy >>= 1; - if (absy == 0) - break; - px *= px; - } - - if (oabsy == py) - return (T) (object) result; - return (T) (object) (long) Scalar.Reciprocal(result); - } - else - { - if (px != 0) return (T) (object) (long) 1; - else return (T) (object) (long) 0; - } - } - - return Complex(x, y); - } - - [MethodImpl(MaxOpt)] - static T Complex(T x, T y) - { - if (typeof(T) == typeof(Complex)) - { - return (T) (object) (Complex) System.Numerics.Complex.Pow((Complex) (object) x, (Complex) (object) y); - } - - return ULong(x, y); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x, T y) - { - if (typeof(T) == typeof(ulong)) - { - var py = (ulong) (object) y; - var px = (ulong) (object) x; - if (py != 0) - { - var oabsy = py; - var absy = oabsy; - ulong result = 1; - while (true) - { - if ((absy & 1) != 0) - result *= px; - absy >>= 1; - if (absy == 0) - break; - px *= px; - } - - return (T) (object) result; - } - else - { - if (px != 0) return (T) (object) (ulong) 1; - else return (T) (object) (ulong) 0; - } - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Returns the angle whose tangent is the quotient of two specified numbers. - /// - /// The y coordinate of a point. - /// The x coordinate of a point. - /// The type of and . - /// - /// An angle, θ, measured in radians, such that -π ≤ θ ≤ π, and tan(θ) = y / x, where (x, y) is a point in the Cartesian plane. Observe the following: - /// - /// For (, ) in quadrant 1, 0 < θ < π/2. - /// For (, ) in quadrant 2, π/2 < θ ≤ π. - /// For (, ) in quadrant 3, -π < θ < -π/2. - /// For (, ) in quadrant 4, -π/2 < θ < 0. - /// - /// - /// If y is 0 and x is not negative, θ = 0. - /// If y is 0 and x is negative, θ = π. - /// If y is positive and x is 0, θ = π/2. - /// If y is 0 and x is 0, θ = -π/2. - /// - /// If or is , or if and are either or , the method returns . - /// - /// - /// The return value is the angle in the Cartesian plane formed by the x-axis, and a vector starting from the origin, (0,0), and terminating at the point, (x,y). - /// - [MethodImpl(MaxOpt)] - public static T Atan2(T y, T x) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Atan2((float) (Half) (object) x, (float) (Half) (object) y); -#else - return (T) (object) (Half) MathF.Atan2((float) (Half) (object) x, (float) (Half) (object) y); -#endif - } - - return Float(x, y); - - [MethodImpl(MaxOpt)] - static T Float(T x, T y) - { - if (typeof(T) == typeof(float)) - { -#if !MATHF - return (T) (object) (float) Math.Atan2((float) (object) x, (float) (object) y); -#else - return (T) (object) MathF.Atan2((float) (object) x, (float) (object) y); -#endif - } - - return Double(x, y); - } - - [MethodImpl(MaxOpt)] - static T Double(T x, T y) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) Math.Atan2((double) (object) x, (double) (object) y); - } - - return Decimal(x, y); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x, T y) - { - if (typeof(T) == typeof(decimal)) - { - ThrowOpUnsupportedPrecision(); - return default; - } - - return SByte(x, y); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x, T y) - { - if (typeof(T) == typeof(sbyte)) - { - return (T) (object) (sbyte) Math.Atan2((sbyte) (object) x, (sbyte) (object) y); - } - - return Byte(x, y); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x, T y) - { - if (typeof(T) == typeof(byte)) - { - return (T) (object) (byte) Math.Atan2((byte) (object) x, (byte) (object) y); - } - - return Short(x, y); - } - - [MethodImpl(MaxOpt)] - static T Short(T x, T y) - { - if (typeof(T) == typeof(short)) - { - return (T) (object) (short) Math.Atan2((short) (object) x, (short) (object) y); - } - - return UShort(x, y); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x, T y) - { - if (typeof(T) == typeof(ushort)) - { - return (T) (object) (ushort) Math.Atan2((ushort) (object) x, (ushort) (object) y); - } - - return Int(x, y); - } - - [MethodImpl(MaxOpt)] - static T Int(T x, T y) - { - if (typeof(T) == typeof(int)) - { - return (T) (object) (int) Math.Atan2((int) (object) x, (int) (object) y); - } - - return UInt(x, y); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x, T y) - { - if (typeof(T) == typeof(uint)) - { - return (T) (object) (uint) Math.Atan2((uint) (object) x, (uint) (object) y); - } - - return Long(x, y); - } - - [MethodImpl(MaxOpt)] - static T Long(T x, T y) - { - if (typeof(T) == typeof(long)) - { - return (T) (object) (long) Math.Atan2((long) (object) x, (long) (object) y); - } - - return ULong(x, y); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x, T y) - { - if (typeof(T) == typeof(ulong)) - { - return (T) (object) (ulong) Math.Atan2((ulong) (object) x, (ulong) (object) y); - } - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Rounds a single-precision floating-point value to a specified number of fractional digits, and rounds midpoint values to the nearest even number. - /// - /// A number to be rounded. - /// The number of fractional digits in the return value. - /// The type of . - /// The number nearest to that contains a number of fractional digits equal to digits. - /// is less than 0 or greater than the maximum number of integral and fractional digits supported by the type. - /// - /// This method uses the default rounding convention of - /// If the value of is , the method returns . - /// If is or , the method returns or , respectively. - /// - [MethodImpl(MaxOpt)] - public static T Round(T x, int digits) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if MATHF - return (T) (object) (Half) (float) MathF.Round((float)(Half) (object) x, digits); -#else - return (T) (object) (Half) (float) Math.Round((float) (Half) (object) x, digits); -#endif - } - - return Float(x, digits); - - [MethodImpl(MaxOpt)] - static T Float(T x, int digits) - { - if (typeof(T) == typeof(float)) - { -#if MATHF - return (T) (object) (float) MathF.Round((float)(object) x, digits); -#else - return (T) (object) (float) Math.Round((float) (object) x, digits); -#endif - } - - return Double(x, digits); - } - - [MethodImpl(MaxOpt)] - static T Double(T x, int digits) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) (double) Math.Round((double) (object) x, digits); - } - - return Decimal(x, digits); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x, int digits) - { - if (typeof(T) == typeof(decimal)) - ThrowOpUnsupportedPrecision(); - - return Other(x, digits); - } - - [MethodImpl(MaxOpt)] - static T Other(T x, int digits) - { - if (typeof(T) == typeof(sbyte) - || typeof(T) == typeof(byte) - || typeof(T) == typeof(ushort) - || typeof(T) == typeof(short) - || typeof(T) == typeof(uint) - || typeof(T) == typeof(int) - || typeof(T) == typeof(ulong) - || typeof(T) == typeof(long) - ) - return x; - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Rounds a single-precision floating-point value to a specified number of fractional digits, and uses the specified rounding convention for midpoint values. - /// - /// A number to be rounded. - /// The number of fractional digits in the return value. - /// Specification for how to round if it is midway between two other numbers. - /// The type of . - /// The number nearest to that contains a number of fractional digits equal to digits. If has fewer fractional digits than , is returned unchanged. - /// is less than 0 or greater than the maximum number of integral and fractional digits supported by the type. - /// - /// If the value of is , the method returns . - /// If is or , the method returns or , respectively. - /// - [MethodImpl(MaxOpt)] - public static T Round(T x, int digits, System.MidpointRounding mode) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if MATHF - return (T) (object) (Half) (float) MathF.Round((float)(Half) (object) x, digits, mode); -#else - return (T) (object) (Half) (float) Math.Round((float) (Half) (object) x, digits, mode); -#endif - } - - return Float(x, digits, mode); - - [MethodImpl(MaxOpt)] - static T Float(T x, int digits, MidpointRounding mode) - { - if (typeof(T) == typeof(float)) - { -#if MATHF - return (T) (object) (float) MathF.Round((float)(object) x, digits, mode); -#else - return (T) (object) (float) Math.Round((float) (object) x, digits, mode); -#endif - } - - return Double(x, digits, mode); - } - - [MethodImpl(MaxOpt)] - static T Double(T x, int digits, MidpointRounding mode) - { - if (typeof(T) == typeof(double)) - { - return (T) (object) (double) Math.Round((double) (object) x, digits, mode); - } - - return Decimal(x, digits, mode); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x, int digits, MidpointRounding mode) - { - if (typeof(T) == typeof(decimal)) - ThrowOpUnsupportedPrecision(); - - return Other(x, digits, mode); - } - - [MethodImpl(MaxOpt)] - static T Other(T x, int digits, MidpointRounding mode) - { - if (typeof(T) == typeof(sbyte) - || typeof(T) == typeof(byte) - || typeof(T) == typeof(ushort) - || typeof(T) == typeof(short) - || typeof(T) == typeof(uint) - || typeof(T) == typeof(int) - || typeof(T) == typeof(ulong) - || typeof(T) == typeof(long) - - ) - return x; - - ThrowUnsupportedType(); - return default; - } - } - - /// - /// Rounds a single-precision floating-point value to the nearest integer, and uses the specified rounding convention for midpoint values. - /// - /// A single-precision floating-point number to be rounded. - /// Specification for how to round x if it is midway between two other numbers. - /// The type of . - /// The integer nearest . If is halfway between two integers, one of which is even and the other odd, then mode determines which of the two is returned. Note that this method returns instead of an integral type. - /// is not a valid value of . - /// - /// If the value of is , the method returns . - /// If is or , the method returns or , respectively. - /// \ - [MethodImpl(MaxOpt)] - public static T Round(T x, System.MidpointRounding mode) where T : notnull - { - if (typeof(T) == typeof(Half)) - { -#if !MATHF - return (T) (object) (Half) (float) Math.Round((float) (Half) (object) x, mode); -#else - return (T) (object) (Half) MathF.Round((float) (Half) (object) x, mode); -#endif - } - - return Float(x, mode); - - [MethodImpl(MaxOpt)] - static T Float(T x, MidpointRounding mode) - { - if (typeof(T) == typeof(float)) - { -#if SSE - if (Sse42.IsSupported) - { - if (mode == MidpointRounding.ToZero) - return (T)(object)(float)Sse41.RoundToZeroScalar(Vector128.CreateScalarUnsafe((float)(object)x)).ToScalar(); - - if (mode == MidpointRounding.ToPositiveInfinity) - return (T)(object)(float)Sse41.RoundToPositiveInfinityScalar(Vector128.CreateScalarUnsafe((float)(object)x)).ToScalar(); - - if (mode == MidpointRounding.ToNegativeInfinity) - return (T)(object)(float)Sse41.RoundToNegativeInfinityScalar(Vector128.CreateScalarUnsafe((float)(object)x)).ToScalar(); - - if (mode == MidpointRounding.ToEven) - return (T)(object)(float)Sse41.RoundToNearestIntegerScalar(Vector128.CreateScalarUnsafe((float)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - if (mode == MidpointRounding.ToZero) - return (T)(object)(float)AdvSimd.RoundToZeroScalar(Vector64.CreateScalarUnsafe((float)(object)x)).ToScalar(); - - if (mode == MidpointRounding.ToPositiveInfinity) - return (T)(object)(float)AdvSimd.RoundToPositiveInfinityScalar(Vector64.CreateScalarUnsafe((float)(object)x)).ToScalar(); - - if (mode == MidpointRounding.ToNegativeInfinity) - return (T)(object)(float)AdvSimd.RoundToNegativeInfinityScalar(Vector64.CreateScalarUnsafe((float)(object)x)).ToScalar(); - - if (mode == MidpointRounding.ToEven) - return (T)(object)(float)AdvSimd.RoundToNearestScalar(Vector64.CreateScalarUnsafe((float)(object)x)).ToScalar(); - } -#endif -#if !MATHF - return (T) (object) (float) Math.Round((float) (object) x, mode); -#else - return (T) (object) MathF.Round((float) (object) x, mode); -#endif - } - - return Double(x, mode); - } - - [MethodImpl(MaxOpt)] - static T Double(T x, MidpointRounding mode) - { - if (typeof(T) == typeof(double)) - { -#if SSE - if (Sse42.IsSupported) - { - if (mode == MidpointRounding.ToZero) - return (T)(object)(double)Sse41.RoundToZeroScalar(Vector128.CreateScalarUnsafe((double)(object)x)).ToScalar(); - - if (mode == MidpointRounding.ToPositiveInfinity) - return (T)(object)(double)Sse41.RoundToPositiveInfinityScalar(Vector128.CreateScalarUnsafe((double)(object)x)).ToScalar(); - - if (mode == MidpointRounding.ToNegativeInfinity) - return (T)(object)(double)Sse41.RoundToNegativeInfinityScalar(Vector128.CreateScalarUnsafe((double)(object)x)).ToScalar(); - - if (mode == MidpointRounding.ToEven) - return (T)(object)(double)Sse41.RoundToNearestIntegerScalar(Vector128.CreateScalarUnsafe((double)(object)x)).ToScalar(); - } -#endif -#if AdvSIMD - if (AdvSimd.IsSupported) - { - if (mode == MidpointRounding.ToZero) - return (T)(object)(double)AdvSimd.RoundToZeroScalar(Vector64.CreateScalar((double)(object)x)).ToScalar(); - - if (mode == MidpointRounding.ToPositiveInfinity) - return (T)(object)(double)AdvSimd.RoundToPositiveInfinityScalar(Vector64.CreateScalar((double)(object)x)).ToScalar(); - - if (mode == MidpointRounding.ToNegativeInfinity) - return (T)(object)(double)AdvSimd.RoundToNegativeInfinityScalar(Vector64.CreateScalar((double)(object)x)).ToScalar(); - - if (mode == MidpointRounding.ToEven) - return (T)(object)(double)AdvSimd.RoundToNearestScalar(Vector64.CreateScalar((double)(object)x)).ToScalar(); - } -#endif - return (T) (object) (double) Math.Round((double) (object) x, mode); - } - - return Decimal(x, mode); - } - - [MethodImpl(MaxOpt)] - static T Decimal(T x, MidpointRounding mode) - { - if (typeof(T) == typeof(decimal)) - { - return (T) (object) (decimal) Math.Round((decimal) (object) x, mode); - } - - return SByte(x); - } - - [MethodImpl(MaxOpt)] - static T SByte(T x) - { - if (typeof(T) == typeof(sbyte)) - { - return x; - } - - return Byte(x); - } - - [MethodImpl(MaxOpt)] - static T Byte(T x) - { - if (typeof(T) == typeof(byte)) - { - return x; - } - - return Short(x); - } - - [MethodImpl(MaxOpt)] - static T Short(T x) - { - if (typeof(T) == typeof(short)) - { - return x; - } - - return UShort(x); - } - - [MethodImpl(MaxOpt)] - static T UShort(T x) - { - if (typeof(T) == typeof(ushort)) - { - return x; - } - - return Int(x); - } - - [MethodImpl(MaxOpt)] - static T Int(T x) - { - if (typeof(T) == typeof(int)) - { - return x; - } - - return UInt(x); - } - - [MethodImpl(MaxOpt)] - static T UInt(T x) - { - if (typeof(T) == typeof(uint)) - { - return x; - } - - return Long(x); - } - - [MethodImpl(MaxOpt)] - static T Long(T x) - { - if (typeof(T) == typeof(long)) - { - return x; - } - - return ULong(x); - } - - [MethodImpl(MaxOpt)] - static T ULong(T x) - { - if (typeof(T) == typeof(ulong)) - { - return x; - } - - ThrowUnsupportedType(); - return default; - } - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Pow.cs b/sources/Maths/Maths/Scalar.Pow.cs deleted file mode 100644 index 083f16441b..0000000000 --- a/sources/Maths/Maths/Scalar.Pow.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - public static partial class Scalar - { - [MethodImpl(MaxOpt)] - private static float CoreFastPow(float x, float y) - { - // improvements can be made here, namely by actually porting a full impl - // see https://github.com/amd/aocl-libm-ose/blob/master/src/optmized/powf.c - - return Exp(y * Log(x)); - } - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Scalar.Sin.cs b/sources/Maths/Maths/Scalar.Sin.cs deleted file mode 100644 index 8a2daffb3b..0000000000 --- a/sources/Maths/Maths/Scalar.Sin.cs +++ /dev/null @@ -1,476 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace Silk.NET.Maths -{ - static partial class Scalar - { - // - // See https://gist.github.com/tannergooding/103be726d48dc3d0b09e890bad0b892f - // - // This is a port of the amd/win-libm implementation provided in assembly here: https://github.com/amd/win-libm/blob/master/sinf.asm - // The original source is Copyright (c) 2002-2019 Advanced Micro Devices, Inc. and provided under the MIT License. - // - // Permission is hereby granted, free of charge, to any person obtaining a copy - // of this Software and associated documentaon files (the "Software"), to deal - // in the Software without restriction, including without limitation the rights - // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - // copies of the Software, and to permit persons to whom the Software is - // furnished to do so, subject to the following conditions: - // - // The above copyright notice and this permission notice shall be included in - // all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - // THE SOFTWARE. - - private static readonly long[] _piBits = - { - 0, - 5215, - 13000023176, - 11362338026, - 67174558139, - 34819822259, - 10612056195, - 67816420731, - 57840157550, - 19558516809, - 50025467026, - 25186875954, - 18152700886 - }; - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - private static long GetPiBits(int index) - { - switch (index) - { - case 0: - return 0; - case 1: - return 5215; - case 2: - return 13000023176; - case 3: - return 11362338026; - case 4: - return 67174558139; - case 5: - return 34819822259; - case 6: - return 10612056195; - case 7: - return 67816420731; - case 8: - return 57840157550; - case 9: - return 19558516809; - case 10: - return 50025467026; - case 11: - return 25186875954; - case 12: - return 18152700886; - default: - ThrowIndexOutOfRange(); - return default; - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - internal static float Sin_Ported(float x) - { - const double PiOverTwo = 1.5707963267948966; - const double PiOverTwoPartOne = 1.5707963267341256; - const double PiOverTwoPartOneTail = 6.077100506506192E-11; - const double PiOverTwoPartTwo = 6.077100506303966E-11; - const double PiOverTwoPartTwoTail = 2.0222662487959506E-21; - const double PiOverFour = 0.7853981633974483; - const double TwoOverPi = 0.6366197723675814; - const double TwoPowNegSeven = 0.0078125; - const double TwoPowNegThirteen = 0.0001220703125; - const double C0 = -1.0 / 2.0; // 1 / 2! - const double C1 = +1.0 / 24.0; // 1 / 4! - const double C2 = -1.0 / 720.0; // 1 / 6! - const double C3 = +1.0 / 40320.0; // 1 / 8! - const double C4 = -1.0 / 3628800.0; // 1 / 10! - const double S1 = -1.0 / 6.0; // 1 / 3! - const double S2 = +1.0 / 120.0; // 1 / 5! - const double S3 = -1.0 / 5040.0; // 1 / 7! - const double S4 = +1.0 / 362880.0; // 1 / 9! - - - if (CoreIsFinite(x)) - { - double ax = Math.Abs(x); - - double result; - if (ax <= PiOverFour) - { - if (ax >= TwoPowNegSeven) - { - result = SinTaylorSeriesFourIterations(x); - } - else if (ax >= TwoPowNegThirteen) - { - result = SinTaylorSeriesOneIteration(x); - } - else - { - result = x; - } - } - else - { - var wasNegative = 0; - - if (CoreIsNegative(x)) - { - x = -x; - wasNegative = 1; - } - - int region; - - if (x < 16000000.0) - { - // Reduce x to be in the range of -(PI / 4) to (PI / 4), inclusive - - // This is done by subtracting multiples of (PI / 2). Double-precision - // isn't quite accurate enough and introduces some error, but we account - // for that using a tail value that helps account for this. - - var axExp = BitConverter.DoubleToInt64Bits(ax) >> 52; - - region = (int) (x * TwoOverPi + 0.5); - double piOverTwoCount = region; - - var rHead = x - (piOverTwoCount * PiOverTwoPartOne); - var rTail = (piOverTwoCount * PiOverTwoPartOneTail); - - var r = rHead - rTail; - var rExp = (BitConverter.DoubleToInt64Bits(r) << 1) >> 53; - - if ((axExp - rExp) > 15) - { - // The remainder is pretty small compared with x, which implies that x is - // near a multiple of (PI / 2). That is, x matches the multiple to at least - // 15 bits and so we perform an additional fixup to account for any error - - r = rHead; - - rTail = (piOverTwoCount * PiOverTwoPartTwo); - rHead = r - rTail; - rTail = (piOverTwoCount * PiOverTwoPartTwoTail) - ((r - rHead) - rTail); - - r = rHead - rTail; - } - - if (rExp >= 0x3F2) // r >= 2^-13 - { - result = (region & 1) == 0 - ? SinTaylorSeriesFourIterations(r) // region 0 or 2 - : CosTaylorSeriesFourIterations(r); // region 1 or 3 - } - else if (rExp > 0x3DE) // r > 1.1641532182693481E-10 - { - result = (region & 1) == 0 - ? SinTaylorSeriesOneIteration(r) // region 0 or 2 - : CosTaylorSeriesOneIteration(r); // region 1 or 3 - } - else - { - if ((region & 1) == 0) // region 0 or 2 - { - result = r; - } - else // region 1 or 3 - { - result = 1; - } - } - } - else - { - var r = ReduceForLargeInput(x, out region); - - result = (region & 1) == 0 - ? SinTaylorSeriesFourIterations(r) // region 0 or 2 - : CosTaylorSeriesFourIterations(r);// region 1 or 3 - } - - region >>= 1; - - var tmp1 = region & wasNegative; - - region = ~region; - wasNegative = ~wasNegative; - - var tmp2 = region & wasNegative; - - if (((tmp1 | tmp2) & 1) == 0) - { - // If the original region was 0/1 and arg is negative, then we negate the result. - // -or- - // If the original region was 2/3 and arg is positive, then we negate the result. - - result = -result; - } - } - - return (float) result; - } - - // modified to raise NaN on infinite - return float.NaN; - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - static double CosTaylorSeriesOneIteration(double x1) - { - // 1 - (x^2 / 2!) - var x2 = x1 * x1; - return 1.0 + (x2 * C1); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - static double CosTaylorSeriesFourIterations(double x1) - { - // 1 - (x^2 / 2!) + (x^4 / 4!) - (x^6 / 6!) + (x^8 / 8!) - (x^10 / 10!) - - var x2 = x1 * x1; - var x4 = x2 * x2; - - return 1.0 + (x2 * C0) + (x4 * ((C1 + (x2 * C2)) + (x4 * (C3 + (x2 * C4))))); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - static unsafe double ReduceForLargeInput(double x, out int region) - { - Debug.Assert(!CoreIsNegative(x)); - - // This method simulates multi-precision floating-point - // arithmetic and is accurate for all 1 <= x < infinity - - const int bitsPerIteration = 36; - var ux = BitConverter.DoubleToInt64Bits(x); - - var xExp = (int) (((ux & 0x7FF0000000000000) >> 52) - 1023); - ux = ((ux & 0x000FFFFFFFFFFFFF) | 0x0010000000000000) >> 29; - - // Now ux is the mantissa bit pattern of x as a long integer - long mask = 1; - mask = (mask << bitsPerIteration) - 1; - - // Set first and last to the positions of the first and last chunks of (2 / PI) that we need - var first = xExp / bitsPerIteration; - var resultExp = xExp - (first * bitsPerIteration); - - // 120 is the theoretical maximum number of bits (actually - // 115 for IEEE single precision) that we need to extract - // from the middle of (2 / PI) to compute the reduced argument - // accurately enough for our purposes - - var last = first + (120 / bitsPerIteration); - - // Unroll the loop. This is only correct because we know that bitsper is fixed as 36. - - var result = stackalloc long[10]; - - result[4] = 0; - var u = _piBits[last] * ux; - - result[3] = u & mask; - var carry = u >> bitsPerIteration; - u = _piBits[last - 1] * ux + carry; - - result[2] = u & mask; - carry = u >> bitsPerIteration; - u = _piBits[last - 2] * ux + carry; - - result[1] = u & mask; - carry = u >> bitsPerIteration; - u = _piBits[first] * ux + carry; - - result[0] = u & mask; - - // Reconstruct the result - var ltb = (int) ((((result[0] << bitsPerIteration) | result[1]) >> (bitsPerIteration - 1 - resultExp)) & - 7); - - long mantissa; - long nextBits; - - // determ says whether the fractional part is >= 0.5 - var determ = (ltb & 1) != 0; - - var i = 1; - - if (determ) - { - // The mantissa is >= 0.5. We want to subtract it from 1.0 by negating all the bits - region = ((ltb >> 1) + 1) & 3; - - mantissa = 1; - mantissa = ~(result[1]) & ((mantissa << (bitsPerIteration - resultExp)) - 1); - - while (mantissa < 0x0000000000010000) - { - i++; - mantissa = (mantissa << bitsPerIteration) | (~(result[i]) & mask); - } - - nextBits = (~(result[i + 1]) & mask); - } - else - { - region = (ltb >> 1); - - mantissa = 1; - mantissa = result[1] & ((mantissa << (bitsPerIteration - resultExp)) - 1); - - while (mantissa < 0x0000000000010000) - { - i++; - mantissa = (mantissa << bitsPerIteration) | result[i]; - } - - nextBits = result[i + 1]; - } - - // Normalize the mantissa. - // The shift value 6 here, determined by trial and error, seems to give optimal speed. - - var bc = 0; - - while (mantissa < 0x0000400000000000) - { - bc += 6; - mantissa <<= 6; - } - - while (mantissa < 0x0010000000000000) - { - bc++; - mantissa <<= 1; - } - - mantissa |= nextBits >> (bitsPerIteration - bc); - - var rExp = 52 + resultExp - bc - i * bitsPerIteration; - - // Put the result exponent rexp onto the mantissa pattern - u = (rExp + 1023L) << 52; - ux = (mantissa & 0x000FFFFFFFFFFFFF) | u; - - if (determ) - { - // If we negated the mantissa we negate x too - ux |= unchecked((long) (0x8000000000000000)); - } - - x = BitConverter.Int64BitsToDouble(ux); - - // x is a double precision version of the fractional part of - // (x * (2 / PI)). Multiply x by (PI / 2) in double precision - // to get the reduced result. - - return x * PiOverTwo; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - static double SinTaylorSeriesOneIteration(double x1) - { - // x - (x^3 / 3!) - - var x2 = x1 * x1; - var x3 = x2 * x1; - - return x1 + (x3 * S1); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - static double SinTaylorSeriesFourIterations(double x1) - { - // x - (x^3 / 3!) + (x^5 / 5!) - (x^7 / 7!) + (x^9 / 9!) - - var x2 = x1 * x1; - var x3 = x2 * x1; - var x4 = x2 * x2; - - return x1 + ((S1 + (x2 * S2) + (x4 * (S3 + (x2 * S4)))) * x3); - } - } - -#if NET5_0 - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - private static bool CoreIsNegative(double d) => BitConverter.DoubleToInt64Bits(d) < 0; - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - private static unsafe bool CoreIsNegative(float f) => *(int*) &f < 0; - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - private static unsafe bool CoreIsFinite(float f) => (*(int*) &f & 0x7FFFFFFF) < 0x7F800000; - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - private static unsafe bool CoreIsSubnormal(float f) - { - var bits = *(int*) &f; - bits &= 0x7FFFFFFF; - return (bits < 0x7F800000) && (bits != 0) && ((bits & 0x7F800000) == 0); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - private static bool CoreIsSubnormal(double f) - { - var bits = BitConverter.DoubleToInt64Bits(f); - bits &= 0x7FFFFFFFFFFFFFFF; - return (bits < 0x7FF0000000000000) && (bits != 0) && ((bits & 0x7FF0000000000000) == 0); - } -#else - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - private static bool CoreIsNegative(double d) => BitConverter.DoubleToInt64Bits(d) < 0; - - // ripped straight from BitConverter on > NetStandard2.1. - // in fact, everything below is ripped from methods on NetStandard2.1, but which aren't available on NetStandard2.0 - private static unsafe int SingleToInt(float f) - { - return *((int*) &f); - } - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - private static bool CoreIsNegative(float f) - { - // FUCK I HATE NETSTANDARD - return SingleToInt(f) < 0; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - private static bool CoreIsFinite(float f) => ((SingleToInt(f)) & 0x7FFFFFFF) < 0x7F800000; - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - private static bool CoreIsSubnormal(float f) - { - var bits = SingleToInt(f); - bits &= 0x7FFFFFFF; - return (bits < 0x7F800000) && (bits != 0) && ((bits & 0x7F800000) == 0); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining | (MethodImplOptions) 512)] - private static bool CoreIsSubnormal(double f) - { - long bits = BitConverter.DoubleToInt64Bits(f); - bits &= 0x7FFFFFFFFFFFFFFF; - return (bits < 0x7FF0000000000000) && (bits != 0) && ((bits & 0x7FF0000000000000) == 0); - } -#endif - } -} \ No newline at end of file diff --git a/sources/Maths/Maths/Silk.NET.Maths.csproj b/sources/Maths/Maths/Silk.NET.Maths.csproj index c4a41cabc6..85025192ac 100644 --- a/sources/Maths/Maths/Silk.NET.Maths.csproj +++ b/sources/Maths/Maths/Silk.NET.Maths.csproj @@ -18,21 +18,6 @@ - - - True - True - Scalar.As.tt - - - - - - TextTemplatingFileGenerator - Scalar.As.cs - - - diff --git a/sources/Maths/Maths/Sphere.cs b/sources/Maths/Maths/Sphere.cs index 7c44cf801c..0432141092 100644 --- a/sources/Maths/Maths/Sphere.cs +++ b/sources/Maths/Maths/Sphere.cs @@ -21,6 +21,7 @@ public struct Sphere /// [DataMember] public Vector3D Center; + /// /// The radius. /// @@ -54,13 +55,13 @@ public Sphere(T centerX, T centerY, T centerZ, T radius) /// The diameter. /// [IgnoreDataMember] - public T Diameter => Scalar.Multiply(Radius, Scalar.Two); + public T Diameter => Radius * T.CreateTruncating(2); /// /// The radius squared. /// [IgnoreDataMember] - public T SquaredRadius => Scalar.Multiply(Radius, Radius); + public T SquaredRadius => Radius * Radius; /// @@ -71,7 +72,7 @@ public Sphere(T centerX, T centerY, T centerZ, T radius) /// This does consider a point on the edge contained. public bool Contains(Vector3D point) { - return Scalar.LessThanOrEqual(Vector3D.DistanceSquared(point, Center), Radius); + return Vector3D.DistanceSquared(point, Center) <= Radius; } /// @@ -83,8 +84,8 @@ public bool Contains(Vector3D point) public bool Contains(Sphere other) { var distanceSquared = Vector3D.DistanceSquared(Center, other.Center); - var radiusDiff = Scalar.Subtract(Radius, other.Radius); - return Scalar.LessThanOrEqual(distanceSquared, Scalar.Multiply(radiusDiff, radiusDiff)); + var radiusDiff = Radius - other.Radius; + return distanceSquared <= radiusDiff * radiusDiff; } /// @@ -94,7 +95,7 @@ public bool Contains(Sphere other) /// The distance squared. public T GetDistanceToNearestEdgeSquared(Vector3D point) { - return Scalar.Subtract(Vector3D.DistanceSquared(Center, point), SquaredRadius); + return Vector3D.DistanceSquared(Center, point) - SquaredRadius; } /// @@ -102,7 +103,7 @@ public T GetDistanceToNearestEdgeSquared(Vector3D point) /// /// The point. /// The distance. - public T GetDistanceToNearestEdge(Vector3D point) => Scalar.Sqrt(GetDistanceToNearestEdgeSquared(point)); + public T GetDistanceToNearestEdge(Vector3D point) => T.Sqrt(GetDistanceToNearestEdgeSquared(point)); /// /// Calculates a new sphere translated by a given distance. @@ -121,7 +122,7 @@ public Sphere GetTranslated(Vector3D distance) /// The sphere. public Sphere GetInflated(Vector3D point) { - return new(Center, Scalar.Max(Radius, Vector3D.Distance(Center, point))); + return new(Center, T.Max(Radius, Vector3D.Distance(Center, point))); } /// Returns a boolean indicating whether the given Sphere is equal to this Sphere instance. @@ -164,7 +165,7 @@ public override int GetHashCode() { return !value1.Equals(value2); } - + /// /// Returns this sphere casted to /// @@ -174,7 +175,7 @@ public override int GetHashCode() public Sphere As() where TOther : IRootFunctions { - return new(Center.As(), Scalar.As(Radius)); + return new(Center.As(), TOther.CreateTruncating(Radius)); } } } diff --git a/tests/Maths/Maths/ExpTests.cs b/tests/Maths/Maths/ExpTests.cs deleted file mode 100644 index 668a49e77e..0000000000 --- a/tests/Maths/Maths/ExpTests.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Xunit; - -namespace Silk.NET.Maths.Tests -{ - public class ExpTests - { - [Fact] - public void MaxInf() - { - var value = 3.5990256e+33f + 1; - var expected = float.PositiveInfinity; -#if !NET48 - Assert.StrictEqual(expected, MathF.Exp(value)); -#endif - Assert.StrictEqual(expected, Scalar.Exp(value)); - } - - [Fact] - public void Exp0() - { - var value = 0f; - var expected = 1f; -#if !NET48 - Assert.StrictEqual(expected, MathF.Exp(value)); -#endif - Assert.StrictEqual(expected, Scalar.Exp(value)); - } - - [Fact] - public void Exp1() - { - var value = 1f; - var expected = 2.71828182846f; -#if !NET48 - Assert.StrictEqual(expected, MathF.Exp(value)); -#endif - Assert.StrictEqual(expected, Scalar.Exp(value)); - } - - [Fact] - public void Exp2() - { - var value = 2f; - var expected = 7.38905609893f; -#if !NET48 - Assert.StrictEqual(expected, MathF.Exp(value)); -#endif - Assert.Equal(expected, Scalar.Exp(value)); - } - - [Fact] - public void Exp5() - { - var value = 5f; - var expected = 148.413159103f; -#if !NET48 - Assert.StrictEqual(expected, MathF.Exp(value)); -#endif - Assert.Equal(expected, Scalar.Exp(value)); - } - - // [Fact] - // public void Exp50() - // { - // var value = 50f; - // var expected = 5.1847055e+21f; - // Assert.Equal(expected, MathF.Exp(value)); - // Assert.Equal(expected, Scalar.Exp(value)); - // } - } -} diff --git a/tests/Maths/Maths/LogTests.cs b/tests/Maths/Maths/LogTests.cs deleted file mode 100644 index 3ff2b0bee7..0000000000 --- a/tests/Maths/Maths/LogTests.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Xunit; - -namespace Silk.NET.Maths.Tests -{ - public class LogTests - { - [Fact] - public void Log0() - { - Assert.StrictEqual(float.NegativeInfinity, Scalar.Log(0f)); - } - - [Fact] - public void Log1() - { - Assert.StrictEqual(0f, Scalar.Log(1f)); - } - - [Fact] - public void LogSmall1() - { - Assert.Equal(-2.0955709236097195567919657540932, Scalar.Log(.123f), 6); - // MathF is also inaccurate :) -#if !NET48 - Assert.Equal(-2.0955709236097195567919657540932, System.MathF.Log(.123f), 6); -#endif - } - - [Fact] - public void Log2() - { - Assert.Equal(0.69314718055994530941723212145818f, Scalar.Log(2f)); - } - - [Fact] - public void Log5() - { - Assert.Equal(1.6094379124341003746007593332262f, Scalar.Log(5f)); - } - - [Fact] - public void Log100() - { - Assert.Equal(4.6051701859880913680359829093687f, Scalar.Log(100f)); - } - - [Fact] - public void Log123() - { - Assert.Equal(4.8121843553724174952620086099599f, Scalar.Log(123f)); - } - } -} diff --git a/tests/Maths/Maths/PlaneTests.cs b/tests/Maths/Maths/PlaneTests.cs index 53a869dd4a..ff12a98c3f 100644 --- a/tests/Maths/Maths/PlaneTests.cs +++ b/tests/Maths/Maths/PlaneTests.cs @@ -147,7 +147,7 @@ public void PlaneCreateFromVerticesTest2() Vector3D point3 = new Vector3D(1.0f, 1.0f, 0.0f); Plane target = Plane.CreateFromVertices(point1, point2, point3); - var invRoot2 = 1.0f / Scalar.Sqrt(2); + var invRoot2 = 1.0f / float.Sqrt(2); Plane expected = new Plane(new Vector3D(invRoot2, 0, invRoot2), -invRoot2); Assert.True(MathHelper.Equal(target, expected), "Plane.cstor did not return the expected value."); @@ -217,7 +217,7 @@ public void PlaneNormalizeTest() Plane target = new Plane(1, 2, 3, 4); float f = target.Normal.LengthSquared; - float invF = 1.0f / (float)Scalar.Sqrt(f); + float invF = 1.0f / float.Sqrt(f); Plane expected = new Plane(target.Normal * invF, target.Distance * invF); Plane actual = Plane.Normalize(target); diff --git a/tests/Maths/Maths/PowIntTests.cs b/tests/Maths/Maths/PowIntTests.cs deleted file mode 100644 index c65dfb66d8..0000000000 --- a/tests/Maths/Maths/PowIntTests.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Xunit; - -namespace Silk.NET.Maths.Tests -{ - public class PowIntTests - { - [Fact] - public void Powx0() - { - var a = 100; - var b = 0; - var expected = 1; - Assert.Equal(expected, Scalar.Pow(a, b)); - } - - [Fact] - public void Pow00() - { - var a = 0; - var b = 0; - var expected = 0; - Assert.Equal(expected, Scalar.Pow(a, b)); - } - - [Fact] - public void Pow12() - { - var a = 1; - var b = 2; - var expected = 1; - Assert.Equal(expected, Scalar.Pow(a, b)); - } - - [Fact] - public void Pow24() - { - var a = 2; - var b = 4; - var expected = 2 << 3; - Assert.Equal(expected, Scalar.Pow(a, b)); - } - - [Fact] - public void Pow2Minus4() - { - var a = 2; - var b = -4; - var expected = Scalar.Reciprocal(2 << 3); - Assert.Equal(expected, Scalar.Pow(a, b)); - } - } -} diff --git a/tests/Maths/Maths/Scalar.Bitwise.cs b/tests/Maths/Maths/Scalar.Bitwise.cs deleted file mode 100644 index a61ac7a8c9..0000000000 --- a/tests/Maths/Maths/Scalar.Bitwise.cs +++ /dev/null @@ -1,111 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Globalization; -using System.Runtime.InteropServices; -using Xunit; - -namespace Silk.NET.Maths.Tests -{ - public class ScalarBitwiseTest - { - [Fact] - public void RotateLeft1() - { - Assert.Equal((byte)0b1110_0001, Scalar.RotateLeft((byte)0b1111_0000, 1)); - } - - [Fact] - public void RotateLeft2() - { - Assert.Equal((ushort)0b1100_1000_0000_0011, Scalar.RotateLeft((ushort)0b1111_0010_0000_0000, 2)); - } - - [Fact] - public void RotateRight1() - { - Assert.Equal((byte)0b1111_0000, Scalar.RotateRight((byte)0b1110_0001, 1)); - } - - [Fact] - public void RotateRight2() - { - Assert.Equal((ushort)0b1111_0010_0000_0000, Scalar.RotateRight((ushort)0b1100_1000_0000_0011, 2)); - } - - [Fact] - public void And1() - { - Assert.Equal(0b1010, Scalar.And(0b1110, 0b1011)); - } - - [Fact] - public void And2() - { - Assert.Equal((byte)0b1010, Scalar.And((byte)0b1110, (byte)0b1011)); - } - - [Fact] - public void And3() - { - Assert.Equal((long)0b1010, Scalar.And((long)0b1110, (long)0b1011)); - } - - [Fact] - public void Or1() - { - Assert.Equal(0b1111, Scalar.Or(0b1110, 0b1011)); - } - - [Fact] - public void Or2() - { - Assert.Equal((byte)0b1111, Scalar.Or((byte)0b1110, (byte)0b1011)); - } - - [Fact] - public void Or3() - { - Assert.Equal((long)0b1111, Scalar.Or((long)0b1110, (long)0b1011)); - } - - [Fact] - public void Xor1() - { - Assert.Equal(0b0101, Scalar.Xor(0b1110, 0b1011)); - } - - [Fact] - public void Xor2() - { - Assert.Equal((byte)0b0101, Scalar.Xor((byte)0b1110, (byte)0b1011)); - } - - [Fact] - public void Xor3() - { - Assert.Equal((long)0b0101, Scalar.Xor((long)0b1110, (long)0b1011)); - } - - [Fact] - public void Not1() - { - Assert.Equal(~0b1110, Scalar.Not(0b1110)); - } - - [Fact] - public void Not2() - { - var b = ~(byte)0b1110; - // ReSharper disable once IntVariableOverflowInUncheckedContext - Assert.Equal((byte)b, Scalar.Not((byte)0b1110)); - } - - [Fact] - public void Not3() - { - Assert.Equal(~(ulong)0b1110, Scalar.Not((ulong)0b1110)); - } - } -} \ No newline at end of file diff --git a/tests/Maths/Maths/ScalarTests.cs b/tests/Maths/Maths/ScalarTests.cs deleted file mode 100644 index 3966c63061..0000000000 --- a/tests/Maths/Maths/ScalarTests.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Numerics; -using Xunit; - -namespace Silk.NET.Maths.Tests -{ - public class ScalarTests - { - [Fact] public void AddBigInteger() - => Assert.Equal(new BigInteger(100), Scalar.Add(BigInteger.One, 99)); - - [Fact] public void SubtractBigInteger() - => Assert.Equal(new BigInteger(-98), Scalar.Subtract(BigInteger.One, 99)); - - [Fact] public void MultiplyBigInteger() - => Assert.Equal(new BigInteger(990), Scalar.Multiply(new BigInteger(10), 99)); - - [Fact] public void DivideBigInteger() - => Assert.Equal(new BigInteger(5), Scalar.Divide(new BigInteger(16), 3)); - - [Fact] public void LessThanBigInteger() - => Assert.True(Scalar.LessThan(new BigInteger(10), 99)); - - [Fact] public void GreaterThanBigInteger() - => Assert.False(Scalar.GreaterThan(new BigInteger(10), 99)); - - [Fact] public void LessThanOrEqualBigInteger() - => Assert.True(Scalar.LessThanOrEqual(new BigInteger(10), 99)); - - [Fact] public void GreaterThanOrEqualBigInteger() - => Assert.False(Scalar.GreaterThanOrEqual(new BigInteger(10), 99)); - - [Fact] public void EqualBigInteger1() - => Assert.False(Scalar.Equal(new BigInteger(10), 99)); - - [Fact] public void EqualBigInteger2() - => Assert.True(Scalar.Equal(new BigInteger(10), 10)); - - // [Fact(Skip = "Abs is unmanaged currently")] public void AbsBigInteger() - // => Assert.Equal(new BigInteger(5), Scalar.Abs(new BigInteger(-5))); - - - [Fact] public void AddComplex() - => Assert.Equal(new Complex(109, 5), Scalar.Add(new Complex(10, 5), 99)); - - [Fact] public void SubtractComplex() - => Assert.Equal(new Complex(-89, 5), Scalar.Subtract(new Complex(10, 5), 99)); - - [Fact] public void MultiplyComplex() - => Assert.Equal(new Complex(990, 495), Scalar.Multiply(new Complex(10, 5), 99)); - - [Fact] public void DivideComplex() - => Assert.Equal(new Complex(10 / 99d, 5 / 99d), Scalar.Divide(new Complex(10, 5), 99)); - - [Fact] public void EqualComplex1() - => Assert.True(Scalar.Equal(new Complex(10, 5), new Complex(10, 5))); - - [Fact] public void EqualComplex2() - => Assert.False(Scalar.Equal(new Complex(10, 5), new Complex(10, 6))); - - [Fact] public void IsFiniteComplex1() - => Assert.True(Scalar.IsFinite(new Complex(10, 5))); - - [Fact] public void IsFiniteComplex2() - => Assert.False(Scalar.IsFinite(new Complex(double.NaN, 5))); - - [Fact] public void IsFiniteComplex3() - => Assert.False(Scalar.IsFinite(new Complex(10, double.NaN))); - - [Fact] public void IsFiniteComplex4() - => Assert.False(Scalar.IsFinite(new Complex(10, double.NegativeInfinity))); - - [Fact] public void IsInfinityComplex1() - => Assert.True(Scalar.IsInfinity(new Complex(double.NegativeInfinity, 5))); - - [Fact] public void IsInfinityComplex2() - => Assert.True(Scalar.IsInfinity(new Complex(5, double.NegativeInfinity))); - - [Fact] public void IsInfinityComplex3() - => Assert.True(Scalar.IsInfinity(new Complex(double.PositiveInfinity, 5))); - - [Fact] public void IsInfinityComplex4() - => Assert.True(Scalar.IsInfinity(new Complex(5, double.PositiveInfinity))); - - [Fact] public void AbsComplex() - => Assert.Equal(new Complex(5, 0), Scalar.Abs(new Complex(3, 4))); - } -} \ No newline at end of file From be95c6be97a28635ffe7be007e2491eec75c1a0d Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Fri, 18 Jul 2025 12:37:52 -0700 Subject: [PATCH 54/67] Update API & Constraints to use generic math in place of the Scalar type. --- sources/Maths/Maths/Box2D.cs | 32 +++++--- sources/Maths/Maths/Box3D.cs | 34 +++++--- sources/Maths/Maths/Circle.cs | 80 ++++++++++-------- sources/Maths/Maths/Cube.cs | 36 +++++---- sources/Maths/Maths/Matrix2X3.Ops.cs | 10 +-- sources/Maths/Maths/Matrix3X2.Ops.cs | 8 +- sources/Maths/Maths/Matrix3X3.Ops.cs | 16 ++-- sources/Maths/Maths/Matrix4X4.Ops.cs | 38 ++++----- sources/Maths/Maths/Plane.Ops.cs | 6 +- .../PublicAPI/net8.0/PublicAPI.Unshipped.txt | 25 +++--- sources/Maths/Maths/Quaternion.Old.cs | 3 +- sources/Maths/Maths/Quaternion.cs | 2 +- sources/Maths/Maths/Rectangle.Ops.cs | 15 ++++ sources/Maths/Maths/Rectangle.cs | 13 --- sources/Maths/Maths/Sphere.cs | 81 +++++++++++-------- 15 files changed, 227 insertions(+), 172 deletions(-) diff --git a/sources/Maths/Maths/Box2D.cs b/sources/Maths/Maths/Box2D.cs index 4eb606def6..7d377738c5 100644 --- a/sources/Maths/Maths/Box2D.cs +++ b/sources/Maths/Maths/Box2D.cs @@ -107,18 +107,6 @@ public bool Contains(Box2D other) => (other.Min.X >= Min.X) && (other.Min.Y >= Min.Y) && (other.Max.X <= Max.X) && (other.Max.Y <= Max.Y); - /// - /// Calculates the distance to the nearest edge from the point. - /// - /// The point. - /// The distance. - public T GetDistanceToNearestEdge(Vector2D point) - { - var dx = T.Max(T.Max(Min.X - point.X, T.Zero), point.X - Max.X); - var dy = T.Max(T.Max(Min.Y - point.Y, T.Zero), point.Y - Max.Y); - return T.Sqrt((dx * dx) + (dy * dy)); - } - /// /// Calculates this box translated by a given distance. /// @@ -251,4 +239,24 @@ public Box2D AsTruncating() return new(Min.AsTruncating(), Max.AsTruncating()); } } + + /// + /// Helper methods to work with + /// + public static class Box2D + { + /// + /// Calculates the distance to the nearest edge from the point. + /// + /// The box. + /// The point. + /// The distance. + public static T GetDistanceToNearestEdge(this Box2D box, Vector2D point) + where T : INumber, IRootFunctions + { + var dx = T.Max(T.Max(box.Min.X - point.X, T.Zero), point.X - box.Max.X); + var dy = T.Max(T.Max(box.Min.Y - point.Y, T.Zero), point.Y - box.Max.Y); + return T.Sqrt((dx * dx) + (dy * dy)); + } + } } diff --git a/sources/Maths/Maths/Box3D.cs b/sources/Maths/Maths/Box3D.cs index 5b81675b4d..5ef5851122 100644 --- a/sources/Maths/Maths/Box3D.cs +++ b/sources/Maths/Maths/Box3D.cs @@ -111,19 +111,6 @@ public bool Contains(Box3D other) => (other.Min.X >= this.Min.X) && (other.Min.Y >= this.Min.Y) && (other.Min.Z >= this.Min.Z) && (other.Max.X <= this.Max.X) && (other.Max.Y <= this.Max.Y) && (other.Max.Z <= this.Max.Z); - /// - /// Calculates the distance to the nearest edge from the point. - /// - /// The point. - /// The distance. - public T GetDistanceToNearestEdge(Vector3D point) - { - var dx = T.Max(T.Max(Min.X - point.X, T.Zero), point.X - Max.X); - var dy = T.Max(T.Max(Min.Y - point.Y, T.Zero), point.Y - Max.Y); - var dz = T.Max(T.Max(Min.Z - point.Z, T.Zero), point.Z - Max.Z); - return T.Sqrt((dx * dx) + (dy * dy) + (dz * dz)); - } - /// /// Calculates this box translated by a given distance. /// @@ -226,4 +213,25 @@ public Box3D As() return new(Min.As(), Max.As()); } } + + /// + /// Helper methods to work with + /// + public static class Box3D + { + /// + /// Calculates the distance to the nearest edge from the point. + /// + /// The box. + /// The point. + /// The distance. + public static T GetDistanceToNearestEdge(this Box3D box, Vector3D point) + where T : INumber, IRootFunctions + { + var dx = T.Max(T.Max(box.Min.X - point.X, T.Zero), point.X - box.Max.X); + var dy = T.Max(T.Max(box.Min.Y - point.Y, T.Zero), point.Y - box.Max.Y); + var dz = T.Max(T.Max(box.Min.Z - point.Z, T.Zero), point.Z - box.Max.Z); + return T.Sqrt((dx * dx) + (dy * dy) + (dz * dz)); + } + } } diff --git a/sources/Maths/Maths/Circle.cs b/sources/Maths/Maths/Circle.cs index fc860c1814..5468fd3be5 100644 --- a/sources/Maths/Maths/Circle.cs +++ b/sources/Maths/Maths/Circle.cs @@ -68,30 +68,6 @@ public Circle(T centerX, T centerY, T radius) [IgnoreDataMember] public T Circumference => T.Tau * Radius; - /// - /// Calculates whether this circle contains a point. - /// - /// The point. - /// True if this circle contains the point; False otherwise. - /// This does consider a point on the edge contained. - public bool Contains(Vector2D point) - { - return Vector2D.DistanceSquared(point, Center) <= Radius; - } - - /// - /// Calculates whether this circle contains another circle - /// - /// The circle. - /// True if this circle contains the given circle; False otherwise. - /// This does consider a circle that touches the edge contained. - public bool Contains(Circle other) - { - var distanceSquared = Vector2D.DistanceSquared(Center, other.Center); - var radiusDiff = Radius - other.Radius; - return distanceSquared <= radiusDiff * radiusDiff; - } - /// /// Calculates the squared distance to the nearest edge from the point. /// @@ -119,16 +95,6 @@ public Circle GetTranslated(Vector2D distance) return new(Center + distance, Radius); } - /// - /// Calculates a circle inflated to contain the given point. - /// - /// The point. - /// The circle. - public Circle GetInflated(Vector2D point) - { - return new(Center, T.Max(Radius, Vector2D.Distance(Center, point))); - } - /// Returns a boolean indicating whether the given Circle is equal to this Circle instance. /// The Circle to compare this instance to. /// True if the other Circle is equal to this instance; False otherwise. @@ -181,4 +147,50 @@ public Circle As() where TOther : IRootFunctions return new(Center.As(), TOther.CreateTruncating(Radius)); } } + + /// + /// Helper methods to work with + /// + public static class Circle + { + /// + /// Calculates whether this circle contains a point. + /// + /// The circle. + /// The point. + /// True if this circle contains the point; False otherwise. + /// This does consider a point on the edge contained. + public static bool Contains(this Circle circle, Vector2D point) + where T : INumber, IRootFunctions + { + return Vector2D.DistanceSquared(point, circle.Center) <= circle.Radius; + } + + /// + /// Calculates whether this circle contains another circle + /// + /// The circle. + /// The other circle. + /// True if this circle contains the given circle; False otherwise. + /// This does consider a circle that touches the edge contained. + public static bool Contains(this Circle circle, Circle other) + where T : INumber, IRootFunctions + { + var distanceSquared = Vector2D.DistanceSquared(circle.Center, other.Center); + var radiusDiff = circle.Radius - other.Radius; + return distanceSquared <= radiusDiff * radiusDiff; + } + + /// + /// Calculates a circle inflated to contain the given point. + /// + /// The circle. + /// The point. + /// The circle. + public static Circle GetInflated(this Circle circle, Vector2D point) + where T : INumber, IRootFunctions + { + return new(circle.Center, T.Max(circle.Radius, Vector2D.Distance(circle.Center, point))); + } + } } diff --git a/sources/Maths/Maths/Cube.cs b/sources/Maths/Maths/Cube.cs index 6948ab6200..f04423f3e7 100644 --- a/sources/Maths/Maths/Cube.cs +++ b/sources/Maths/Maths/Cube.cs @@ -123,20 +123,6 @@ public bool Contains(Cube other) && (oMax.X <= tMax.X) && (oMax.Y <= tMax.Y) && (oMax.Y <= tMax.Y); } - /// - /// Calculates the distance to the nearest edge from the point. - /// - /// The point. - /// The distance. - public T GetDistanceToNearestEdge(Vector3D point) - { - var max = Max; - var dx = T.Max(T.Max(Origin.X - point.X, T.Zero), point.X - max.X); - var dy = T.Max(T.Max(Origin.Y - point.Y, T.Zero), point.Y - max.Y); - var dz = T.Max(T.Max(Origin.Z - point.Z, T.Zero), point.Z - max.Z); - return T.Sqrt((dx * dx) + (dy * dy) + (dz * dz)); - } - /// /// Calculates a new cube translated by a given distance. /// @@ -241,4 +227,26 @@ public Cube As() return new(Origin.As(), Max.As()); } } + + /// + /// Helper methods to work with + /// + public static class Cube + { + /// + /// Calculates the distance to the nearest edge from the point. + /// + /// The cube. + /// The point. + /// The distance. + public static T GetDistanceToNearestEdge(Cube cube, Vector3D point) + where T : INumber, IRootFunctions + { + var max = cube.Max; + var dx = T.Max(T.Max(cube.Origin.X - point.X, T.Zero), point.X - max.X); + var dy = T.Max(T.Max(cube.Origin.Y - point.Y, T.Zero), point.Y - max.Y); + var dz = T.Max(T.Max(cube.Origin.Z - point.Z, T.Zero), point.Z - max.Z); + return T.Sqrt((dx * dx) + (dy * dy) + (dz * dz)); + } + } } diff --git a/sources/Maths/Maths/Matrix2X3.Ops.cs b/sources/Maths/Maths/Matrix2X3.Ops.cs index d201af2e30..6cb8eefe84 100644 --- a/sources/Maths/Maths/Matrix2X3.Ops.cs +++ b/sources/Maths/Maths/Matrix2X3.Ops.cs @@ -21,7 +21,7 @@ public static partial class Matrix2X3 /// The forward vector of the camera. /// The created billboard matrix public static Matrix2X3 CreateBillboard(Vector3D objectPosition, Vector3D cameraPosition, Vector3D cameraUpVector, Vector3D cameraForwardVector) - where T : IRootFunctions + where T : INumber, IRootFunctions { Vector3D zaxis = objectPosition - cameraPosition; var norm = zaxis.LengthSquared; @@ -46,7 +46,7 @@ public static Matrix2X3 CreateBillboard(Vector3D objectPosition, Vector /// The angle to rotate around the given axis, in radians. /// The rotation matrix. public static Matrix2X3 CreateFromAxisAngle(Vector3D axis, T angle) - where T : INumberBase + where T : ITrigonometricFunctions { // a: angle // x, y, z: unit vector for axis. @@ -95,7 +95,7 @@ public static Matrix2X3 CreateFromAxisAngle(Vector3D axis, T angle) /// The source Quaternion. /// The rotation matrix. public static Matrix2X3 CreateFromQuaternion(Quaternion quaternion) - where T : ITrigonometricFunctions + where T : INumber, IRootFunctions, ITrigonometricFunctions { Matrix2X3 result = Matrix2X3.Identity; @@ -128,7 +128,7 @@ public static Matrix2X3 CreateFromQuaternion(Quaternion quaternion) /// Angle of rotation, in radians, around the Z-axis. /// The rotation matrix. public static Matrix2X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) - where T : ITrigonometricFunctions + where T : INumber, IRootFunctions, ITrigonometricFunctions { var q = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(q); @@ -139,7 +139,7 @@ public static Matrix2X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) /// The rotation to apply. /// The transformed matrix. public static Matrix2X3 Transform(Matrix2X3 value, Quaternion rotation) - where T : ITrigonometricFunctions + where T : INumber, IRootFunctions, ITrigonometricFunctions { // Compute rotation matrix. T x2 = rotation.X + rotation.X; diff --git a/sources/Maths/Maths/Matrix3X2.Ops.cs b/sources/Maths/Maths/Matrix3X2.Ops.cs index 14d318437d..d4f919805c 100644 --- a/sources/Maths/Maths/Matrix3X2.Ops.cs +++ b/sources/Maths/Maths/Matrix3X2.Ops.cs @@ -22,7 +22,7 @@ public static partial class Matrix3X2 /// The amount of rotation, in radians. /// A rotation matrix. public static Matrix3X2 CreateRotation(T radians) - where T : INumberBase + where T : IFloatingPointIeee754 { radians = T.Ieee754Remainder(radians, T.Tau); @@ -113,7 +113,7 @@ public static Matrix3X2 CreateRotation(T radians) /// The center point. /// A rotation matrix. public static Matrix3X2 CreateRotation(T radians, Vector2D centerPoint) - where T : INumberBase + where T : IFloatingPointIeee754 { radians = T.Ieee754Remainder(radians, T.Tau); @@ -307,7 +307,7 @@ public static Matrix3X2 CreateScale(T scale, Vector2D centerPoint) /// The Y angle, in radians. /// A skew matrix. public static Matrix3X2 CreateSkew(T radiansX, T radiansY) - where T : INumberBase + where T : ITrigonometricFunctions { Matrix3X2 result = Matrix3X2.Identity; @@ -326,7 +326,7 @@ public static Matrix3X2 CreateSkew(T radiansX, T radiansY) /// The center point. /// A skew matrix. public static Matrix3X2 CreateSkew(T radiansX, T radiansY, Vector2D centerPoint) - where T : INumberBase + where T : ITrigonometricFunctions { Matrix3X2 result = Matrix3X2.Identity; diff --git a/sources/Maths/Maths/Matrix3X3.Ops.cs b/sources/Maths/Maths/Matrix3X3.Ops.cs index 740d43d1ba..a683892cce 100644 --- a/sources/Maths/Maths/Matrix3X3.Ops.cs +++ b/sources/Maths/Maths/Matrix3X3.Ops.cs @@ -42,7 +42,7 @@ private struct VectorBasis /// The forward vector of the camera. /// The created billboard matrix public static Matrix3X3 CreateBillboard(Vector3D objectPosition, Vector3D cameraPosition, Vector3D cameraUpVector, Vector3D cameraForwardVector) - where T : IRootFunctions + where T : INumber, IRootFunctions { Vector3D zaxis = objectPosition - cameraPosition; var norm = zaxis.LengthSquared; @@ -67,7 +67,7 @@ public static Matrix3X3 CreateBillboard(Vector3D objectPosition, Vector /// The angle to rotate around the given axis, in radians. /// The rotation matrix. public static Matrix3X3 CreateFromAxisAngle(Vector3D axis, T angle) - where T : INumberBase + where T : ITrigonometricFunctions { // a: angle // x, y, z: unit vector for axis. @@ -120,7 +120,7 @@ public static Matrix3X3 CreateFromAxisAngle(Vector3D axis, T angle) /// The source Quaternion. /// The rotation matrix. public static Matrix3X3 CreateFromQuaternion(Quaternion quaternion) - where T : ITrigonometricFunctions + where T : INumber, IRootFunctions, ITrigonometricFunctions { Matrix3X3 result = Matrix3X3.Identity; @@ -157,7 +157,7 @@ public static Matrix3X3 CreateFromQuaternion(Quaternion quaternion) /// Angle of rotation, in radians, around the Z-axis. /// The rotation matrix. public static Matrix3X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) - where T : ITrigonometricFunctions + where T : INumber, IRootFunctions, ITrigonometricFunctions { var q = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(q); @@ -167,7 +167,7 @@ public static Matrix3X3 CreateFromYawPitchRoll(T yaw, T pitch, T roll) /// The amount, in radians, by which to rotate around the X-axis. /// The rotation matrix. public static Matrix3X3 CreateRotationX(T radians) - where T : INumberBase + where T : ITrigonometricFunctions { Matrix3X3 result = Matrix3X3.Identity; @@ -191,7 +191,7 @@ public static Matrix3X3 CreateRotationX(T radians) /// The amount, in radians, by which to rotate around the Y-axis. /// The rotation matrix. public static Matrix3X3 CreateRotationY(T radians) - where T : INumberBase + where T : ITrigonometricFunctions { Matrix3X3 result = Matrix3X3.Identity; @@ -214,7 +214,7 @@ public static Matrix3X3 CreateRotationY(T radians) /// The amount, in radians, by which to rotate around the Z-axis. /// The rotation matrix. public static Matrix3X3 CreateRotationZ(T radians) - where T : INumberBase + where T : ITrigonometricFunctions { Matrix3X3 result = Matrix3X3.Identity; @@ -476,7 +476,7 @@ public static bool Decompose(Matrix3X3 matrix, out Vector3D scale, out /// The rotation to apply. /// The transformed matrix. public static Matrix3X3 Transform(Matrix3X3 value, Quaternion rotation) - where T : ITrigonometricFunctions + where T : INumber, IRootFunctions, ITrigonometricFunctions { // Compute rotation matrix. T x2 = rotation.X + rotation.X; diff --git a/sources/Maths/Maths/Matrix4X4.Ops.cs b/sources/Maths/Maths/Matrix4X4.Ops.cs index 7c68e38403..8ed0783162 100644 --- a/sources/Maths/Maths/Matrix4X4.Ops.cs +++ b/sources/Maths/Maths/Matrix4X4.Ops.cs @@ -47,7 +47,7 @@ private struct VectorBasis /// The forward vector of the camera. /// The created billboard matrix public static Matrix4X4 CreateBillboard(Vector3D objectPosition, Vector3D cameraPosition, Vector3D cameraUpVector, Vector3D cameraForwardVector) - where T : IRootFunctions + where T : INumber, IRootFunctions { Vector3D zaxis = objectPosition - cameraPosition; var norm = zaxis.LengthSquared; @@ -79,7 +79,7 @@ public static Matrix4X4 CreateBillboard(Vector3D objectPosition, Vector /// Forward vector of the object. /// The created billboard matrix. public static Matrix4X4 CreateConstrainedBillboard(Vector3D objectPosition, Vector3D cameraPosition, Vector3D rotateAxis, Vector3D cameraForwardVector, Vector3D objectForwardVector) - where T : IRootFunctions + where T : INumber, IRootFunctions { // Treat the case when object and camera positions are too close. Vector3D faceDir = objectPosition - cameraPosition; @@ -137,7 +137,7 @@ public static Matrix4X4 CreateConstrainedBillboard(Vector3D objectPosit /// The angle to rotate around the given axis, in radians. /// The rotation matrix. public static Matrix4X4 CreateFromAxisAngle(Vector3D axis, T angle) - where T : INumberBase + where T : ITrigonometricFunctions { // a: angle // x, y, z: unit vector for axis. @@ -190,7 +190,7 @@ public static Matrix4X4 CreateFromAxisAngle(Vector3D axis, T angle) /// The source Quaternion. /// The rotation matrix. public static Matrix4X4 CreateFromQuaternion(Quaternion quaternion) - where T : ITrigonometricFunctions + where T : INumber, IRootFunctions, ITrigonometricFunctions { Matrix4X4 result = Matrix4X4.Identity; @@ -227,7 +227,7 @@ public static Matrix4X4 CreateFromQuaternion(Quaternion quaternion) /// Angle of rotation, in radians, around the Z-axis. /// The rotation matrix. public static Matrix4X4 CreateFromYawPitchRoll(T yaw, T pitch, T roll) - where T : ITrigonometricFunctions + where T : INumber, IRootFunctions, ITrigonometricFunctions { var q = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(q); @@ -318,7 +318,7 @@ public static Matrix4X4 CreateOrthographicOffCenter(T left, T right, T bot /// Distance to the far view plane. /// The perspective projection matrix. public static Matrix4X4 CreatePerspective(T width, T height, T nearPlaneDistance, T farPlaneDistance) - where T : INumberBase + where T : INumber { if (!(nearPlaneDistance > T.Zero)) throw new ArgumentOutOfRangeException(nameof(nearPlaneDistance)); @@ -354,7 +354,7 @@ public static Matrix4X4 CreatePerspective(T width, T height, T nearPlaneDi /// Distance to the far view plane. /// The perspective projection matrix. public static Matrix4X4 CreatePerspectiveFieldOfView(T fieldOfView, T aspectRatio, T nearPlaneDistance, T farPlaneDistance) - where T : INumberBase + where T : INumber, ITrigonometricFunctions { if (!(fieldOfView > T.Zero) || (fieldOfView >= T.Pi)) throw new ArgumentOutOfRangeException(nameof(fieldOfView)); @@ -396,7 +396,7 @@ public static Matrix4X4 CreatePerspectiveFieldOfView(T fieldOfView, T aspe /// Distance to of the far view plane. /// The perspective projection matrix. public static Matrix4X4 CreatePerspectiveOffCenter(T left, T right, T bottom, T top, T nearPlaneDistance, T farPlaneDistance) - where T : INumberBase + where T : INumber { if (!(nearPlaneDistance > T.Zero)) throw new ArgumentOutOfRangeException(nameof(nearPlaneDistance)); @@ -428,7 +428,7 @@ public static Matrix4X4 CreatePerspectiveOffCenter(T left, T right, T bott /// The Plane about which to create a reflection. /// A new matrix expressing the reflection. public static Matrix4X4 CreateReflection(Plane value) - where T : INumberBase + where T : INumber, IRootFunctions { value = Plane.Normalize(value); @@ -465,7 +465,7 @@ public static Matrix4X4 CreateReflection(Plane value) /// The amount, in radians, by which to rotate around the X-axis. /// The rotation matrix. public static Matrix4X4 CreateRotationX(T radians) - where T : INumberBase + where T : ITrigonometricFunctions { Matrix4X4 result = Matrix4X4.Identity; @@ -490,7 +490,7 @@ public static Matrix4X4 CreateRotationX(T radians) /// The center point. /// The rotation matrix. public static Matrix4X4 CreateRotationX(T radians, Vector3D centerPoint) - where T : INumberBase + where T : ITrigonometricFunctions { Matrix4X4 result = Matrix4X4.Identity; @@ -519,7 +519,7 @@ public static Matrix4X4 CreateRotationX(T radians, Vector3D centerPoint /// The amount, in radians, by which to rotate around the Y-axis. /// The rotation matrix. public static Matrix4X4 CreateRotationY(T radians) - where T : INumberBase + where T : ITrigonometricFunctions { Matrix4X4 result = Matrix4X4.Identity; @@ -543,7 +543,7 @@ public static Matrix4X4 CreateRotationY(T radians) /// The center point. /// The rotation matrix. public static Matrix4X4 CreateRotationY(T radians, Vector3D centerPoint) - where T : INumberBase + where T : ITrigonometricFunctions { Matrix4X4 result = Matrix4X4.Identity; @@ -571,7 +571,7 @@ public static Matrix4X4 CreateRotationY(T radians, Vector3D centerPoint /// The amount, in radians, by which to rotate around the Z-axis. /// The rotation matrix. public static Matrix4X4 CreateRotationZ(T radians) - where T : INumberBase + where T : ITrigonometricFunctions { Matrix4X4 result = Matrix4X4.Identity; @@ -595,7 +595,7 @@ public static Matrix4X4 CreateRotationZ(T radians) /// The center point. /// The rotation matrix. public static Matrix4X4 CreateRotationZ(T radians, Vector3D centerPoint) - where T : INumberBase + where T : ITrigonometricFunctions { Matrix4X4 result = Matrix4X4.Identity; @@ -737,7 +737,7 @@ public static Matrix4X4 CreateScale(T scale, Vector3D centerPoint) /// The Plane onto which the new matrix should flatten geometry so as to cast a shadow. /// A new Matrix that can be used to flatten geometry onto the specified plane from the specified direction. public static Matrix4X4 CreateShadow(Vector3D lightDirection, Plane plane) - where T : INumberBase + where T : INumber, IRootFunctions { Plane p = Plane.Normalize(plane); @@ -837,7 +837,7 @@ public static Matrix4X4 CreateWorld(Vector3D position, Vector3D forw /// [MethodImpl((MethodImplOptions)768)] public static unsafe bool Invert(Matrix4X4 matrix, out Matrix4X4 result) - where T : INumberBase + where T : IFloatingPointIeee754 { // This implementation is based on the DirectX Math Library XMMatrixInverse method // https://github.com/microsoft/DirectXMath/blob/master/Inc/DirectXMathMatrix.inl @@ -1207,7 +1207,7 @@ private static Vector128 Permute(Vector128 value, byte control) /// The rotation component of the transformation matrix. /// The translation component of the transformation matrix /// True if the source matrix was successfully decomposed; False otherwise. - public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out Silk.NET.Maths.Legacy.Quaternion rotation, out Vector3D translation) + public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out Quaternion rotation, out Vector3D translation) where T : INumberBase { bool result = true; @@ -1405,7 +1405,7 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out /// The rotation to apply. /// The transformed matrix. public static Matrix4X4 Transform(Matrix4X4 value, Quaternion rotation) - where T : ITrigonometricFunctions + where T : INumber, IRootFunctions, ITrigonometricFunctions { // Compute rotation matrix. T x2 = rotation.X + rotation.X; diff --git a/sources/Maths/Maths/Plane.Ops.cs b/sources/Maths/Maths/Plane.Ops.cs index 3752151970..c843d6e05f 100644 --- a/sources/Maths/Maths/Plane.Ops.cs +++ b/sources/Maths/Maths/Plane.Ops.cs @@ -110,7 +110,7 @@ public static T DotNormal(Plane plane, Vector3D value) /// The normalized Plane. [MethodImpl((MethodImplOptions)768)] public static Plane Normalize(Plane value) - where T : INumberBase + where T : INumber, IRootFunctions { /*if (Vector.IsHardwareAccelerated) { @@ -151,7 +151,7 @@ public static Plane Normalize(Plane value) /// The transformed Plane. [MethodImpl((MethodImplOptions)768)] public static Plane Transform(Plane plane, Matrix4X4 matrix) - where T : INumberBase + where T : IFloatingPointIeee754 { Matrix4X4.Invert(matrix, out Matrix4X4 m); @@ -171,7 +171,7 @@ public static Plane Transform(Plane plane, Matrix4X4 matrix) /// A new Plane that results from applying the rotation. [MethodImpl((MethodImplOptions)768)] public static Plane Transform(Plane plane, Quaternion rotation) - where T : ITrigonometricFunctions + where T : INumber, IRootFunctions, ITrigonometricFunctions { // Compute rotation matrix. T x2 = rotation.X + rotation.X; diff --git a/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt index c532a03b17..fbb7eb876d 100644 --- a/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -60,6 +60,7 @@ override Silk.NET.Maths.Vector3D.ToString() -> string! override Silk.NET.Maths.Vector4D.Equals(object? obj) -> bool override Silk.NET.Maths.Vector4D.GetHashCode() -> int override Silk.NET.Maths.Vector4D.ToString() -> string! +Silk.NET.Maths.Box2D Silk.NET.Maths.Box2D Silk.NET.Maths.Box2D.As() -> Silk.NET.Maths.Box2D Silk.NET.Maths.Box2D.AsChecked() -> Silk.NET.Maths.Box2D @@ -74,7 +75,6 @@ Silk.NET.Maths.Box2D.Center.get -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Box2D.Contains(Silk.NET.Maths.Box2D other) -> bool Silk.NET.Maths.Box2D.Contains(Silk.NET.Maths.Vector2D point) -> bool Silk.NET.Maths.Box2D.Equals(Silk.NET.Maths.Box2D other) -> bool -Silk.NET.Maths.Box2D.GetDistanceToNearestEdge(Silk.NET.Maths.Vector2D point) -> T Silk.NET.Maths.Box2D.GetInflated(Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Box2D Silk.NET.Maths.Box2D.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Box2D Silk.NET.Maths.Box2D.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Box2D @@ -82,6 +82,7 @@ Silk.NET.Maths.Box2D.GetTranslated(Silk.NET.Maths.Vector2D distance) -> Si Silk.NET.Maths.Box2D.Max -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Box2D.Min -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Box2D.Size.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Box3D Silk.NET.Maths.Box3D Silk.NET.Maths.Box3D.As() -> Silk.NET.Maths.Box3D Silk.NET.Maths.Box3D.Box3D() -> void @@ -93,7 +94,6 @@ Silk.NET.Maths.Box3D.Center.get -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Box3D.Contains(Silk.NET.Maths.Box3D other) -> bool Silk.NET.Maths.Box3D.Contains(Silk.NET.Maths.Vector3D point) -> bool Silk.NET.Maths.Box3D.Equals(Silk.NET.Maths.Box3D other) -> bool -Silk.NET.Maths.Box3D.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D point) -> T Silk.NET.Maths.Box3D.GetInflated(Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Box3D Silk.NET.Maths.Box3D.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Box3D Silk.NET.Maths.Box3D.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Box3D @@ -101,6 +101,7 @@ Silk.NET.Maths.Box3D.GetTranslated(Silk.NET.Maths.Vector3D distance) -> Si Silk.NET.Maths.Box3D.Max -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Box3D.Min -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Box3D.Size.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Circle Silk.NET.Maths.Circle Silk.NET.Maths.Circle.As() -> Silk.NET.Maths.Circle Silk.NET.Maths.Circle.Center -> Silk.NET.Maths.Vector2D @@ -108,16 +109,14 @@ Silk.NET.Maths.Circle.Circle() -> void Silk.NET.Maths.Circle.Circle(Silk.NET.Maths.Vector2D center, T radius) -> void Silk.NET.Maths.Circle.Circle(T centerX, T centerY, T radius) -> void Silk.NET.Maths.Circle.Circumference.get -> T -Silk.NET.Maths.Circle.Contains(Silk.NET.Maths.Circle other) -> bool -Silk.NET.Maths.Circle.Contains(Silk.NET.Maths.Vector2D point) -> bool Silk.NET.Maths.Circle.Diameter.get -> T Silk.NET.Maths.Circle.Equals(Silk.NET.Maths.Circle other) -> bool Silk.NET.Maths.Circle.GetDistanceToNearestEdge(Silk.NET.Maths.Vector2D point) -> T Silk.NET.Maths.Circle.GetDistanceToNearestEdgeSquared(Silk.NET.Maths.Vector2D point) -> T -Silk.NET.Maths.Circle.GetInflated(Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Circle Silk.NET.Maths.Circle.GetTranslated(Silk.NET.Maths.Vector2D distance) -> Silk.NET.Maths.Circle Silk.NET.Maths.Circle.Radius -> T Silk.NET.Maths.Circle.SquaredRadius.get -> T +Silk.NET.Maths.Cube Silk.NET.Maths.Cube Silk.NET.Maths.Cube.As() -> Silk.NET.Maths.Cube Silk.NET.Maths.Cube.Center.get -> Silk.NET.Maths.Vector3D @@ -129,7 +128,6 @@ Silk.NET.Maths.Cube.Cube(Silk.NET.Maths.Vector3D origin, T sizeX, T sizeY, Silk.NET.Maths.Cube.Cube(T originX, T originY, T originZ, Silk.NET.Maths.Vector3D size) -> void Silk.NET.Maths.Cube.Cube(T originX, T originY, T originZ, T sizeX, T sizeY, T sizeZ) -> void Silk.NET.Maths.Cube.Equals(Silk.NET.Maths.Cube other) -> bool -Silk.NET.Maths.Cube.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D point) -> T Silk.NET.Maths.Cube.GetInflated(Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Cube Silk.NET.Maths.Cube.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Cube Silk.NET.Maths.Cube.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Cube @@ -553,7 +551,6 @@ Silk.NET.Maths.Rectangle.Center.get -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Rectangle.Contains(Silk.NET.Maths.Rectangle other) -> bool Silk.NET.Maths.Rectangle.Contains(Silk.NET.Maths.Vector2D point) -> bool Silk.NET.Maths.Rectangle.Equals(Silk.NET.Maths.Rectangle other) -> bool -Silk.NET.Maths.Rectangle.GetDistanceToNearestEdge(Silk.NET.Maths.Vector2D point) -> T Silk.NET.Maths.Rectangle.GetInflated(Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Rectangle Silk.NET.Maths.Rectangle.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Rectangle Silk.NET.Maths.Rectangle.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Rectangle @@ -567,16 +564,14 @@ Silk.NET.Maths.Rectangle.Rectangle(Silk.NET.Maths.Vector2D origin, T sizeX Silk.NET.Maths.Rectangle.Rectangle(T originX, T originY, Silk.NET.Maths.Vector2D size) -> void Silk.NET.Maths.Rectangle.Rectangle(T originX, T originY, T sizeX, T sizeY) -> void Silk.NET.Maths.Rectangle.Size -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Sphere Silk.NET.Maths.Sphere Silk.NET.Maths.Sphere.As() -> Silk.NET.Maths.Sphere Silk.NET.Maths.Sphere.Center -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Sphere.Contains(Silk.NET.Maths.Sphere other) -> bool -Silk.NET.Maths.Sphere.Contains(Silk.NET.Maths.Vector3D point) -> bool Silk.NET.Maths.Sphere.Diameter.get -> T Silk.NET.Maths.Sphere.Equals(Silk.NET.Maths.Sphere other) -> bool Silk.NET.Maths.Sphere.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D point) -> T Silk.NET.Maths.Sphere.GetDistanceToNearestEdgeSquared(Silk.NET.Maths.Vector3D point) -> T -Silk.NET.Maths.Sphere.GetInflated(Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Sphere Silk.NET.Maths.Sphere.GetTranslated(Silk.NET.Maths.Vector3D distance) -> Silk.NET.Maths.Sphere Silk.NET.Maths.Sphere.Radius -> T Silk.NET.Maths.Sphere.Sphere() -> void @@ -671,12 +666,18 @@ Silk.NET.Maths.Vector4D.W -> T Silk.NET.Maths.Vector4D.X -> T Silk.NET.Maths.Vector4D.Y -> T Silk.NET.Maths.Vector4D.Z -> T +static Silk.NET.Maths.Box2D.GetDistanceToNearestEdge(this Silk.NET.Maths.Box2D box, Silk.NET.Maths.Vector2D point) -> T static Silk.NET.Maths.Box2D.operator !=(Silk.NET.Maths.Box2D value1, Silk.NET.Maths.Box2D value2) -> bool static Silk.NET.Maths.Box2D.operator ==(Silk.NET.Maths.Box2D value1, Silk.NET.Maths.Box2D value2) -> bool +static Silk.NET.Maths.Box3D.GetDistanceToNearestEdge(this Silk.NET.Maths.Box3D box, Silk.NET.Maths.Vector3D point) -> T static Silk.NET.Maths.Box3D.operator !=(Silk.NET.Maths.Box3D value1, Silk.NET.Maths.Box3D value2) -> bool static Silk.NET.Maths.Box3D.operator ==(Silk.NET.Maths.Box3D value1, Silk.NET.Maths.Box3D value2) -> bool +static Silk.NET.Maths.Circle.Contains(this Silk.NET.Maths.Circle circle, Silk.NET.Maths.Circle other) -> bool +static Silk.NET.Maths.Circle.Contains(this Silk.NET.Maths.Circle circle, Silk.NET.Maths.Vector2D point) -> bool +static Silk.NET.Maths.Circle.GetInflated(this Silk.NET.Maths.Circle circle, Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Circle static Silk.NET.Maths.Circle.operator !=(Silk.NET.Maths.Circle value1, Silk.NET.Maths.Circle value2) -> bool static Silk.NET.Maths.Circle.operator ==(Silk.NET.Maths.Circle value1, Silk.NET.Maths.Circle value2) -> bool +static Silk.NET.Maths.Cube.GetDistanceToNearestEdge(Silk.NET.Maths.Cube cube, Silk.NET.Maths.Vector3D point) -> T static Silk.NET.Maths.Cube.operator !=(Silk.NET.Maths.Cube value1, Silk.NET.Maths.Cube value2) -> bool static Silk.NET.Maths.Cube.operator ==(Silk.NET.Maths.Cube value1, Silk.NET.Maths.Cube value2) -> bool static Silk.NET.Maths.Matrix2X2.Add(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 @@ -1327,8 +1328,12 @@ static Silk.NET.Maths.Ray2D.operator ==(Silk.NET.Maths.Ray2D value1, Silk. static Silk.NET.Maths.Ray3D.operator !=(Silk.NET.Maths.Ray3D value1, Silk.NET.Maths.Ray3D value2) -> bool static Silk.NET.Maths.Ray3D.operator ==(Silk.NET.Maths.Ray3D value1, Silk.NET.Maths.Ray3D value2) -> bool static Silk.NET.Maths.Rectangle.FromLTRB(T left, T top, T right, T bottom) -> Silk.NET.Maths.Rectangle +static Silk.NET.Maths.Rectangle.GetDistanceToNearestEdge(this Silk.NET.Maths.Rectangle rectangle, Silk.NET.Maths.Vector2D point) -> T static Silk.NET.Maths.Rectangle.operator !=(Silk.NET.Maths.Rectangle value1, Silk.NET.Maths.Rectangle value2) -> bool static Silk.NET.Maths.Rectangle.operator ==(Silk.NET.Maths.Rectangle value1, Silk.NET.Maths.Rectangle value2) -> bool +static Silk.NET.Maths.Sphere.Contains(this Silk.NET.Maths.Sphere sphere, Silk.NET.Maths.Sphere other) -> bool +static Silk.NET.Maths.Sphere.Contains(this Silk.NET.Maths.Sphere sphere, Silk.NET.Maths.Vector3D point) -> bool +static Silk.NET.Maths.Sphere.GetInflated(this Silk.NET.Maths.Sphere sphere, Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Sphere static Silk.NET.Maths.Sphere.operator !=(Silk.NET.Maths.Sphere value1, Silk.NET.Maths.Sphere value2) -> bool static Silk.NET.Maths.Sphere.operator ==(Silk.NET.Maths.Sphere value1, Silk.NET.Maths.Sphere value2) -> bool static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Matrix3x2 value) -> Silk.NET.Maths.Matrix3X2 diff --git a/sources/Maths/Maths/Quaternion.Old.cs b/sources/Maths/Maths/Quaternion.Old.cs index cb9b41d5b9..43f13d923e 100644 --- a/sources/Maths/Maths/Quaternion.Old.cs +++ b/sources/Maths/Maths/Quaternion.Old.cs @@ -629,7 +629,8 @@ public static explicit operator Quaternion(Quaternion from) /// /// The type to cast to /// The casted quaternion - public Quaternion As() where TOther : ITrigonometricFunctions + public Quaternion As() + where TOther : INumber, IRootFunctions, ITrigonometricFunctions { return new(TOther.CreateTruncating(X), TOther.CreateTruncating(Y), TOther.CreateTruncating(Z), TOther.CreateTruncating(W)); } diff --git a/sources/Maths/Maths/Quaternion.cs b/sources/Maths/Maths/Quaternion.cs index da901aad05..35e13124b8 100644 --- a/sources/Maths/Maths/Quaternion.cs +++ b/sources/Maths/Maths/Quaternion.cs @@ -16,7 +16,7 @@ namespace Silk.NET.Maths /// public partial struct Quaternion : IEquatable> - where T : ITrigonometricFunctions + where T : INumber, IRootFunctions, ITrigonometricFunctions { /// Specifies the X-value of the vector component of the Quaternion. [DataMember] diff --git a/sources/Maths/Maths/Rectangle.Ops.cs b/sources/Maths/Maths/Rectangle.Ops.cs index cb1175a1a8..29bdb3b64e 100644 --- a/sources/Maths/Maths/Rectangle.Ops.cs +++ b/sources/Maths/Maths/Rectangle.Ops.cs @@ -26,5 +26,20 @@ public static Rectangle FromLTRB(T left, T top, T right, T bottom) Vector2D o = new(left, top); return new Rectangle(o, new Vector2D(right, bottom) - o); } + + /// + /// Calculates the distance to the nearest edge from the point. + /// + /// The rectangle. + /// The point. + /// The distance. + public static T GetDistanceToNearestEdge(this Rectangle rectangle, Vector2D point) + where T : INumber, IRootFunctions + { + var max = rectangle.Max; + var dx = T.Max(T.Max(rectangle.Origin.X - point.X, T.Zero), point.X - max.X); + var dy = T.Max(T.Max(rectangle.Origin.Y - point.Y, T.Zero), point.Y - max.Y); + return T.Sqrt((dx * dx) + (dy * dy)); + } } } diff --git a/sources/Maths/Maths/Rectangle.cs b/sources/Maths/Maths/Rectangle.cs index ff84de0d20..2912e8a625 100644 --- a/sources/Maths/Maths/Rectangle.cs +++ b/sources/Maths/Maths/Rectangle.cs @@ -118,19 +118,6 @@ public bool Contains(Rectangle other) && (oMax.X <= tMax.X) && (oMax.Y <= tMax.Y); } - /// - /// Calculates the distance to the nearest edge from the point. - /// - /// The point. - /// The distance. - public T GetDistanceToNearestEdge(Vector2D point) - { - var max = Max; - var dx = T.Max(T.Max(Origin.X - point.X, T.Zero), point.X - max.X); - var dy = T.Max(T.Max(Origin.Y - point.Y, T.Zero), point.Y - max.Y); - return T.Sqrt((dx * dx) + (dy * dy)); - } - /// /// Calculates a new rectangle translated by a given distance. /// diff --git a/sources/Maths/Maths/Sphere.cs b/sources/Maths/Maths/Sphere.cs index 0432141092..d7f576e2e9 100644 --- a/sources/Maths/Maths/Sphere.cs +++ b/sources/Maths/Maths/Sphere.cs @@ -63,31 +63,6 @@ public Sphere(T centerX, T centerY, T centerZ, T radius) [IgnoreDataMember] public T SquaredRadius => Radius * Radius; - - /// - /// Calculates whether this sphere contains a point. - /// - /// The point. - /// True if this sphere contains the point; False otherwise. - /// This does consider a point on the edge contained. - public bool Contains(Vector3D point) - { - return Vector3D.DistanceSquared(point, Center) <= Radius; - } - - /// - /// Calculates whether this sphere contains another sphere - /// - /// The sphere. - /// True if this sphere contains the given sphere; False otherwise. - /// This does consider a sphere that touches the edge contained. - public bool Contains(Sphere other) - { - var distanceSquared = Vector3D.DistanceSquared(Center, other.Center); - var radiusDiff = Radius - other.Radius; - return distanceSquared <= radiusDiff * radiusDiff; - } - /// /// Calculates the squared distance to the nearest edge from the point. /// @@ -115,16 +90,6 @@ public Sphere GetTranslated(Vector3D distance) return new(Center + distance, Radius); } - /// - /// Calculates a sphere inflated to contain the given point. - /// - /// The point. - /// The sphere. - public Sphere GetInflated(Vector3D point) - { - return new(Center, T.Max(Radius, Vector3D.Distance(Center, point))); - } - /// Returns a boolean indicating whether the given Sphere is equal to this Sphere instance. /// The Sphere to compare this instance to. /// True if the other Sphere is equal to this instance; False otherwise. @@ -178,4 +143,50 @@ public Sphere As() return new(Center.As(), TOther.CreateTruncating(Radius)); } } + + /// + /// Helper methods to work with + /// + public static class Sphere + { + /// + /// Calculates whether this sphere contains a point. + /// + /// The sphere. + /// The point. + /// True if this sphere contains the point; False otherwise. + /// This does consider a point on the edge contained. + public static bool Contains(this Sphere sphere, Vector3D point) + where T : INumber, IRootFunctions + { + return Vector3D.DistanceSquared(point, sphere.Center) <= sphere.Radius; + } + + /// + /// Calculates whether this sphere contains another sphere + /// + /// The sphere. + /// The other sphere. + /// True if this sphere contains the given sphere; False otherwise. + /// This does consider a sphere that touches the edge contained. + public static bool Contains(this Sphere sphere, Sphere other) + where T : INumber, IRootFunctions + { + var distanceSquared = Vector3D.DistanceSquared(sphere.Center, other.Center); + var radiusDiff = sphere.Radius - other.Radius; + return distanceSquared <= radiusDiff * radiusDiff; + } + + /// + /// Calculates a sphere inflated to contain the given point. + /// + /// The sphere. + /// The point. + /// The sphere. + public static Sphere GetInflated(this Sphere sphere, Vector3D point) + where T : INumber, IRootFunctions + { + return new(sphere.Center, T.Max(sphere.Radius, Vector3D.Distance(sphere.Center, point))); + } + } } From 7099d0d21a824bc38270d08c5a365aef3ca88f53 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 19 Jul 2025 14:22:11 -0700 Subject: [PATCH 55/67] Moved comments and class attributes to the generated files. --- sources/Maths/Maths/Matrix2X2.cs | 9 --------- sources/Maths/Maths/Matrix2X2.gen.cs | 8 +++++++- sources/Maths/Maths/Matrix2X3.cs | 7 ------- sources/Maths/Maths/Matrix2X3.gen.cs | 8 +++++++- sources/Maths/Maths/Matrix2X4.cs | 7 ------- sources/Maths/Maths/Matrix2X4.gen.cs | 8 +++++++- sources/Maths/Maths/Matrix3X2.cs | 7 ------- sources/Maths/Maths/Matrix3X2.gen.cs | 8 +++++++- sources/Maths/Maths/Matrix3X3.cs | 9 --------- sources/Maths/Maths/Matrix3X3.gen.cs | 8 +++++++- sources/Maths/Maths/Matrix3X4.cs | 7 ------- sources/Maths/Maths/Matrix3X4.gen.cs | 8 +++++++- sources/Maths/Maths/Matrix4X2.cs | 8 -------- sources/Maths/Maths/Matrix4X2.gen.cs | 8 +++++++- sources/Maths/Maths/Matrix4X3.cs | 6 ------ sources/Maths/Maths/Matrix4X3.gen.cs | 8 +++++++- sources/Maths/Maths/Matrix4X4.cs | 9 --------- sources/Maths/Maths/Matrix4X4.gen.cs | 8 +++++++- sources/Maths/Maths/Matrix5X4.cs | 7 ------- sources/Maths/Maths/Matrix5X4.gen.cs | 8 +++++++- sources/Maths/Maths/Vector2D.cs | 1 - sources/Maths/Maths/Vector2D.gen.cs | 4 ++++ sources/Maths/Maths/Vector3D.cs | 1 - sources/Maths/Maths/Vector3D.gen.cs | 4 ++++ sources/Maths/Maths/Vector4D.cs | 1 - sources/Maths/Maths/Vector4D.gen.cs | 4 ++++ 26 files changed, 82 insertions(+), 89 deletions(-) diff --git a/sources/Maths/Maths/Matrix2X2.cs b/sources/Maths/Maths/Matrix2X2.cs index adfb53b5b2..68776d1594 100644 --- a/sources/Maths/Maths/Matrix2X2.cs +++ b/sources/Maths/Maths/Matrix2X2.cs @@ -1,17 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Globalization; -using System.Numerics; -using System.Runtime.CompilerServices; -using System.Runtime.Serialization; - namespace Silk.NET.Maths { - /// A structure encapsulating a 2x2 matrix. - [Serializable] - [DataContract] public partial struct Matrix2X2 { /// Constructs a from the given . diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index 36d8a000cb..48d0bb0a6d 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -1,10 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { + using System; using System.Diagnostics.CodeAnalysis; using System.Numerics; - using System.Runtime.CompilerServices; using System.Runtime.Serialization; + /// A structure encapsulating a 2x2 matrix. + [Serializable] + [DataContract] public partial struct Matrix2X2 : IEquatable> where T : INumberBase diff --git a/sources/Maths/Maths/Matrix2X3.cs b/sources/Maths/Maths/Matrix2X3.cs index 9ec69ba3bd..7a6d04767c 100644 --- a/sources/Maths/Maths/Matrix2X3.cs +++ b/sources/Maths/Maths/Matrix2X3.cs @@ -1,17 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Globalization; -using System.Numerics; -using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace Silk.NET.Maths { - /// A structure encapsulating a 2x3 matrix. - [Serializable] - [DataContract] public partial struct Matrix2X3 { private static readonly Matrix2X3 _identity = new diff --git a/sources/Maths/Maths/Matrix2X3.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs index bff4862b07..cd7231a85b 100644 --- a/sources/Maths/Maths/Matrix2X3.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -1,10 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { + using System; using System.Diagnostics.CodeAnalysis; using System.Numerics; - using System.Runtime.CompilerServices; using System.Runtime.Serialization; + /// A structure encapsulating a 2x3 matrix. + [Serializable] + [DataContract] public partial struct Matrix2X3 : IEquatable> where T : INumberBase diff --git a/sources/Maths/Maths/Matrix2X4.cs b/sources/Maths/Maths/Matrix2X4.cs index 447aa4fac4..6bb404325a 100644 --- a/sources/Maths/Maths/Matrix2X4.cs +++ b/sources/Maths/Maths/Matrix2X4.cs @@ -1,17 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Globalization; -using System.Numerics; -using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace Silk.NET.Maths { - /// A structure encapsulating a 2x4 matrix. - [Serializable] - [DataContract] public partial struct Matrix2X4 { private static readonly Matrix2X4 _identity = new diff --git a/sources/Maths/Maths/Matrix2X4.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs index 708458f69b..d436c7655b 100644 --- a/sources/Maths/Maths/Matrix2X4.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -1,10 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { + using System; using System.Diagnostics.CodeAnalysis; using System.Numerics; - using System.Runtime.CompilerServices; using System.Runtime.Serialization; + /// A structure encapsulating a 2x4 matrix. + [Serializable] + [DataContract] public partial struct Matrix2X4 : IEquatable> where T : INumberBase diff --git a/sources/Maths/Maths/Matrix3X2.cs b/sources/Maths/Maths/Matrix3X2.cs index 8fa03166d2..7565f3a6da 100644 --- a/sources/Maths/Maths/Matrix3X2.cs +++ b/sources/Maths/Maths/Matrix3X2.cs @@ -1,17 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Globalization; -using System.Numerics; -using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace Silk.NET.Maths { - /// A structure encapsulating a 3x2 matrix. - [Serializable] - [DataContract] public partial struct Matrix3X2 { private static readonly Matrix3X2 _identity = new( diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index 792f84ebaa..11acc4d122 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -1,10 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { + using System; using System.Diagnostics.CodeAnalysis; using System.Numerics; - using System.Runtime.CompilerServices; using System.Runtime.Serialization; + /// A structure encapsulating a 3x2 matrix. + [Serializable] + [DataContract] public partial struct Matrix3X2 : IEquatable> where T : INumberBase diff --git a/sources/Maths/Maths/Matrix3X3.cs b/sources/Maths/Maths/Matrix3X3.cs index 982de76974..30f4f53403 100644 --- a/sources/Maths/Maths/Matrix3X3.cs +++ b/sources/Maths/Maths/Matrix3X3.cs @@ -1,17 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Globalization; -using System.Numerics; -using System.Runtime.CompilerServices; -using System.Runtime.Serialization; - namespace Silk.NET.Maths { - /// A structure encapsulating a 3x3 matrix. - [Serializable] - [DataContract] public partial struct Matrix3X3 { /// Constructs a from the given . diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index 8bc8ec7c86..f984cbb2d4 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -1,10 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { + using System; using System.Diagnostics.CodeAnalysis; using System.Numerics; - using System.Runtime.CompilerServices; using System.Runtime.Serialization; + /// A structure encapsulating a 3x3 matrix. + [Serializable] + [DataContract] public partial struct Matrix3X3 : IEquatable> where T : INumberBase diff --git a/sources/Maths/Maths/Matrix3X4.cs b/sources/Maths/Maths/Matrix3X4.cs index 1143215c6a..9382287017 100644 --- a/sources/Maths/Maths/Matrix3X4.cs +++ b/sources/Maths/Maths/Matrix3X4.cs @@ -1,17 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Globalization; -using System.Numerics; -using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace Silk.NET.Maths { - /// A structure encapsulating a 3x4 matrix. - [Serializable] - [DataContract] public partial struct Matrix3X4 { private static readonly Matrix3X4 _identity = new diff --git a/sources/Maths/Maths/Matrix3X4.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs index 2df43ee04c..0350edffd4 100644 --- a/sources/Maths/Maths/Matrix3X4.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -1,10 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { + using System; using System.Diagnostics.CodeAnalysis; using System.Numerics; - using System.Runtime.CompilerServices; using System.Runtime.Serialization; + /// A structure encapsulating a 3x4 matrix. + [Serializable] + [DataContract] public partial struct Matrix3X4 : IEquatable> where T : INumberBase diff --git a/sources/Maths/Maths/Matrix4X2.cs b/sources/Maths/Maths/Matrix4X2.cs index d738f1ea91..8208c94bbe 100644 --- a/sources/Maths/Maths/Matrix4X2.cs +++ b/sources/Maths/Maths/Matrix4X2.cs @@ -1,18 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Diagnostics; -using System.Globalization; -using System.Numerics; -using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace Silk.NET.Maths { - /// A structure encapsulating a 4x2 matrix. - [Serializable] - [DataContract] public partial struct Matrix4X2 { private static readonly Matrix4X2 _identity = new diff --git a/sources/Maths/Maths/Matrix4X2.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs index 3b147c1b97..877fe108f2 100644 --- a/sources/Maths/Maths/Matrix4X2.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -1,10 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { + using System; using System.Diagnostics.CodeAnalysis; using System.Numerics; - using System.Runtime.CompilerServices; using System.Runtime.Serialization; + /// A structure encapsulating a 4x2 matrix. + [Serializable] + [DataContract] public partial struct Matrix4X2 : IEquatable> where T : INumberBase diff --git a/sources/Maths/Maths/Matrix4X3.cs b/sources/Maths/Maths/Matrix4X3.cs index b0c363a541..b86f4bbd79 100644 --- a/sources/Maths/Maths/Matrix4X3.cs +++ b/sources/Maths/Maths/Matrix4X3.cs @@ -1,17 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Globalization; using System.Numerics; -using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace Silk.NET.Maths { - /// A structure encapsulating a 4x3 matrix. - [Serializable] - [DataContract] public partial struct Matrix4X3 : IEquatable> where T : INumberBase diff --git a/sources/Maths/Maths/Matrix4X3.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs index 85ef245f27..9f282d733e 100644 --- a/sources/Maths/Maths/Matrix4X3.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -1,10 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { + using System; using System.Diagnostics.CodeAnalysis; using System.Numerics; - using System.Runtime.CompilerServices; using System.Runtime.Serialization; + /// A structure encapsulating a 4x3 matrix. + [Serializable] + [DataContract] public partial struct Matrix4X3 : IEquatable> where T : INumberBase diff --git a/sources/Maths/Maths/Matrix4X4.cs b/sources/Maths/Maths/Matrix4X4.cs index 4abee35430..6b8af672f3 100644 --- a/sources/Maths/Maths/Matrix4X4.cs +++ b/sources/Maths/Maths/Matrix4X4.cs @@ -1,17 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Globalization; -using System.Numerics; -using System.Runtime.CompilerServices; -using System.Runtime.Serialization; - namespace Silk.NET.Maths { - /// A structure encapsulating a 4x4 matrix. - [Serializable] - [DataContract] public partial struct Matrix4X4 { /// Constructs a from the given . diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index 0fcdce95cf..8745a7829c 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -1,10 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { + using System; using System.Diagnostics.CodeAnalysis; using System.Numerics; - using System.Runtime.CompilerServices; using System.Runtime.Serialization; + /// A structure encapsulating a 4x4 matrix. + [Serializable] + [DataContract] public partial struct Matrix4X4 : IEquatable> where T : INumberBase diff --git a/sources/Maths/Maths/Matrix5X4.cs b/sources/Maths/Maths/Matrix5X4.cs index 555c6582b7..0d007466eb 100644 --- a/sources/Maths/Maths/Matrix5X4.cs +++ b/sources/Maths/Maths/Matrix5X4.cs @@ -1,17 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Globalization; -using System.Numerics; -using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace Silk.NET.Maths { - /// A structure encapsulating a 4x4 matrix. - [Serializable] - [DataContract] public partial struct Matrix5X4 { private static readonly Matrix5X4 _identity = new diff --git a/sources/Maths/Maths/Matrix5X4.gen.cs b/sources/Maths/Maths/Matrix5X4.gen.cs index 6da344fa18..751bf52c8a 100644 --- a/sources/Maths/Maths/Matrix5X4.gen.cs +++ b/sources/Maths/Maths/Matrix5X4.gen.cs @@ -1,10 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { + using System; using System.Diagnostics.CodeAnalysis; using System.Numerics; - using System.Runtime.CompilerServices; using System.Runtime.Serialization; + /// A structure encapsulating a 5x4 matrix. + [Serializable] + [DataContract] public partial struct Matrix5X4 : IEquatable> where T : INumberBase diff --git a/sources/Maths/Maths/Vector2D.cs b/sources/Maths/Maths/Vector2D.cs index 5ade5f68db..5ddbc35e62 100644 --- a/sources/Maths/Maths/Vector2D.cs +++ b/sources/Maths/Maths/Vector2D.cs @@ -5,7 +5,6 @@ namespace Silk.NET.Maths { - /// A structure representing a 2D integer vector. public partial struct Vector2D { /// Explicitly casts a to a . diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index 79b4f1297d..1d59ccb608 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { using System.Collections; @@ -6,6 +9,7 @@ namespace Silk.NET.Maths using System.Runtime.InteropServices; using System.Text; + /// A structure encapsulating a 2D vector. public partial struct Vector2D : IEquatable>, IReadOnlyList, diff --git a/sources/Maths/Maths/Vector3D.cs b/sources/Maths/Maths/Vector3D.cs index 6e70b85bd8..3cc0606531 100644 --- a/sources/Maths/Maths/Vector3D.cs +++ b/sources/Maths/Maths/Vector3D.cs @@ -5,7 +5,6 @@ namespace Silk.NET.Maths { - /// A structure representing a 3D integer vector. public partial struct Vector3D { /// Explicitly casts a to a . diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index 769dd516b2..a8c510ea39 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { using System.Collections; @@ -6,6 +9,7 @@ namespace Silk.NET.Maths using System.Runtime.InteropServices; using System.Text; + /// A structure encapsulating a 3D vector. public partial struct Vector3D : IEquatable>, IReadOnlyList, diff --git a/sources/Maths/Maths/Vector4D.cs b/sources/Maths/Maths/Vector4D.cs index 8a11841c66..9aeff8dfa9 100644 --- a/sources/Maths/Maths/Vector4D.cs +++ b/sources/Maths/Maths/Vector4D.cs @@ -5,7 +5,6 @@ namespace Silk.NET.Maths { - /// A structure representing a 4D integer vector. public partial struct Vector4D { /// Explicitly casts a to a . diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index 6f7e2d978c..6e4ff23e19 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + namespace Silk.NET.Maths { using System.Collections; @@ -6,6 +9,7 @@ namespace Silk.NET.Maths using System.Runtime.InteropServices; using System.Text; + /// A structure encapsulating a 4D vector. public partial struct Vector4D : IEquatable>, IReadOnlyList, From a9ad742e7bf47c166b81b75966641f1923159377 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 19 Jul 2025 14:26:34 -0700 Subject: [PATCH 56/67] Comment tweaks. --- sources/Maths/Maths/Matrix2X2.gen.cs | 10 +++------- sources/Maths/Maths/Matrix2X3.gen.cs | 8 ++------ sources/Maths/Maths/Matrix2X4.gen.cs | 8 ++------ sources/Maths/Maths/Matrix3X2.gen.cs | 8 ++------ sources/Maths/Maths/Matrix3X3.gen.cs | 10 +++------- sources/Maths/Maths/Matrix3X4.gen.cs | 8 ++------ sources/Maths/Maths/Matrix4X2.gen.cs | 8 ++------ sources/Maths/Maths/Matrix4X3.gen.cs | 8 ++------ sources/Maths/Maths/Matrix4X4.gen.cs | 10 +++------- sources/Maths/Maths/Matrix5X4.gen.cs | 8 ++------ 10 files changed, 23 insertions(+), 63 deletions(-) diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index 48d0bb0a6d..144d9a66b2 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -15,7 +15,7 @@ public partial struct Matrix2X2 : IEquatable> where T : INumberBase { - /// The multiplicative identity matrix of size 2x2. + /// Gets the multiplicative identity matrix of size 2x2. public static Matrix2X2 Identity { get; } = new( new(T.MultiplicativeIdentity, T.Zero), new(T.Zero, T.MultiplicativeIdentity)); @@ -40,15 +40,11 @@ public partial struct Matrix2X2 : [IgnoreDataMember] public Vector2D Column2 => new(Row1.Y, Row2.Y); - /// - /// Constructs a from the given rows. - /// + /// Constructs a from the given rows. public Matrix2X2(Vector2D row1, Vector2D row2) => (Row1, Row2) = (row1, row2); - /// - /// Constructs a from the given components. - /// + /// Constructs a from the given components. public Matrix2X2( T m11, T m12, T m21, T m22) diff --git a/sources/Maths/Maths/Matrix2X3.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs index cd7231a85b..89ffba5d3c 100644 --- a/sources/Maths/Maths/Matrix2X3.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -35,15 +35,11 @@ public partial struct Matrix2X3 : [IgnoreDataMember] public Vector2D Column3 => new(Row1.Z, Row2.Z); - /// - /// Constructs a from the given rows. - /// + /// Constructs a from the given rows. public Matrix2X3(Vector3D row1, Vector3D row2) => (Row1, Row2) = (row1, row2); - /// - /// Constructs a from the given components. - /// + /// Constructs a from the given components. public Matrix2X3( T m11, T m12, T m13, T m21, T m22, T m23) diff --git a/sources/Maths/Maths/Matrix2X4.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs index d436c7655b..c56d5d3869 100644 --- a/sources/Maths/Maths/Matrix2X4.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -39,15 +39,11 @@ public partial struct Matrix2X4 : [IgnoreDataMember] public Vector2D Column4 => new(Row1.W, Row2.W); - /// - /// Constructs a from the given rows. - /// + /// Constructs a from the given rows. public Matrix2X4(Vector4D row1, Vector4D row2) => (Row1, Row2) = (row1, row2); - /// - /// Constructs a from the given components. - /// + /// Constructs a from the given components. public Matrix2X4( T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24) diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index 11acc4d122..146443f8e5 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -35,15 +35,11 @@ public partial struct Matrix3X2 : [IgnoreDataMember] public Vector3D Column2 => new(Row1.Y, Row2.Y, Row3.Y); - /// - /// Constructs a from the given rows. - /// + /// Constructs a from the given rows. public Matrix3X2(Vector2D row1, Vector2D row2, Vector2D row3) => (Row1, Row2, Row3) = (row1, row2, row3); - /// - /// Constructs a from the given components. - /// + /// Constructs a from the given components. public Matrix3X2( T m11, T m12, T m21, T m22, diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index f984cbb2d4..6b90b17ce6 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -15,7 +15,7 @@ public partial struct Matrix3X3 : IEquatable> where T : INumberBase { - /// The multiplicative identity matrix of size 3x3. + /// Gets the multiplicative identity matrix of size 3x3. public static Matrix3X3 Identity { get; } = new( new(T.MultiplicativeIdentity, T.Zero, T.Zero), new(T.Zero, T.MultiplicativeIdentity, T.Zero), @@ -49,15 +49,11 @@ public partial struct Matrix3X3 : [IgnoreDataMember] public Vector3D Column3 => new(Row1.Z, Row2.Z, Row3.Z); - /// - /// Constructs a from the given rows. - /// + /// Constructs a from the given rows. public Matrix3X3(Vector3D row1, Vector3D row2, Vector3D row3) => (Row1, Row2, Row3) = (row1, row2, row3); - /// - /// Constructs a from the given components. - /// + /// Constructs a from the given components. public Matrix3X3( T m11, T m12, T m13, T m21, T m22, T m23, diff --git a/sources/Maths/Maths/Matrix3X4.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs index 0350edffd4..4c774db732 100644 --- a/sources/Maths/Maths/Matrix3X4.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -43,15 +43,11 @@ public partial struct Matrix3X4 : [IgnoreDataMember] public Vector3D Column4 => new(Row1.W, Row2.W, Row3.W); - /// - /// Constructs a from the given rows. - /// + /// Constructs a from the given rows. public Matrix3X4(Vector4D row1, Vector4D row2, Vector4D row3) => (Row1, Row2, Row3) = (row1, row2, row3); - /// - /// Constructs a from the given components. - /// + /// Constructs a from the given components. public Matrix3X4( T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24, diff --git a/sources/Maths/Maths/Matrix4X2.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs index 877fe108f2..36a9be66fa 100644 --- a/sources/Maths/Maths/Matrix4X2.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -39,15 +39,11 @@ public partial struct Matrix4X2 : [IgnoreDataMember] public Vector4D Column2 => new(Row1.Y, Row2.Y, Row3.Y, Row4.Y); - /// - /// Constructs a from the given rows. - /// + /// Constructs a from the given rows. public Matrix4X2(Vector2D row1, Vector2D row2, Vector2D row3, Vector2D row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); - /// - /// Constructs a from the given components. - /// + /// Constructs a from the given components. public Matrix4X2( T m11, T m12, T m21, T m22, diff --git a/sources/Maths/Maths/Matrix4X3.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs index 9f282d733e..af8d280c3c 100644 --- a/sources/Maths/Maths/Matrix4X3.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -43,15 +43,11 @@ public partial struct Matrix4X3 : [IgnoreDataMember] public Vector4D Column3 => new(Row1.Z, Row2.Z, Row3.Z, Row4.Z); - /// - /// Constructs a from the given rows. - /// + /// Constructs a from the given rows. public Matrix4X3(Vector3D row1, Vector3D row2, Vector3D row3, Vector3D row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); - /// - /// Constructs a from the given components. - /// + /// Constructs a from the given components. public Matrix4X3( T m11, T m12, T m13, T m21, T m22, T m23, diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index 8745a7829c..132cba58a4 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -15,7 +15,7 @@ public partial struct Matrix4X4 : IEquatable> where T : INumberBase { - /// The multiplicative identity matrix of size 4x4. + /// Gets the multiplicative identity matrix of size 4x4. public static Matrix4X4 Identity { get; } = new( new(T.MultiplicativeIdentity, T.Zero, T.Zero, T.Zero), new(T.Zero, T.MultiplicativeIdentity, T.Zero, T.Zero), @@ -58,15 +58,11 @@ public partial struct Matrix4X4 : [IgnoreDataMember] public Vector4D Column4 => new(Row1.W, Row2.W, Row3.W, Row4.W); - /// - /// Constructs a from the given rows. - /// + /// Constructs a from the given rows. public Matrix4X4(Vector4D row1, Vector4D row2, Vector4D row3, Vector4D row4) => (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); - /// - /// Constructs a from the given components. - /// + /// Constructs a from the given components. public Matrix4X4( T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24, diff --git a/sources/Maths/Maths/Matrix5X4.gen.cs b/sources/Maths/Maths/Matrix5X4.gen.cs index 751bf52c8a..b4f1b7642a 100644 --- a/sources/Maths/Maths/Matrix5X4.gen.cs +++ b/sources/Maths/Maths/Matrix5X4.gen.cs @@ -35,15 +35,11 @@ public partial struct Matrix5X4 : [IgnoreDataMember] public Vector4D Row5; - /// - /// Constructs a from the given rows. - /// + /// Constructs a from the given rows. public Matrix5X4(Vector4D row1, Vector4D row2, Vector4D row3, Vector4D row4, Vector4D row5) => (Row1, Row2, Row3, Row4, Row5) = (row1, row2, row3, row4, row5); - /// - /// Constructs a from the given components. - /// + /// Constructs a from the given components. public Matrix5X4( T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24, From 55cfcf8f0a37a3f5752b328e4683c1fa1002a864 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 19 Jul 2025 14:32:47 -0700 Subject: [PATCH 57/67] Added vector overloads from the updated proposal. --- .../PublicAPI/net8.0/PublicAPI.Unshipped.txt | 18 ++++++++ sources/Maths/Maths/Vector2D.gen.cs | 44 +++++++++++++++++++ sources/Maths/Maths/Vector3D.gen.cs | 44 +++++++++++++++++++ sources/Maths/Maths/Vector4D.gen.cs | 44 +++++++++++++++++++ 4 files changed, 150 insertions(+) diff --git a/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt index fbb7eb876d..db5673f7b7 100644 --- a/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -1388,8 +1388,11 @@ static Silk.NET.Maths.Vector2D.Exp(this Silk.NET.Maths.Vector2D x) static Silk.NET.Maths.Vector2D.ExpM1(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Floor(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.FusedMultiplyAdd(this Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right, Silk.NET.Maths.Vector2D addend) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.FusedMultiplyAdd(this Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right, TSelf addend) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.FusedMultiplyAdd(this Silk.NET.Maths.Vector2D left, TSelf right, Silk.NET.Maths.Vector2D addend) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.FusedMultiplyAdd(this Silk.NET.Maths.Vector2D left, TSelf right, TSelf addend) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Hypot(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Hypot(this Silk.NET.Maths.Vector2D x, TSelf y) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Ieee754Remainder(this Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Ieee754Remainder(this Silk.NET.Maths.Vector2D left, TSelf right) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.ILogB(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D @@ -1401,6 +1404,7 @@ static Silk.NET.Maths.Vector2D.Log10P1(this Silk.NET.Maths.Vector2D(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Log2P1(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Log(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D newBase) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Log(this Silk.NET.Maths.Vector2D x, TSelf newBase) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.LogP1(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Max(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D @@ -1428,7 +1432,9 @@ static Silk.NET.Maths.Vector2D.Reflect(Silk.NET.Maths.Vector2D vector, Sil static Silk.NET.Maths.Vector2D.RootN(this Silk.NET.Maths.Vector2D x, int n) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.RootN(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D n) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Round(this Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Round(this Silk.NET.Maths.Vector2D x, int digits) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Round(this Silk.NET.Maths.Vector2D x, int digits, System.MidpointRounding mode) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Round(this Silk.NET.Maths.Vector2D x, System.MidpointRounding mode) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.ScaleB(this Silk.NET.Maths.Vector2D x, int n) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.ScaleB(this Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D n) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Sign(this Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D @@ -1535,8 +1541,11 @@ static Silk.NET.Maths.Vector3D.Exp(this Silk.NET.Maths.Vector3D x) static Silk.NET.Maths.Vector3D.ExpM1(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Floor(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.FusedMultiplyAdd(this Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right, Silk.NET.Maths.Vector3D addend) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.FusedMultiplyAdd(this Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right, TSelf addend) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.FusedMultiplyAdd(this Silk.NET.Maths.Vector3D left, TSelf right, Silk.NET.Maths.Vector3D addend) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.FusedMultiplyAdd(this Silk.NET.Maths.Vector3D left, TSelf right, TSelf addend) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Hypot(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Hypot(this Silk.NET.Maths.Vector3D x, TSelf y) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Ieee754Remainder(this Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Ieee754Remainder(this Silk.NET.Maths.Vector3D left, TSelf right) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.ILogB(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D @@ -1548,6 +1557,7 @@ static Silk.NET.Maths.Vector3D.Log10P1(this Silk.NET.Maths.Vector3D(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Log2P1(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Log(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D newBase) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Log(this Silk.NET.Maths.Vector3D x, TSelf newBase) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.LogP1(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Max(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D @@ -1575,7 +1585,9 @@ static Silk.NET.Maths.Vector3D.Reflect(Silk.NET.Maths.Vector3D vector, Sil static Silk.NET.Maths.Vector3D.RootN(this Silk.NET.Maths.Vector3D x, int n) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.RootN(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D n) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Round(this Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Round(this Silk.NET.Maths.Vector3D x, int digits) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Round(this Silk.NET.Maths.Vector3D x, int digits, System.MidpointRounding mode) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Round(this Silk.NET.Maths.Vector3D x, System.MidpointRounding mode) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.ScaleB(this Silk.NET.Maths.Vector3D x, int n) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.ScaleB(this Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D n) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Sign(this Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D @@ -1682,8 +1694,11 @@ static Silk.NET.Maths.Vector4D.Exp(this Silk.NET.Maths.Vector4D x) static Silk.NET.Maths.Vector4D.ExpM1(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Floor(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.FusedMultiplyAdd(this Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right, Silk.NET.Maths.Vector4D addend) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.FusedMultiplyAdd(this Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right, TSelf addend) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.FusedMultiplyAdd(this Silk.NET.Maths.Vector4D left, TSelf right, Silk.NET.Maths.Vector4D addend) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.FusedMultiplyAdd(this Silk.NET.Maths.Vector4D left, TSelf right, TSelf addend) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Hypot(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Hypot(this Silk.NET.Maths.Vector4D x, TSelf y) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Ieee754Remainder(this Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Ieee754Remainder(this Silk.NET.Maths.Vector4D left, TSelf right) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.ILogB(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D @@ -1695,6 +1710,7 @@ static Silk.NET.Maths.Vector4D.Log10P1(this Silk.NET.Maths.Vector4D(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Log2P1(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Log(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D newBase) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Log(this Silk.NET.Maths.Vector4D x, TSelf newBase) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.LogP1(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Max(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D @@ -1722,7 +1738,9 @@ static Silk.NET.Maths.Vector4D.Reflect(Silk.NET.Maths.Vector4D vector, Sil static Silk.NET.Maths.Vector4D.RootN(this Silk.NET.Maths.Vector4D x, int n) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.RootN(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D n) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Round(this Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Round(this Silk.NET.Maths.Vector4D x, int digits) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Round(this Silk.NET.Maths.Vector4D x, int digits, System.MidpointRounding mode) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Round(this Silk.NET.Maths.Vector4D x, System.MidpointRounding mode) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.ScaleB(this Silk.NET.Maths.Vector4D x, int n) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.ScaleB(this Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D n) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Sign(this Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index 1d59ccb608..e318a50904 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -894,6 +894,20 @@ public static Vector2D Round(this Vector2D x) where TSelf : IFloatingPoint => new(TSelf.Round(x.X), TSelf.Round(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D Round(this Vector2D x, int digits) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, digits), TSelf.Round(x.Y, digits)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D Round(this Vector2D x, MidpointRounding mode) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, mode), TSelf.Round(x.Y, mode)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . @@ -950,6 +964,22 @@ public static Vector2D FusedMultiplyAdd(this Vector2D left, where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D FusedMultiplyAdd(this Vector2D left, Vector2D right, TSelf addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right.X, addend), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A vector whose members will be provided for . + public static Vector2D FusedMultiplyAdd(this Vector2D left, TSelf right, Vector2D addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right, addend.X), TSelf.FusedMultiplyAdd(left.Y, right, addend.Y)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . @@ -1051,12 +1081,26 @@ public static Vector2D Hypot(this Vector2D x, Vector2D => new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D Hypot(this Vector2D x, TSelf y) + where TSelf : IRootFunctions => + new(TSelf.Hypot(x.X, y), TSelf.Hypot(x.Y, y)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . public static Vector2D Log(this Vector2D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D Log(this Vector2D x, Vector2D newBase) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index a8c510ea39..6fd81a1aa8 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -935,6 +935,20 @@ public static Vector3D Round(this Vector3D x) where TSelf : IFloatingPoint => new(TSelf.Round(x.X), TSelf.Round(x.Y), TSelf.Round(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D Round(this Vector3D x, int digits) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, digits), TSelf.Round(x.Y, digits), TSelf.Round(x.Z, digits)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D Round(this Vector3D x, MidpointRounding mode) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, mode), TSelf.Round(x.Y, mode), TSelf.Round(x.Z, mode)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . @@ -991,6 +1005,22 @@ public static Vector3D FusedMultiplyAdd(this Vector3D left, where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D FusedMultiplyAdd(this Vector3D left, Vector3D right, TSelf addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right.X, addend), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A vector whose members will be provided for . + public static Vector3D FusedMultiplyAdd(this Vector3D left, TSelf right, Vector3D addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right, addend.X), TSelf.FusedMultiplyAdd(left.Y, right, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right, addend.Z)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . @@ -1092,12 +1122,26 @@ public static Vector3D Hypot(this Vector3D x, Vector3D => new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y), TSelf.Hypot(x.Z, y.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D Hypot(this Vector3D x, TSelf y) + where TSelf : IRootFunctions => + new(TSelf.Hypot(x.X, y), TSelf.Hypot(x.Y, y), TSelf.Hypot(x.Z, y)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . public static Vector3D Log(this Vector3D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D Log(this Vector3D x, Vector3D newBase) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index 6e4ff23e19..0b24eadbd0 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -976,6 +976,20 @@ public static Vector4D Round(this Vector4D x) where TSelf : IFloatingPoint => new(TSelf.Round(x.X), TSelf.Round(x.Y), TSelf.Round(x.Z), TSelf.Round(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D Round(this Vector4D x, int digits) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, digits), TSelf.Round(x.Y, digits), TSelf.Round(x.Z, digits), TSelf.Round(x.W, digits)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D Round(this Vector4D x, MidpointRounding mode) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, mode), TSelf.Round(x.Y, mode), TSelf.Round(x.Z, mode), TSelf.Round(x.W, mode)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . @@ -1032,6 +1046,22 @@ public static Vector4D FusedMultiplyAdd(this Vector4D left, where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend.Z), TSelf.FusedMultiplyAdd(left.W, right.W, addend.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D FusedMultiplyAdd(this Vector4D left, Vector4D right, TSelf addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right.X, addend), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend), TSelf.FusedMultiplyAdd(left.W, right.W, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A vector whose members will be provided for . + public static Vector4D FusedMultiplyAdd(this Vector4D left, TSelf right, Vector4D addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right, addend.X), TSelf.FusedMultiplyAdd(left.Y, right, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right, addend.Z), TSelf.FusedMultiplyAdd(left.W, right, addend.W)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . @@ -1133,12 +1163,26 @@ public static Vector4D Hypot(this Vector4D x, Vector4D => new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y), TSelf.Hypot(x.Z, y.Z), TSelf.Hypot(x.W, y.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D Hypot(this Vector4D x, TSelf y) + where TSelf : IRootFunctions => + new(TSelf.Hypot(x.X, y), TSelf.Hypot(x.Y, y), TSelf.Hypot(x.Z, y), TSelf.Hypot(x.W, y)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . public static Vector4D Log(this Vector4D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z), TSelf.Log(x.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D Log(this Vector4D x, Vector4D newBase) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z), TSelf.Log(x.W, newBase.W)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . From 7770dedc8ce9ae14d24dce52d2efdd4aa08c13fb Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 19 Jul 2025 16:50:10 -0700 Subject: [PATCH 58/67] Move non-generic Matrix and Vector classes into separate files. --- sources/Maths/Maths/Matrix2X2.Ops.gen.cs | 118 ++++ sources/Maths/Maths/Matrix2X2.gen.cs | 111 ---- sources/Maths/Maths/Matrix2X3.Ops.gen.cs | 126 ++++ sources/Maths/Maths/Matrix2X3.gen.cs | 119 ---- sources/Maths/Maths/Matrix2X4.Ops.gen.cs | 126 ++++ sources/Maths/Maths/Matrix2X4.gen.cs | 119 ---- sources/Maths/Maths/Matrix3X2.Ops.gen.cs | 127 +++++ sources/Maths/Maths/Matrix3X2.gen.cs | 120 ---- sources/Maths/Maths/Matrix3X3.Ops.gen.cs | 119 ++++ sources/Maths/Maths/Matrix3X3.gen.cs | 112 ---- sources/Maths/Maths/Matrix3X4.Ops.gen.cs | 127 +++++ sources/Maths/Maths/Matrix3X4.gen.cs | 120 ---- sources/Maths/Maths/Matrix4X2.Ops.gen.cs | 128 +++++ sources/Maths/Maths/Matrix4X2.gen.cs | 121 ---- sources/Maths/Maths/Matrix4X3.Ops.gen.cs | 128 +++++ sources/Maths/Maths/Matrix4X3.gen.cs | 121 ---- sources/Maths/Maths/Matrix4X4.Ops.gen.cs | 128 +++++ sources/Maths/Maths/Matrix4X4.gen.cs | 121 ---- sources/Maths/Maths/Matrix5X4.Ops.gen.cs | 73 +++ sources/Maths/Maths/Matrix5X4.gen.cs | 66 --- sources/Maths/Maths/Vector2D.Ops.gen.cs | 686 ++++++++++++++++++++++ sources/Maths/Maths/Vector2D.gen.cs | 679 ---------------------- sources/Maths/Maths/Vector3D.Ops.gen.cs | 690 ++++++++++++++++++++++ sources/Maths/Maths/Vector3D.gen.cs | 683 ---------------------- sources/Maths/Maths/Vector4D.Ops.gen.cs | 694 +++++++++++++++++++++++ sources/Maths/Maths/Vector4D.gen.cs | 687 ---------------------- 26 files changed, 3270 insertions(+), 3179 deletions(-) create mode 100644 sources/Maths/Maths/Matrix2X2.Ops.gen.cs create mode 100644 sources/Maths/Maths/Matrix2X3.Ops.gen.cs create mode 100644 sources/Maths/Maths/Matrix2X4.Ops.gen.cs create mode 100644 sources/Maths/Maths/Matrix3X2.Ops.gen.cs create mode 100644 sources/Maths/Maths/Matrix3X3.Ops.gen.cs create mode 100644 sources/Maths/Maths/Matrix3X4.Ops.gen.cs create mode 100644 sources/Maths/Maths/Matrix4X2.Ops.gen.cs create mode 100644 sources/Maths/Maths/Matrix4X3.Ops.gen.cs create mode 100644 sources/Maths/Maths/Matrix4X4.Ops.gen.cs create mode 100644 sources/Maths/Maths/Matrix5X4.Ops.gen.cs create mode 100644 sources/Maths/Maths/Vector2D.Ops.gen.cs create mode 100644 sources/Maths/Maths/Vector3D.Ops.gen.cs create mode 100644 sources/Maths/Maths/Vector4D.Ops.gen.cs diff --git a/sources/Maths/Maths/Matrix2X2.Ops.gen.cs b/sources/Maths/Maths/Matrix2X2.Ops.gen.cs new file mode 100644 index 0000000000..838f36a311 --- /dev/null +++ b/sources/Maths/Maths/Matrix2X2.Ops.gen.cs @@ -0,0 +1,118 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Matrix2X2 + { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. + public static Matrix2X2 Lerp(Matrix2X2 value1, Matrix2X2 value2, T amount) + where T : IFloatingPointIeee754 => + new(Vector2D.Lerp(value1.Row1, value2.Row1, amount), + Vector2D.Lerp(value1.Row2, value2.Row2, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix2X2 Add(Matrix2X2 left, Matrix2X2 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix2X2 Negate(Matrix2X2 value) + where T : INumberBase => + -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix2X2 Subtract(Matrix2X2 left, Matrix2X2 right) + where T : INumberBase => + left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix2X2 Multiply(Matrix2X2 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix2X2 Multiply(T left, Matrix2X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector2D Multiply(Vector2D rowVector, Matrix2X2 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector2D Multiply(Matrix2X2 matrix, Vector2D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X2 Multiply(Matrix2X2 left, Matrix2X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X3 Multiply(Matrix2X2 left, Matrix2X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 Multiply(Matrix2X2 left, Matrix2X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X2 Multiply(Matrix3X2 left, Matrix2X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 Multiply(Matrix4X2 left, Matrix2X2 right) + where T : INumberBase => + left * right; + } +} diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index 144d9a66b2..fb71b14e14 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -451,115 +451,4 @@ public static explicit operator checked Matrix2X2(Matrix2X2 from) => new(Vector2D.CreateChecked(from.Row1), Vector2D.CreateChecked(from.Row2)); } - - /// - /// Methods for working with . - /// - public static partial class Matrix2X2 - { - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static Matrix2X2 Lerp(Matrix2X2 value1, Matrix2X2 value2, T amount) - where T : IFloatingPointIeee754 => - new(Vector2D.Lerp(value1.Row1, value2.Row1, amount), - Vector2D.Lerp(value1.Row2, value2.Row2, amount)); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix2X2 Add(Matrix2X2 left, Matrix2X2 right) - where T : INumberBase => - left + right; - - /// Returns a negated copy of the specified matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix2X2 Negate(Matrix2X2 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix2X2 Subtract(Matrix2X2 left, Matrix2X2 right) - where T : INumberBase - => left - right; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static Matrix2X2 Multiply(Matrix2X2 left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by a scalar value. - /// The scaling factor. - /// The source matrix. - /// The scaled matrix. - public static Matrix2X2 Multiply(T left, Matrix2X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix, expressed as a row vector. - /// The second source matrix. - /// The result of the multiplication as a column vector. - public static Vector2D Multiply(Vector2D rowVector, Matrix2X2 matrix) - where T : INumberBase => - rowVector * matrix; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix, expressed as a column vector. - /// The result of the multiplication as a row vector. - public static Vector2D Multiply(Matrix2X2 matrix, Vector2D columnVector) - where T : INumberBase => - matrix * columnVector; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X2 Multiply(Matrix2X2 left, Matrix2X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X3 Multiply(Matrix2X2 left, Matrix2X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X4 Multiply(Matrix2X2 left, Matrix2X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X2 Multiply(Matrix3X2 left, Matrix2X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X2 Multiply(Matrix4X2 left, Matrix2X2 right) - where T : INumberBase => - left * right; - } } diff --git a/sources/Maths/Maths/Matrix2X3.Ops.gen.cs b/sources/Maths/Maths/Matrix2X3.Ops.gen.cs new file mode 100644 index 0000000000..b889b49719 --- /dev/null +++ b/sources/Maths/Maths/Matrix2X3.Ops.gen.cs @@ -0,0 +1,126 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Matrix2X3 + { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. + public static Matrix2X3 Lerp(Matrix2X3 value1, Matrix2X3 value2, T amount) + where T : IFloatingPointIeee754 => + new(Vector3D.Lerp(value1.Row1, value2.Row1, amount), + Vector3D.Lerp(value1.Row2, value2.Row2, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix2X3 Add(Matrix2X3 left, Matrix2X3 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix2X3 Negate(Matrix2X3 value) + where T : INumberBase => + -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix2X3 Subtract(Matrix2X3 left, Matrix2X3 right) + where T : INumberBase => + left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix2X3 Multiply(Matrix2X3 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix2X3 Multiply(T left, Matrix2X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector3D Multiply(Vector2D rowVector, Matrix2X3 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector2D Multiply(Matrix2X3 matrix, Vector3D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X3 Multiply(Matrix2X2 left, Matrix2X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X2 Multiply(Matrix2X3 left, Matrix3X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X3 Multiply(Matrix2X3 left, Matrix3X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 Multiply(Matrix2X3 left, Matrix3X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X3 Multiply(Matrix3X2 left, Matrix2X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 Multiply(Matrix4X2 left, Matrix2X3 right) + where T : INumberBase => + left * right; + } +} diff --git a/sources/Maths/Maths/Matrix2X3.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs index 89ffba5d3c..b5f76d74b6 100644 --- a/sources/Maths/Maths/Matrix2X3.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -465,123 +465,4 @@ public static explicit operator checked Matrix2X3(Matrix2X3 from) => new(Vector3D.CreateChecked(from.Row1), Vector3D.CreateChecked(from.Row2)); } - - /// - /// Methods for working with . - /// - public static partial class Matrix2X3 - { - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static Matrix2X3 Lerp(Matrix2X3 value1, Matrix2X3 value2, T amount) - where T : IFloatingPointIeee754 => - new(Vector3D.Lerp(value1.Row1, value2.Row1, amount), - Vector3D.Lerp(value1.Row2, value2.Row2, amount)); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix2X3 Add(Matrix2X3 left, Matrix2X3 right) - where T : INumberBase => - left + right; - - /// Returns a negated copy of the specified matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix2X3 Negate(Matrix2X3 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix2X3 Subtract(Matrix2X3 left, Matrix2X3 right) - where T : INumberBase - => left - right; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static Matrix2X3 Multiply(Matrix2X3 left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by a scalar value. - /// The scaling factor. - /// The source matrix. - /// The scaled matrix. - public static Matrix2X3 Multiply(T left, Matrix2X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix, expressed as a row vector. - /// The second source matrix. - /// The result of the multiplication as a column vector. - public static Vector3D Multiply(Vector2D rowVector, Matrix2X3 matrix) - where T : INumberBase => - rowVector * matrix; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix, expressed as a column vector. - /// The result of the multiplication as a row vector. - public static Vector2D Multiply(Matrix2X3 matrix, Vector3D columnVector) - where T : INumberBase => - matrix * columnVector; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X3 Multiply(Matrix2X2 left, Matrix2X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X2 Multiply(Matrix2X3 left, Matrix3X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X3 Multiply(Matrix2X3 left, Matrix3X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X4 Multiply(Matrix2X3 left, Matrix3X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X3 Multiply(Matrix3X2 left, Matrix2X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X3 Multiply(Matrix4X2 left, Matrix2X3 right) - where T : INumberBase => - left * right; - } } diff --git a/sources/Maths/Maths/Matrix2X4.Ops.gen.cs b/sources/Maths/Maths/Matrix2X4.Ops.gen.cs new file mode 100644 index 0000000000..11fb2e377b --- /dev/null +++ b/sources/Maths/Maths/Matrix2X4.Ops.gen.cs @@ -0,0 +1,126 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Matrix2X4 + { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. + public static Matrix2X4 Lerp(Matrix2X4 value1, Matrix2X4 value2, T amount) + where T : IFloatingPointIeee754 => + new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), + Vector4D.Lerp(value1.Row2, value2.Row2, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix2X4 Add(Matrix2X4 left, Matrix2X4 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix2X4 Negate(Matrix2X4 value) + where T : INumberBase => + -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix2X4 Subtract(Matrix2X4 left, Matrix2X4 right) + where T : INumberBase => + left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix2X4 Multiply(Matrix2X4 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix2X4 Multiply(T left, Matrix2X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector4D Multiply(Vector2D rowVector, Matrix2X4 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector2D Multiply(Matrix2X4 matrix, Vector4D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 Multiply(Matrix2X2 left, Matrix2X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X2 Multiply(Matrix2X4 left, Matrix4X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X3 Multiply(Matrix2X4 left, Matrix4X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 Multiply(Matrix2X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 Multiply(Matrix3X2 left, Matrix2X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X4 Multiply(Matrix4X2 left, Matrix2X4 right) + where T : INumberBase => + left * right; + } +} diff --git a/sources/Maths/Maths/Matrix2X4.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs index c56d5d3869..b352063580 100644 --- a/sources/Maths/Maths/Matrix2X4.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -489,123 +489,4 @@ public static explicit operator checked Matrix2X4(Matrix2X4 from) => new(Vector4D.CreateChecked(from.Row1), Vector4D.CreateChecked(from.Row2)); } - - /// - /// Methods for working with . - /// - public static partial class Matrix2X4 - { - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static Matrix2X4 Lerp(Matrix2X4 value1, Matrix2X4 value2, T amount) - where T : IFloatingPointIeee754 => - new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), - Vector4D.Lerp(value1.Row2, value2.Row2, amount)); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix2X4 Add(Matrix2X4 left, Matrix2X4 right) - where T : INumberBase => - left + right; - - /// Returns a negated copy of the specified matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix2X4 Negate(Matrix2X4 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix2X4 Subtract(Matrix2X4 left, Matrix2X4 right) - where T : INumberBase - => left - right; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static Matrix2X4 Multiply(Matrix2X4 left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by a scalar value. - /// The scaling factor. - /// The source matrix. - /// The scaled matrix. - public static Matrix2X4 Multiply(T left, Matrix2X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix, expressed as a row vector. - /// The second source matrix. - /// The result of the multiplication as a column vector. - public static Vector4D Multiply(Vector2D rowVector, Matrix2X4 matrix) - where T : INumberBase => - rowVector * matrix; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix, expressed as a column vector. - /// The result of the multiplication as a row vector. - public static Vector2D Multiply(Matrix2X4 matrix, Vector4D columnVector) - where T : INumberBase => - matrix * columnVector; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X4 Multiply(Matrix2X2 left, Matrix2X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X2 Multiply(Matrix2X4 left, Matrix4X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X3 Multiply(Matrix2X4 left, Matrix4X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X4 Multiply(Matrix2X4 left, Matrix4X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X4 Multiply(Matrix3X2 left, Matrix2X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X4 Multiply(Matrix4X2 left, Matrix2X4 right) - where T : INumberBase => - left * right; - } } diff --git a/sources/Maths/Maths/Matrix3X2.Ops.gen.cs b/sources/Maths/Maths/Matrix3X2.Ops.gen.cs new file mode 100644 index 0000000000..f8aa0e2e8e --- /dev/null +++ b/sources/Maths/Maths/Matrix3X2.Ops.gen.cs @@ -0,0 +1,127 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Matrix3X2 + { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. + public static Matrix3X2 Lerp(Matrix3X2 value1, Matrix3X2 value2, T amount) + where T : IFloatingPointIeee754 => + new(Vector2D.Lerp(value1.Row1, value2.Row1, amount), + Vector2D.Lerp(value1.Row2, value2.Row2, amount), + Vector2D.Lerp(value1.Row3, value2.Row3, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix3X2 Add(Matrix3X2 left, Matrix3X2 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix3X2 Negate(Matrix3X2 value) + where T : INumberBase => + -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix3X2 Subtract(Matrix3X2 left, Matrix3X2 right) + where T : INumberBase => + left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix3X2 Multiply(Matrix3X2 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix3X2 Multiply(T left, Matrix3X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector2D Multiply(Vector3D rowVector, Matrix3X2 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector3D Multiply(Matrix3X2 matrix, Vector2D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X2 Multiply(Matrix2X3 left, Matrix3X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X2 Multiply(Matrix3X2 left, Matrix2X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X3 Multiply(Matrix3X2 left, Matrix2X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 Multiply(Matrix3X2 left, Matrix2X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X2 Multiply(Matrix3X3 left, Matrix3X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 Multiply(Matrix4X3 left, Matrix3X2 right) + where T : INumberBase => + left * right; + } +} diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index 146443f8e5..b78a593a44 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -501,124 +501,4 @@ public static explicit operator checked Matrix3X2(Matrix3X2 from) => Vector2D.CreateChecked(from.Row2), Vector2D.CreateChecked(from.Row3)); } - - /// - /// Methods for working with . - /// - public static partial class Matrix3X2 - { - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static Matrix3X2 Lerp(Matrix3X2 value1, Matrix3X2 value2, T amount) - where T : IFloatingPointIeee754 => - new(Vector2D.Lerp(value1.Row1, value2.Row1, amount), - Vector2D.Lerp(value1.Row2, value2.Row2, amount), - Vector2D.Lerp(value1.Row3, value2.Row3, amount)); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix3X2 Add(Matrix3X2 left, Matrix3X2 right) - where T : INumberBase => - left + right; - - /// Returns a negated copy of the specified matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix3X2 Negate(Matrix3X2 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix3X2 Subtract(Matrix3X2 left, Matrix3X2 right) - where T : INumberBase - => left - right; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static Matrix3X2 Multiply(Matrix3X2 left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by a scalar value. - /// The scaling factor. - /// The source matrix. - /// The scaled matrix. - public static Matrix3X2 Multiply(T left, Matrix3X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix, expressed as a row vector. - /// The second source matrix. - /// The result of the multiplication as a column vector. - public static Vector2D Multiply(Vector3D rowVector, Matrix3X2 matrix) - where T : INumberBase => - rowVector * matrix; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix, expressed as a column vector. - /// The result of the multiplication as a row vector. - public static Vector3D Multiply(Matrix3X2 matrix, Vector2D columnVector) - where T : INumberBase => - matrix * columnVector; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X2 Multiply(Matrix2X3 left, Matrix3X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X2 Multiply(Matrix3X2 left, Matrix2X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X3 Multiply(Matrix3X2 left, Matrix2X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X4 Multiply(Matrix3X2 left, Matrix2X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X2 Multiply(Matrix3X3 left, Matrix3X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X2 Multiply(Matrix4X3 left, Matrix3X2 right) - where T : INumberBase => - left * right; - } } diff --git a/sources/Maths/Maths/Matrix3X3.Ops.gen.cs b/sources/Maths/Maths/Matrix3X3.Ops.gen.cs new file mode 100644 index 0000000000..5d0b5e91c9 --- /dev/null +++ b/sources/Maths/Maths/Matrix3X3.Ops.gen.cs @@ -0,0 +1,119 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Matrix3X3 + { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. + public static Matrix3X3 Lerp(Matrix3X3 value1, Matrix3X3 value2, T amount) + where T : IFloatingPointIeee754 => + new(Vector3D.Lerp(value1.Row1, value2.Row1, amount), + Vector3D.Lerp(value1.Row2, value2.Row2, amount), + Vector3D.Lerp(value1.Row3, value2.Row3, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix3X3 Add(Matrix3X3 left, Matrix3X3 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix3X3 Negate(Matrix3X3 value) + where T : INumberBase => + -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix3X3 Subtract(Matrix3X3 left, Matrix3X3 right) + where T : INumberBase => + left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix3X3 Multiply(Matrix3X3 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix3X3 Multiply(T left, Matrix3X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector3D Multiply(Vector3D rowVector, Matrix3X3 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector3D Multiply(Matrix3X3 matrix, Vector3D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X3 Multiply(Matrix2X3 left, Matrix3X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X2 Multiply(Matrix3X3 left, Matrix3X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X3 Multiply(Matrix3X3 left, Matrix3X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 Multiply(Matrix3X3 left, Matrix3X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 Multiply(Matrix4X3 left, Matrix3X3 right) + where T : INumberBase => + left * right; + } +} diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index 6b90b17ce6..33336a03a1 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -539,116 +539,4 @@ public static explicit operator checked Matrix3X3(Matrix3X3 from) => Vector3D.CreateChecked(from.Row2), Vector3D.CreateChecked(from.Row3)); } - - /// - /// Methods for working with . - /// - public static partial class Matrix3X3 - { - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static Matrix3X3 Lerp(Matrix3X3 value1, Matrix3X3 value2, T amount) - where T : IFloatingPointIeee754 => - new(Vector3D.Lerp(value1.Row1, value2.Row1, amount), - Vector3D.Lerp(value1.Row2, value2.Row2, amount), - Vector3D.Lerp(value1.Row3, value2.Row3, amount)); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix3X3 Add(Matrix3X3 left, Matrix3X3 right) - where T : INumberBase => - left + right; - - /// Returns a negated copy of the specified matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix3X3 Negate(Matrix3X3 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix3X3 Subtract(Matrix3X3 left, Matrix3X3 right) - where T : INumberBase - => left - right; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static Matrix3X3 Multiply(Matrix3X3 left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by a scalar value. - /// The scaling factor. - /// The source matrix. - /// The scaled matrix. - public static Matrix3X3 Multiply(T left, Matrix3X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix, expressed as a row vector. - /// The second source matrix. - /// The result of the multiplication as a column vector. - public static Vector3D Multiply(Vector3D rowVector, Matrix3X3 matrix) - where T : INumberBase => - rowVector * matrix; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix, expressed as a column vector. - /// The result of the multiplication as a row vector. - public static Vector3D Multiply(Matrix3X3 matrix, Vector3D columnVector) - where T : INumberBase => - matrix * columnVector; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X3 Multiply(Matrix2X3 left, Matrix3X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X2 Multiply(Matrix3X3 left, Matrix3X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X3 Multiply(Matrix3X3 left, Matrix3X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X4 Multiply(Matrix3X3 left, Matrix3X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X3 Multiply(Matrix4X3 left, Matrix3X3 right) - where T : INumberBase => - left * right; - } } diff --git a/sources/Maths/Maths/Matrix3X4.Ops.gen.cs b/sources/Maths/Maths/Matrix3X4.Ops.gen.cs new file mode 100644 index 0000000000..2adf914ae2 --- /dev/null +++ b/sources/Maths/Maths/Matrix3X4.Ops.gen.cs @@ -0,0 +1,127 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Matrix3X4 + { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. + public static Matrix3X4 Lerp(Matrix3X4 value1, Matrix3X4 value2, T amount) + where T : IFloatingPointIeee754 => + new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), + Vector4D.Lerp(value1.Row2, value2.Row2, amount), + Vector4D.Lerp(value1.Row3, value2.Row3, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix3X4 Add(Matrix3X4 left, Matrix3X4 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix3X4 Negate(Matrix3X4 value) + where T : INumberBase => + -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix3X4 Subtract(Matrix3X4 left, Matrix3X4 right) + where T : INumberBase => + left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix3X4 Multiply(Matrix3X4 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix3X4 Multiply(T left, Matrix3X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector4D Multiply(Vector3D rowVector, Matrix3X4 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector3D Multiply(Matrix3X4 matrix, Vector4D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 Multiply(Matrix2X3 left, Matrix3X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 Multiply(Matrix3X3 left, Matrix3X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X2 Multiply(Matrix3X4 left, Matrix4X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X3 Multiply(Matrix3X4 left, Matrix4X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 Multiply(Matrix3X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X4 Multiply(Matrix4X3 left, Matrix3X4 right) + where T : INumberBase => + left * right; + } +} diff --git a/sources/Maths/Maths/Matrix3X4.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs index 4c774db732..2bf714652f 100644 --- a/sources/Maths/Maths/Matrix3X4.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -558,124 +558,4 @@ public static explicit operator checked Matrix3X4(Matrix3X4 from) => Vector4D.CreateChecked(from.Row2), Vector4D.CreateChecked(from.Row3)); } - - /// - /// Methods for working with . - /// - public static partial class Matrix3X4 - { - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static Matrix3X4 Lerp(Matrix3X4 value1, Matrix3X4 value2, T amount) - where T : IFloatingPointIeee754 => - new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), - Vector4D.Lerp(value1.Row2, value2.Row2, amount), - Vector4D.Lerp(value1.Row3, value2.Row3, amount)); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix3X4 Add(Matrix3X4 left, Matrix3X4 right) - where T : INumberBase => - left + right; - - /// Returns a negated copy of the specified matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix3X4 Negate(Matrix3X4 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix3X4 Subtract(Matrix3X4 left, Matrix3X4 right) - where T : INumberBase - => left - right; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static Matrix3X4 Multiply(Matrix3X4 left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by a scalar value. - /// The scaling factor. - /// The source matrix. - /// The scaled matrix. - public static Matrix3X4 Multiply(T left, Matrix3X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix, expressed as a row vector. - /// The second source matrix. - /// The result of the multiplication as a column vector. - public static Vector4D Multiply(Vector3D rowVector, Matrix3X4 matrix) - where T : INumberBase => - rowVector * matrix; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix, expressed as a column vector. - /// The result of the multiplication as a row vector. - public static Vector3D Multiply(Matrix3X4 matrix, Vector4D columnVector) - where T : INumberBase => - matrix * columnVector; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X4 Multiply(Matrix2X3 left, Matrix3X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X4 Multiply(Matrix3X3 left, Matrix3X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X2 Multiply(Matrix3X4 left, Matrix4X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X3 Multiply(Matrix3X4 left, Matrix4X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X4 Multiply(Matrix3X4 left, Matrix4X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X4 Multiply(Matrix4X3 left, Matrix3X4 right) - where T : INumberBase => - left * right; - } } diff --git a/sources/Maths/Maths/Matrix4X2.Ops.gen.cs b/sources/Maths/Maths/Matrix4X2.Ops.gen.cs new file mode 100644 index 0000000000..5e19cc085d --- /dev/null +++ b/sources/Maths/Maths/Matrix4X2.Ops.gen.cs @@ -0,0 +1,128 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Matrix4X2 + { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. + public static Matrix4X2 Lerp(Matrix4X2 value1, Matrix4X2 value2, T amount) + where T : IFloatingPointIeee754 => + new(Vector2D.Lerp(value1.Row1, value2.Row1, amount), + Vector2D.Lerp(value1.Row2, value2.Row2, amount), + Vector2D.Lerp(value1.Row3, value2.Row3, amount), + Vector2D.Lerp(value1.Row4, value2.Row4, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4X2 Add(Matrix4X2 left, Matrix4X2 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4X2 Negate(Matrix4X2 value) + where T : INumberBase => + -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4X2 Subtract(Matrix4X2 left, Matrix4X2 right) + where T : INumberBase => + left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix4X2 Multiply(Matrix4X2 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix4X2 Multiply(T left, Matrix4X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector2D Multiply(Vector4D rowVector, Matrix4X2 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector4D Multiply(Matrix4X2 matrix, Vector2D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X2 Multiply(Matrix2X4 left, Matrix4X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X2 Multiply(Matrix3X4 left, Matrix4X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 Multiply(Matrix4X2 left, Matrix2X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 Multiply(Matrix4X2 left, Matrix2X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X4 Multiply(Matrix4X2 left, Matrix2X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 Multiply(Matrix4X4 left, Matrix4X2 right) + where T : INumberBase => + left * right; + } +} diff --git a/sources/Maths/Maths/Matrix4X2.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs index 36a9be66fa..736f70bab4 100644 --- a/sources/Maths/Maths/Matrix4X2.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -562,125 +562,4 @@ public static explicit operator checked Matrix4X2(Matrix4X2 from) => Vector2D.CreateChecked(from.Row3), Vector2D.CreateChecked(from.Row4)); } - - /// - /// Methods for working with . - /// - public static partial class Matrix4X2 - { - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static Matrix4X2 Lerp(Matrix4X2 value1, Matrix4X2 value2, T amount) - where T : IFloatingPointIeee754 => - new(Vector2D.Lerp(value1.Row1, value2.Row1, amount), - Vector2D.Lerp(value1.Row2, value2.Row2, amount), - Vector2D.Lerp(value1.Row3, value2.Row3, amount), - Vector2D.Lerp(value1.Row4, value2.Row4, amount)); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix4X2 Add(Matrix4X2 left, Matrix4X2 right) - where T : INumberBase => - left + right; - - /// Returns a negated copy of the specified matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix4X2 Negate(Matrix4X2 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix4X2 Subtract(Matrix4X2 left, Matrix4X2 right) - where T : INumberBase - => left - right; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static Matrix4X2 Multiply(Matrix4X2 left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by a scalar value. - /// The scaling factor. - /// The source matrix. - /// The scaled matrix. - public static Matrix4X2 Multiply(T left, Matrix4X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix, expressed as a row vector. - /// The second source matrix. - /// The result of the multiplication as a column vector. - public static Vector2D Multiply(Vector4D rowVector, Matrix4X2 matrix) - where T : INumberBase => - rowVector * matrix; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix, expressed as a column vector. - /// The result of the multiplication as a row vector. - public static Vector4D Multiply(Matrix4X2 matrix, Vector2D columnVector) - where T : INumberBase => - matrix * columnVector; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X2 Multiply(Matrix2X4 left, Matrix4X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X2 Multiply(Matrix3X4 left, Matrix4X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X2 Multiply(Matrix4X2 left, Matrix2X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X3 Multiply(Matrix4X2 left, Matrix2X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X4 Multiply(Matrix4X2 left, Matrix2X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X2 Multiply(Matrix4X4 left, Matrix4X2 right) - where T : INumberBase => - left * right; - } } diff --git a/sources/Maths/Maths/Matrix4X3.Ops.gen.cs b/sources/Maths/Maths/Matrix4X3.Ops.gen.cs new file mode 100644 index 0000000000..963cbf4370 --- /dev/null +++ b/sources/Maths/Maths/Matrix4X3.Ops.gen.cs @@ -0,0 +1,128 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Matrix4X3 + { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. + public static Matrix4X3 Lerp(Matrix4X3 value1, Matrix4X3 value2, T amount) + where T : IFloatingPointIeee754 => + new(Vector3D.Lerp(value1.Row1, value2.Row1, amount), + Vector3D.Lerp(value1.Row2, value2.Row2, amount), + Vector3D.Lerp(value1.Row3, value2.Row3, amount), + Vector3D.Lerp(value1.Row4, value2.Row4, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4X3 Add(Matrix4X3 left, Matrix4X3 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4X3 Negate(Matrix4X3 value) + where T : INumberBase => + -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4X3 Subtract(Matrix4X3 left, Matrix4X3 right) + where T : INumberBase => + left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix4X3 Multiply(Matrix4X3 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix4X3 Multiply(T left, Matrix4X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector3D Multiply(Vector4D rowVector, Matrix4X3 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector4D Multiply(Matrix4X3 matrix, Vector3D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X3 Multiply(Matrix2X4 left, Matrix4X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X3 Multiply(Matrix3X4 left, Matrix4X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 Multiply(Matrix4X3 left, Matrix3X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 Multiply(Matrix4X3 left, Matrix3X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X4 Multiply(Matrix4X3 left, Matrix3X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 Multiply(Matrix4X4 left, Matrix4X3 right) + where T : INumberBase => + left * right; + } +} diff --git a/sources/Maths/Maths/Matrix4X3.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs index af8d280c3c..90626d74b3 100644 --- a/sources/Maths/Maths/Matrix4X3.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -595,125 +595,4 @@ public static explicit operator checked Matrix4X3(Matrix4X3 from) => Vector3D.CreateChecked(from.Row3), Vector3D.CreateChecked(from.Row4)); } - - /// - /// Methods for working with . - /// - public static partial class Matrix4X3 - { - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static Matrix4X3 Lerp(Matrix4X3 value1, Matrix4X3 value2, T amount) - where T : IFloatingPointIeee754 => - new(Vector3D.Lerp(value1.Row1, value2.Row1, amount), - Vector3D.Lerp(value1.Row2, value2.Row2, amount), - Vector3D.Lerp(value1.Row3, value2.Row3, amount), - Vector3D.Lerp(value1.Row4, value2.Row4, amount)); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix4X3 Add(Matrix4X3 left, Matrix4X3 right) - where T : INumberBase => - left + right; - - /// Returns a negated copy of the specified matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix4X3 Negate(Matrix4X3 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix4X3 Subtract(Matrix4X3 left, Matrix4X3 right) - where T : INumberBase - => left - right; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static Matrix4X3 Multiply(Matrix4X3 left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by a scalar value. - /// The scaling factor. - /// The source matrix. - /// The scaled matrix. - public static Matrix4X3 Multiply(T left, Matrix4X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix, expressed as a row vector. - /// The second source matrix. - /// The result of the multiplication as a column vector. - public static Vector3D Multiply(Vector4D rowVector, Matrix4X3 matrix) - where T : INumberBase => - rowVector * matrix; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix, expressed as a column vector. - /// The result of the multiplication as a row vector. - public static Vector4D Multiply(Matrix4X3 matrix, Vector3D columnVector) - where T : INumberBase => - matrix * columnVector; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X3 Multiply(Matrix2X4 left, Matrix4X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X3 Multiply(Matrix3X4 left, Matrix4X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X2 Multiply(Matrix4X3 left, Matrix3X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X3 Multiply(Matrix4X3 left, Matrix3X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X4 Multiply(Matrix4X3 left, Matrix3X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X3 Multiply(Matrix4X4 left, Matrix4X3 right) - where T : INumberBase => - left * right; - } } diff --git a/sources/Maths/Maths/Matrix4X4.Ops.gen.cs b/sources/Maths/Maths/Matrix4X4.Ops.gen.cs new file mode 100644 index 0000000000..80278aa415 --- /dev/null +++ b/sources/Maths/Maths/Matrix4X4.Ops.gen.cs @@ -0,0 +1,128 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Matrix4X4 + { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. + public static Matrix4X4 Lerp(Matrix4X4 value1, Matrix4X4 value2, T amount) + where T : IFloatingPointIeee754 => + new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), + Vector4D.Lerp(value1.Row2, value2.Row2, amount), + Vector4D.Lerp(value1.Row3, value2.Row3, amount), + Vector4D.Lerp(value1.Row4, value2.Row4, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix4X4 Add(Matrix4X4 left, Matrix4X4 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix4X4 Negate(Matrix4X4 value) + where T : INumberBase => + -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix4X4 Subtract(Matrix4X4 left, Matrix4X4 right) + where T : INumberBase => + left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix4X4 Multiply(Matrix4X4 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix4X4 Multiply(T left, Matrix4X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix, expressed as a row vector. + /// The second source matrix. + /// The result of the multiplication as a column vector. + public static Vector4D Multiply(Vector4D rowVector, Matrix4X4 matrix) + where T : INumberBase => + rowVector * matrix; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix, expressed as a column vector. + /// The result of the multiplication as a row vector. + public static Vector4D Multiply(Matrix4X4 matrix, Vector4D columnVector) + where T : INumberBase => + matrix * columnVector; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix2X4 Multiply(Matrix2X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix3X4 Multiply(Matrix3X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X2 Multiply(Matrix4X4 left, Matrix4X2 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X3 Multiply(Matrix4X4 left, Matrix4X3 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix4X4 Multiply(Matrix4X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix5X4 Multiply(Matrix5X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; + } +} diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index 132cba58a4..a21819946d 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -640,125 +640,4 @@ public static explicit operator checked Matrix4X4(Matrix4X4 from) => Vector4D.CreateChecked(from.Row3), Vector4D.CreateChecked(from.Row4)); } - - /// - /// Methods for working with . - /// - public static partial class Matrix4X4 - { - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static Matrix4X4 Lerp(Matrix4X4 value1, Matrix4X4 value2, T amount) - where T : IFloatingPointIeee754 => - new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), - Vector4D.Lerp(value1.Row2, value2.Row2, amount), - Vector4D.Lerp(value1.Row3, value2.Row3, amount), - Vector4D.Lerp(value1.Row4, value2.Row4, amount)); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix4X4 Add(Matrix4X4 left, Matrix4X4 right) - where T : INumberBase => - left + right; - - /// Returns a negated copy of the specified matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix4X4 Negate(Matrix4X4 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix4X4 Subtract(Matrix4X4 left, Matrix4X4 right) - where T : INumberBase - => left - right; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static Matrix4X4 Multiply(Matrix4X4 left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by a scalar value. - /// The scaling factor. - /// The source matrix. - /// The scaled matrix. - public static Matrix4X4 Multiply(T left, Matrix4X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix, expressed as a row vector. - /// The second source matrix. - /// The result of the multiplication as a column vector. - public static Vector4D Multiply(Vector4D rowVector, Matrix4X4 matrix) - where T : INumberBase => - rowVector * matrix; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix, expressed as a column vector. - /// The result of the multiplication as a row vector. - public static Vector4D Multiply(Matrix4X4 matrix, Vector4D columnVector) - where T : INumberBase => - matrix * columnVector; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix2X4 Multiply(Matrix2X4 left, Matrix4X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix3X4 Multiply(Matrix3X4 left, Matrix4X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X2 Multiply(Matrix4X4 left, Matrix4X2 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X3 Multiply(Matrix4X4 left, Matrix4X3 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix4X4 Multiply(Matrix4X4 left, Matrix4X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix5X4 Multiply(Matrix5X4 left, Matrix4X4 right) - where T : INumberBase => - left * right; - } } diff --git a/sources/Maths/Maths/Matrix5X4.Ops.gen.cs b/sources/Maths/Maths/Matrix5X4.Ops.gen.cs new file mode 100644 index 0000000000..bbe6b3776e --- /dev/null +++ b/sources/Maths/Maths/Matrix5X4.Ops.gen.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Matrix5X4 + { + /// Linearly interpolates between the corresponding values of two matrices. + /// The first source matrix. + /// The second source matrix. + /// The relative weight of the second source matrix. + /// The interpolated matrix. + public static Matrix5X4 Lerp(Matrix5X4 value1, Matrix5X4 value2, T amount) + where T : IFloatingPointIeee754 => + new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), + Vector4D.Lerp(value1.Row2, value2.Row2, amount), + Vector4D.Lerp(value1.Row3, value2.Row3, amount), + Vector4D.Lerp(value1.Row4, value2.Row4, amount), + Vector4D.Lerp(value1.Row5, value2.Row5, amount)); + + /// Adds two matrices together. + /// The first source matrix. + /// The second source matrix. + /// The result of the addition. + public static Matrix5X4 Add(Matrix5X4 left, Matrix5X4 right) + where T : INumberBase => + left + right; + + /// Returns a negated copy of the specified matrix. + /// The source matrix. + /// The negated matrix. + public static Matrix5X4 Negate(Matrix5X4 value) + where T : INumberBase => + -value; + + /// Subtracts the second matrix from the first. + /// The first source matrix. + /// The second source matrix. + /// The result of the subtraction. + public static Matrix5X4 Subtract(Matrix5X4 left, Matrix5X4 right) + where T : INumberBase => + left - right; + + /// Multiplies a matrix by a scalar value. + /// The source matrix. + /// The scaling factor. + /// The scaled matrix. + public static Matrix5X4 Multiply(Matrix5X4 left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by a scalar value. + /// The scaling factor. + /// The source matrix. + /// The scaled matrix. + public static Matrix5X4 Multiply(T left, Matrix5X4 right) + where T : INumberBase => + left * right; + + /// Multiplies a matrix by another matrix. + /// The first source matrix. + /// The second source matrix. + /// The result of the multiplication. + public static Matrix5X4 Multiply(Matrix5X4 left, Matrix4X4 right) + where T : INumberBase => + left * right; + } +} diff --git a/sources/Maths/Maths/Matrix5X4.gen.cs b/sources/Maths/Maths/Matrix5X4.gen.cs index b4f1b7642a..18207c9630 100644 --- a/sources/Maths/Maths/Matrix5X4.gen.cs +++ b/sources/Maths/Maths/Matrix5X4.gen.cs @@ -615,70 +615,4 @@ public static explicit operator checked Matrix5X4(Matrix5X4 from) => Vector4D.CreateChecked(from.Row4), Vector4D.CreateChecked(from.Row5)); } - - /// - /// Methods for working with . - /// - public static partial class Matrix5X4 - { - /// Linearly interpolates between the corresponding values of two matrices. - /// The first source matrix. - /// The second source matrix. - /// The relative weight of the second source matrix. - /// The interpolated matrix. - public static Matrix5X4 Lerp(Matrix5X4 value1, Matrix5X4 value2, T amount) - where T : IFloatingPointIeee754 => - new(Vector4D.Lerp(value1.Row1, value2.Row1, amount), - Vector4D.Lerp(value1.Row2, value2.Row2, amount), - Vector4D.Lerp(value1.Row3, value2.Row3, amount), - Vector4D.Lerp(value1.Row4, value2.Row4, amount), - Vector4D.Lerp(value1.Row5, value2.Row5, amount)); - - /// Adds two matrices together. - /// The first source matrix. - /// The second source matrix. - /// The result of the addition. - public static Matrix5X4 Add(Matrix5X4 left, Matrix5X4 right) - where T : INumberBase => - left + right; - - /// Returns a negated copy of the specified matrix. - /// The source matrix. - /// The negated matrix. - public static Matrix5X4 Negate(Matrix5X4 value) - where T : INumberBase - => -value; - - /// Subtracts the second matrix from the first. - /// The first source matrix. - /// The second source matrix. - /// The result of the subtraction. - public static Matrix5X4 Subtract(Matrix5X4 left, Matrix5X4 right) - where T : INumberBase - => left - right; - - /// Multiplies a matrix by a scalar value. - /// The source matrix. - /// The scaling factor. - /// The scaled matrix. - public static Matrix5X4 Multiply(Matrix5X4 left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by a scalar value. - /// The scaling factor. - /// The source matrix. - /// The scaled matrix. - public static Matrix5X4 Multiply(T left, Matrix5X4 right) - where T : INumberBase => - left * right; - - /// Multiplies a matrix by another matrix. - /// The first source matrix. - /// The second source matrix. - /// The result of the multiplication. - public static Matrix5X4 Multiply(Matrix5X4 left, Matrix4X4 right) - where T : INumberBase => - left * right; - } } diff --git a/sources/Maths/Maths/Vector2D.Ops.gen.cs b/sources/Maths/Maths/Vector2D.Ops.gen.cs new file mode 100644 index 0000000000..15469506ff --- /dev/null +++ b/sources/Maths/Maths/Vector2D.Ops.gen.cs @@ -0,0 +1,686 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Vector2D + { + /// Extensions for vectors with elements implementing . + extension(Vector2D vector) + where T : IRootFunctions + { + /// Gets the length of the vector. + public T Length => T.Sqrt(vector.LengthSquared); + } + + /// Extensions for vectors with elements implementing . + extension(Vector2D vector) + where T : INumberBase + { + /// Gets the length squared of the vector. + public T LengthSquared => Vector2D.Dot(vector, vector); + } + + /// Desconstructs a vector into its components. + /// The vector to deconstruct. + /// The X component. + /// The Y component. + public static void Deconstruct(this Vector2D vector, out T x, out T y) + where T : INumberBase + { + x = vector.X; + y = vector.Y; + } + + /// Computes the dot product of two vectors. + public static T Dot(this Vector2D left, Vector2D right) + where T : INumberBase => + left.X * right.X + left.Y * right.Y; + + /// Reflects a vector over a normal vector. + public static Vector2D Reflect(Vector2D vector, Vector2D normal) + where T : INumberBase + { + T dot = vector.Dot(normal); + return vector - (normal * (dot + dot)); + } + + /// Normalizes a vector. + public static Vector2D Normalize(this Vector2D vector) + where T : IRootFunctions + { + T length = vector.Length; + return length != T.Zero ? vector / length : Vector2D.Zero; + } + + /// Returns the Euclidean distance between the two given points. + /// The first point. + /// The second point. + /// The distance. + public static T Distance(Vector2D value1, Vector2D value2) + where T : IRootFunctions => + T.Sqrt(DistanceSquared(value1, value2)); + + /// Returns the Euclidean distance squared between the two given points. + /// The first point. + /// The second point. + /// The distance squared. + public static T DistanceSquared(Vector2D value1, Vector2D value2) + where T : INumberBase + { + var difference = value1 - value2; + return Dot(difference, difference); + } + + /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). + public static Vector2D LerpClamped(Vector2D a, Vector2D b, T amount) + where T : IFloatingPointIeee754 => + Lerp(a, b, T.Clamp(amount, T.Zero, T.One)); + + /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). + public static Vector2D LerpClamped(Vector2D a, Vector2D b, Vector2D amount) + where T : IFloatingPointIeee754 => + new(T.Lerp(a.X, b.X, T.Clamp(amount.X, T.Zero, T.One)), + T.Lerp(a.Y, b.Y, T.Clamp(amount.Y, T.Zero, T.One))); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static (Vector2D Sin, Vector2D Cos) SinCos(this Vector2D x) + where T : ITrigonometricFunctions => + (new(T.Sin(x.X), T.Sin(x.Y)), new(T.Cos(x.X), T.Cos(x.Y))); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static (Vector2D SinPi, Vector2D CosPi) SinCosPi(this Vector2D x) + where T : ITrigonometricFunctions => + (new(T.SinPi(x.X), T.SinPi(x.Y)), new(T.CosPi(x.X), T.CosPi(x.Y))); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static (Vector2D Quotient, Vector2D Remainder) DivRem(Vector2D left, Vector2D right) + where T : IBinaryInteger + { + var (qX, rX) = T.DivRem(left.X, right.X); + var (qY, rY) = T.DivRem(left.Y, right.Y); + return (new Vector2D(qX, qY), new Vector2D(rX, rY)); + } + + /// Multiplies a vector by a scalar value. + /// The source vector. + /// The scaling factor. + /// The scaled vector. + public static Vector2D Multiply(Vector2D left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a vector by a scalar value. + /// The scaling factor. + /// The source vector. + /// The scaled vector. + public static Vector2D Multiply(T left, Vector2D right) + where T : INumberBase => + left * right; + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Sign(this Vector2D value) + where TSelf : INumber => + new(TSelf.Sign(value.X), TSelf.Sign(value.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D Max(this Vector2D x, Vector2D y) + where TSelf : INumber => + new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D Max(this Vector2D x, TSelf y) + where TSelf : INumber => + new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D MaxNumber(this Vector2D x, Vector2D y) + where TSelf : INumber => + new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D MaxNumber(this Vector2D x, TSelf y) + where TSelf : INumber => + new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D Min(this Vector2D x, Vector2D y) + where TSelf : INumber => + new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D Min(this Vector2D x, TSelf y) + where TSelf : INumber => + new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D MinNumber(this Vector2D x, Vector2D y) + where TSelf : INumber => + new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D MinNumber(this Vector2D x, TSelf y) + where TSelf : INumber => + new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D Clamp(this Vector2D value, Vector2D min, Vector2D max) + where TSelf : INumber => + new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector2D Clamp(this Vector2D value, TSelf min, TSelf max) + where TSelf : INumber => + new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D CopySign(this Vector2D value, Vector2D sign) + where TSelf : INumber => + new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D CopySign(this Vector2D value, TSelf sign) + where TSelf : INumber => + new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Abs(this Vector2D value) + where TSelf : INumberBase => + new(TSelf.Abs(value.X), TSelf.Abs(value.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D MaxMagnitude(this Vector2D x, Vector2D y) + where TSelf : INumberBase => + new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D MaxMagnitudeNumber(this Vector2D x, Vector2D y) + where TSelf : INumberBase => + new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D MinMagnitude(this Vector2D x, Vector2D y) + where TSelf : INumberBase => + new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D MinMagnitudeNumber(this Vector2D x, Vector2D y) + where TSelf : INumberBase => + new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D PopCount(this Vector2D value) + where TSelf : IBinaryInteger => + new(TSelf.PopCount(value.X), TSelf.PopCount(value.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D TrailingZeroCount(this Vector2D value) + where TSelf : IBinaryInteger => + new(TSelf.TrailingZeroCount(value.X), TSelf.TrailingZeroCount(value.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Ceiling(this Vector2D x) + where TSelf : IFloatingPoint => + new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Floor(this Vector2D x) + where TSelf : IFloatingPoint => + new(TSelf.Floor(x.X), TSelf.Floor(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Round(this Vector2D x) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X), TSelf.Round(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D Round(this Vector2D x, int digits) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, digits), TSelf.Round(x.Y, digits)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D Round(this Vector2D x, MidpointRounding mode) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, mode), TSelf.Round(x.Y, mode)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector2D Round(this Vector2D x, int digits, MidpointRounding mode) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Truncate(this Vector2D x) + where TSelf : IFloatingPoint => + new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D Atan2(this Vector2D y, Vector2D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D Atan2Pi(this Vector2D y, Vector2D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D Lerp(this Vector2D value1, Vector2D value2, TSelf amount) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D BitDecrement(this Vector2D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D BitIncrement(this Vector2D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D FusedMultiplyAdd(this Vector2D left, Vector2D right, Vector2D addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D FusedMultiplyAdd(this Vector2D left, Vector2D right, TSelf addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right.X, addend), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A vector whose members will be provided for . + public static Vector2D FusedMultiplyAdd(this Vector2D left, TSelf right, Vector2D addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right, addend.X), TSelf.FusedMultiplyAdd(left.Y, right, addend.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector2D FusedMultiplyAdd(this Vector2D left, TSelf right, TSelf addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D Ieee754Remainder(this Vector2D left, Vector2D right) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D Ieee754Remainder(this Vector2D left, TSelf right) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D ILogB(this Vector2D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D ReciprocalEstimate(this Vector2D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D ReciprocalSqrtEstimate(this Vector2D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D ScaleB(this Vector2D x, Vector2D n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D ScaleB(this Vector2D x, int n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D Pow(this Vector2D x, Vector2D y) + where TSelf : IPowerFunctions => + new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D Pow(this Vector2D x, TSelf y) + where TSelf : IPowerFunctions => + new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Cbrt(this Vector2D x) + where TSelf : IRootFunctions => + new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Sqrt(this Vector2D x) + where TSelf : IRootFunctions => + new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D RootN(this Vector2D x, int n) + where TSelf : IRootFunctions => + new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D RootN(this Vector2D x, Vector2D n) + where TSelf : IRootFunctions => + new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D Hypot(this Vector2D x, Vector2D y) + where TSelf : IRootFunctions => + new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D Hypot(this Vector2D x, TSelf y) + where TSelf : IRootFunctions => + new(TSelf.Hypot(x.X, y), TSelf.Hypot(x.Y, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Log(this Vector2D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log(x.X), TSelf.Log(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D Log(this Vector2D x, Vector2D newBase) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D Log(this Vector2D x, TSelf newBase) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D LogP1(this Vector2D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Log2(this Vector2D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log2(x.X), TSelf.Log2(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Log2P1(this Vector2D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Log10(this Vector2D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log10(x.X), TSelf.Log10(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Log10P1(this Vector2D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Exp(this Vector2D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp(x.X), TSelf.Exp(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D ExpM1(this Vector2D x) + where TSelf : IExponentialFunctions => + new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Exp2(this Vector2D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Exp2M1(this Vector2D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Exp10(this Vector2D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Exp10M1(this Vector2D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Acos(this Vector2D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Acos(x.X), TSelf.Acos(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D AcosPi(this Vector2D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Asin(this Vector2D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Asin(x.X), TSelf.Asin(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D AsinPi(this Vector2D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Atan(this Vector2D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Atan(x.X), TSelf.Atan(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D AtanPi(this Vector2D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Cos(this Vector2D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Cos(x.X), TSelf.Cos(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D CosPi(this Vector2D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Sin(this Vector2D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Sin(x.X), TSelf.Sin(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D SinPi(this Vector2D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Tan(this Vector2D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Tan(x.X), TSelf.Tan(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D TanPi(this Vector2D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D DegreesToRadians(this Vector2D degrees) + where TSelf : ITrigonometricFunctions => + new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D RadiansToDegrees(this Vector2D radians) + where TSelf : ITrigonometricFunctions => + new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Acosh(this Vector2D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Asinh(this Vector2D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Atanh(this Vector2D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Cosh(this Vector2D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Sinh(this Vector2D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector2D Tanh(this Vector2D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y)); + } +} diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index e318a50904..46eb432135 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -615,683 +615,4 @@ public static explicit operator Vector2D(Vector2D from) => public static explicit operator checked Vector2D(Vector2D from) => Vector2D.CreateChecked(from); } - - /// - /// Methods for working with . - /// - public static partial class Vector2D - { - /// Extensions for vectors with elements implementing . - extension(Vector2D vector) - where T : IRootFunctions - { - /// Gets the length of the vector. - public T Length => T.Sqrt(vector.LengthSquared); - } - - /// Extensions for vectors with elements implementing . - extension(Vector2D vector) - where T : INumberBase - { - /// Gets the length squared of the vector. - public T LengthSquared => Vector2D.Dot(vector, vector); - } - - /// Desconstructs a vector into its components. - /// The vector to deconstruct. - /// The X component. - /// The Y component. - public static void Deconstruct(this Vector2D vector, out T x, out T y) - where T : INumberBase - { - x = vector.X; - y = vector.Y; - } - - /// Computes the dot product of two vectors. - public static T Dot(this Vector2D left, Vector2D right) - where T : INumberBase => - left.X * right.X + left.Y * right.Y; - - /// Reflects a vector over a normal vector. - public static Vector2D Reflect(Vector2D vector, Vector2D normal) - where T : INumberBase - { - T dot = vector.Dot(normal); - return vector - (normal * (dot + dot)); - } - - /// Normalizes a vector. - public static Vector2D Normalize(this Vector2D vector) - where T : IRootFunctions - { - T length = vector.Length; - return length != T.Zero ? vector / length : Vector2D.Zero; - } - - /// Returns the Euclidean distance between the two given points. - /// The first point. - /// The second point. - /// The distance. - public static T Distance(Vector2D value1, Vector2D value2) - where T : IRootFunctions => - T.Sqrt(DistanceSquared(value1, value2)); - - /// Returns the Euclidean distance squared between the two given points. - /// The first point. - /// The second point. - /// The distance squared. - public static T DistanceSquared(Vector2D value1, Vector2D value2) - where T : INumberBase - { - var difference = value1 - value2; - return Dot(difference, difference); - } - - /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). - public static Vector2D LerpClamped(Vector2D a, Vector2D b, T amount) - where T : IFloatingPointIeee754 => - Lerp(a, b, T.Clamp(amount, T.Zero, T.One)); - - /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). - public static Vector2D LerpClamped(Vector2D a, Vector2D b, Vector2D amount) - where T : IFloatingPointIeee754 => - new(T.Lerp(a.X, b.X, T.Clamp(amount.X, T.Zero, T.One)), - T.Lerp(a.Y, b.Y, T.Clamp(amount.Y, T.Zero, T.One))); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static (Vector2D Sin, Vector2D Cos) SinCos(this Vector2D x) - where T : ITrigonometricFunctions => - (new(T.Sin(x.X), T.Sin(x.Y)), new(T.Cos(x.X), T.Cos(x.Y))); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static (Vector2D SinPi, Vector2D CosPi) SinCosPi(this Vector2D x) - where T : ITrigonometricFunctions => - (new(T.SinPi(x.X), T.SinPi(x.Y)), new(T.CosPi(x.X), T.CosPi(x.Y))); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static (Vector2D Quotient, Vector2D Remainder) DivRem(Vector2D left, Vector2D right) - where T : IBinaryInteger - { - var (qX, rX) = T.DivRem(left.X, right.X); - var (qY, rY) = T.DivRem(left.Y, right.Y); - return (new Vector2D(qX, qY), new Vector2D(rX, rY)); - } - - /// Multiplies a vector by a scalar value. - /// The source vector. - /// The scaling factor. - /// The scaled vector. - public static Vector2D Multiply(Vector2D left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a vector by a scalar value. - /// The scaling factor. - /// The source vector. - /// The scaled vector. - public static Vector2D Multiply(T left, Vector2D right) - where T : INumberBase => - left * right; - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Sign(this Vector2D value) - where TSelf : INumber => - new(TSelf.Sign(value.X), TSelf.Sign(value.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D Max(this Vector2D x, Vector2D y) - where TSelf : INumber => - new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D Max(this Vector2D x, TSelf y) - where TSelf : INumber => - new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D MaxNumber(this Vector2D x, Vector2D y) - where TSelf : INumber => - new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D MaxNumber(this Vector2D x, TSelf y) - where TSelf : INumber => - new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D Min(this Vector2D x, Vector2D y) - where TSelf : INumber => - new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D Min(this Vector2D x, TSelf y) - where TSelf : INumber => - new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D MinNumber(this Vector2D x, Vector2D y) - where TSelf : INumber => - new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D MinNumber(this Vector2D x, TSelf y) - where TSelf : INumber => - new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D Clamp(this Vector2D value, Vector2D min, Vector2D max) - where TSelf : INumber => - new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A single value provided for . - public static Vector2D Clamp(this Vector2D value, TSelf min, TSelf max) - where TSelf : INumber => - new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D CopySign(this Vector2D value, Vector2D sign) - where TSelf : INumber => - new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D CopySign(this Vector2D value, TSelf sign) - where TSelf : INumber => - new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Abs(this Vector2D value) - where TSelf : INumberBase => - new(TSelf.Abs(value.X), TSelf.Abs(value.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D MaxMagnitude(this Vector2D x, Vector2D y) - where TSelf : INumberBase => - new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D MaxMagnitudeNumber(this Vector2D x, Vector2D y) - where TSelf : INumberBase => - new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D MinMagnitude(this Vector2D x, Vector2D y) - where TSelf : INumberBase => - new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D MinMagnitudeNumber(this Vector2D x, Vector2D y) - where TSelf : INumberBase => - new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D PopCount(this Vector2D value) - where TSelf : IBinaryInteger => - new(TSelf.PopCount(value.X), TSelf.PopCount(value.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D TrailingZeroCount(this Vector2D value) - where TSelf : IBinaryInteger => - new(TSelf.TrailingZeroCount(value.X), TSelf.TrailingZeroCount(value.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Ceiling(this Vector2D x) - where TSelf : IFloatingPoint => - new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Floor(this Vector2D x) - where TSelf : IFloatingPoint => - new(TSelf.Floor(x.X), TSelf.Floor(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Round(this Vector2D x) - where TSelf : IFloatingPoint => - new(TSelf.Round(x.X), TSelf.Round(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D Round(this Vector2D x, int digits) - where TSelf : IFloatingPoint => - new(TSelf.Round(x.X, digits), TSelf.Round(x.Y, digits)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D Round(this Vector2D x, MidpointRounding mode) - where TSelf : IFloatingPoint => - new(TSelf.Round(x.X, mode), TSelf.Round(x.Y, mode)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A single value provided for . - public static Vector2D Round(this Vector2D x, int digits, MidpointRounding mode) - where TSelf : IFloatingPoint => - new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Truncate(this Vector2D x) - where TSelf : IFloatingPoint => - new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D Atan2(this Vector2D y, Vector2D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D Atan2Pi(this Vector2D y, Vector2D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D Lerp(this Vector2D value1, Vector2D value2, TSelf amount) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D BitDecrement(this Vector2D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D BitIncrement(this Vector2D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D FusedMultiplyAdd(this Vector2D left, Vector2D right, Vector2D addend) - where TSelf : IFloatingPointIeee754 => - new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D FusedMultiplyAdd(this Vector2D left, Vector2D right, TSelf addend) - where TSelf : IFloatingPointIeee754 => - new(TSelf.FusedMultiplyAdd(left.X, right.X, addend), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A vector whose members will be provided for . - public static Vector2D FusedMultiplyAdd(this Vector2D left, TSelf right, Vector2D addend) - where TSelf : IFloatingPointIeee754 => - new(TSelf.FusedMultiplyAdd(left.X, right, addend.X), TSelf.FusedMultiplyAdd(left.Y, right, addend.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A single value provided for . - public static Vector2D FusedMultiplyAdd(this Vector2D left, TSelf right, TSelf addend) - where TSelf : IFloatingPointIeee754 => - new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D Ieee754Remainder(this Vector2D left, Vector2D right) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D Ieee754Remainder(this Vector2D left, TSelf right) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D ILogB(this Vector2D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D ReciprocalEstimate(this Vector2D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D ReciprocalSqrtEstimate(this Vector2D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D ScaleB(this Vector2D x, Vector2D n) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D ScaleB(this Vector2D x, int n) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D Pow(this Vector2D x, Vector2D y) - where TSelf : IPowerFunctions => - new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D Pow(this Vector2D x, TSelf y) - where TSelf : IPowerFunctions => - new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Cbrt(this Vector2D x) - where TSelf : IRootFunctions => - new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Sqrt(this Vector2D x) - where TSelf : IRootFunctions => - new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D RootN(this Vector2D x, int n) - where TSelf : IRootFunctions => - new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D RootN(this Vector2D x, Vector2D n) - where TSelf : IRootFunctions => - new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D Hypot(this Vector2D x, Vector2D y) - where TSelf : IRootFunctions => - new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D Hypot(this Vector2D x, TSelf y) - where TSelf : IRootFunctions => - new(TSelf.Hypot(x.X, y), TSelf.Hypot(x.Y, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Log(this Vector2D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log(x.X), TSelf.Log(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector2D Log(this Vector2D x, Vector2D newBase) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector2D Log(this Vector2D x, TSelf newBase) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D LogP1(this Vector2D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Log2(this Vector2D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log2(x.X), TSelf.Log2(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Log2P1(this Vector2D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Log10(this Vector2D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log10(x.X), TSelf.Log10(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Log10P1(this Vector2D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Exp(this Vector2D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp(x.X), TSelf.Exp(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D ExpM1(this Vector2D x) - where TSelf : IExponentialFunctions => - new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Exp2(this Vector2D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Exp2M1(this Vector2D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Exp10(this Vector2D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Exp10M1(this Vector2D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Acos(this Vector2D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Acos(x.X), TSelf.Acos(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D AcosPi(this Vector2D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Asin(this Vector2D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Asin(x.X), TSelf.Asin(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D AsinPi(this Vector2D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Atan(this Vector2D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Atan(x.X), TSelf.Atan(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D AtanPi(this Vector2D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Cos(this Vector2D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Cos(x.X), TSelf.Cos(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D CosPi(this Vector2D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Sin(this Vector2D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Sin(x.X), TSelf.Sin(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D SinPi(this Vector2D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Tan(this Vector2D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Tan(x.X), TSelf.Tan(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D TanPi(this Vector2D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D DegreesToRadians(this Vector2D degrees) - where TSelf : ITrigonometricFunctions => - new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D RadiansToDegrees(this Vector2D radians) - where TSelf : ITrigonometricFunctions => - new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Acosh(this Vector2D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Asinh(this Vector2D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Atanh(this Vector2D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Cosh(this Vector2D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Sinh(this Vector2D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector2D Tanh(this Vector2D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y)); - } } diff --git a/sources/Maths/Maths/Vector3D.Ops.gen.cs b/sources/Maths/Maths/Vector3D.Ops.gen.cs new file mode 100644 index 0000000000..dcbd4f369a --- /dev/null +++ b/sources/Maths/Maths/Vector3D.Ops.gen.cs @@ -0,0 +1,690 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Vector3D + { + /// Extensions for vectors with elements implementing . + extension(Vector3D vector) + where T : IRootFunctions + { + /// Gets the length of the vector. + public T Length => T.Sqrt(vector.LengthSquared); + } + + /// Extensions for vectors with elements implementing . + extension(Vector3D vector) + where T : INumberBase + { + /// Gets the length squared of the vector. + public T LengthSquared => Vector3D.Dot(vector, vector); + } + + /// Desconstructs a vector into its components. + /// The vector to deconstruct. + /// The X component. + /// The Y component. + /// The Z component. + public static void Deconstruct(this Vector3D vector, out T x, out T y, out T z) + where T : INumberBase + { + x = vector.X; + y = vector.Y; + z = vector.Z; + } + + /// Computes the dot product of two vectors. + public static T Dot(this Vector3D left, Vector3D right) + where T : INumberBase => + left.X * right.X + left.Y * right.Y + left.Z * right.Z; + + /// Reflects a vector over a normal vector. + public static Vector3D Reflect(Vector3D vector, Vector3D normal) + where T : INumberBase + { + T dot = vector.Dot(normal); + return vector - (normal * (dot + dot)); + } + + /// Normalizes a vector. + public static Vector3D Normalize(this Vector3D vector) + where T : IRootFunctions + { + T length = vector.Length; + return length != T.Zero ? vector / length : Vector3D.Zero; + } + + /// Returns the Euclidean distance between the two given points. + /// The first point. + /// The second point. + /// The distance. + public static T Distance(Vector3D value1, Vector3D value2) + where T : IRootFunctions => + T.Sqrt(DistanceSquared(value1, value2)); + + /// Returns the Euclidean distance squared between the two given points. + /// The first point. + /// The second point. + /// The distance squared. + public static T DistanceSquared(Vector3D value1, Vector3D value2) + where T : INumberBase + { + var difference = value1 - value2; + return Dot(difference, difference); + } + + /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). + public static Vector3D LerpClamped(Vector3D a, Vector3D b, T amount) + where T : IFloatingPointIeee754 => + Lerp(a, b, T.Clamp(amount, T.Zero, T.One)); + + /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). + public static Vector3D LerpClamped(Vector3D a, Vector3D b, Vector3D amount) + where T : IFloatingPointIeee754 => + new(T.Lerp(a.X, b.X, T.Clamp(amount.X, T.Zero, T.One)), + T.Lerp(a.Y, b.Y, T.Clamp(amount.Y, T.Zero, T.One)), + T.Lerp(a.Z, b.Z, T.Clamp(amount.Z, T.Zero, T.One))); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static (Vector3D Sin, Vector3D Cos) SinCos(this Vector3D x) + where T : ITrigonometricFunctions => + (new(T.Sin(x.X), T.Sin(x.Y), T.Sin(x.Z)), new(T.Cos(x.X), T.Cos(x.Y), T.Cos(x.Z))); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static (Vector3D SinPi, Vector3D CosPi) SinCosPi(this Vector3D x) + where T : ITrigonometricFunctions => + (new(T.SinPi(x.X), T.SinPi(x.Y), T.SinPi(x.Z)), new(T.CosPi(x.X), T.CosPi(x.Y), T.CosPi(x.Z))); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static (Vector3D Quotient, Vector3D Remainder) DivRem(Vector3D left, Vector3D right) + where T : IBinaryInteger + { + var (qX, rX) = T.DivRem(left.X, right.X); + var (qY, rY) = T.DivRem(left.Y, right.Y); + var (qZ, rZ) = T.DivRem(left.Z, right.Z); + return (new Vector3D(qX, qY, qZ), new Vector3D(rX, rY, rZ)); + } + + /// Multiplies a vector by a scalar value. + /// The source vector. + /// The scaling factor. + /// The scaled vector. + public static Vector3D Multiply(Vector3D left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a vector by a scalar value. + /// The scaling factor. + /// The source vector. + /// The scaled vector. + public static Vector3D Multiply(T left, Vector3D right) + where T : INumberBase => + left * right; + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Sign(this Vector3D value) + where TSelf : INumber => + new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D Max(this Vector3D x, Vector3D y) + where TSelf : INumber => + new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D Max(this Vector3D x, TSelf y) + where TSelf : INumber => + new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D MaxNumber(this Vector3D x, Vector3D y) + where TSelf : INumber => + new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D MaxNumber(this Vector3D x, TSelf y) + where TSelf : INumber => + new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D Min(this Vector3D x, Vector3D y) + where TSelf : INumber => + new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D Min(this Vector3D x, TSelf y) + where TSelf : INumber => + new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D MinNumber(this Vector3D x, Vector3D y) + where TSelf : INumber => + new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D MinNumber(this Vector3D x, TSelf y) + where TSelf : INumber => + new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D Clamp(this Vector3D value, Vector3D min, Vector3D max) + where TSelf : INumber => + new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector3D Clamp(this Vector3D value, TSelf min, TSelf max) + where TSelf : INumber => + new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D CopySign(this Vector3D value, Vector3D sign) + where TSelf : INumber => + new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D CopySign(this Vector3D value, TSelf sign) + where TSelf : INumber => + new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Abs(this Vector3D value) + where TSelf : INumberBase => + new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D MaxMagnitude(this Vector3D x, Vector3D y) + where TSelf : INumberBase => + new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D MaxMagnitudeNumber(this Vector3D x, Vector3D y) + where TSelf : INumberBase => + new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D MinMagnitude(this Vector3D x, Vector3D y) + where TSelf : INumberBase => + new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D MinMagnitudeNumber(this Vector3D x, Vector3D y) + where TSelf : INumberBase => + new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D PopCount(this Vector3D value) + where TSelf : IBinaryInteger => + new(TSelf.PopCount(value.X), TSelf.PopCount(value.Y), TSelf.PopCount(value.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D TrailingZeroCount(this Vector3D value) + where TSelf : IBinaryInteger => + new(TSelf.TrailingZeroCount(value.X), TSelf.TrailingZeroCount(value.Y), TSelf.TrailingZeroCount(value.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Ceiling(this Vector3D x) + where TSelf : IFloatingPoint => + new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y), TSelf.Ceiling(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Floor(this Vector3D x) + where TSelf : IFloatingPoint => + new(TSelf.Floor(x.X), TSelf.Floor(x.Y), TSelf.Floor(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Round(this Vector3D x) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X), TSelf.Round(x.Y), TSelf.Round(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D Round(this Vector3D x, int digits) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, digits), TSelf.Round(x.Y, digits), TSelf.Round(x.Z, digits)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D Round(this Vector3D x, MidpointRounding mode) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, mode), TSelf.Round(x.Y, mode), TSelf.Round(x.Z, mode)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector3D Round(this Vector3D x, int digits, MidpointRounding mode) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode), TSelf.Round(x.Z, digits, mode)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Truncate(this Vector3D x) + where TSelf : IFloatingPoint => + new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y), TSelf.Truncate(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D Atan2(this Vector3D y, Vector3D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y), TSelf.Atan2(y.Z, x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D Atan2Pi(this Vector3D y, Vector3D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y), TSelf.Atan2Pi(y.Z, x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D Lerp(this Vector3D value1, Vector3D value2, TSelf amount) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount), TSelf.Lerp(value1.Z, value2.Z, amount)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D BitDecrement(this Vector3D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y), TSelf.BitDecrement(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D BitIncrement(this Vector3D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y), TSelf.BitIncrement(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D FusedMultiplyAdd(this Vector3D left, Vector3D right, Vector3D addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D FusedMultiplyAdd(this Vector3D left, Vector3D right, TSelf addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right.X, addend), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A vector whose members will be provided for . + public static Vector3D FusedMultiplyAdd(this Vector3D left, TSelf right, Vector3D addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right, addend.X), TSelf.FusedMultiplyAdd(left.Y, right, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right, addend.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector3D FusedMultiplyAdd(this Vector3D left, TSelf right, TSelf addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend), TSelf.FusedMultiplyAdd(left.Z, right, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D Ieee754Remainder(this Vector3D left, Vector3D right) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y), TSelf.Ieee754Remainder(left.Z, right.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D Ieee754Remainder(this Vector3D left, TSelf right) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right), TSelf.Ieee754Remainder(left.Z, right)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D ILogB(this Vector3D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y), TSelf.ILogB(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D ReciprocalEstimate(this Vector3D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y), TSelf.ReciprocalEstimate(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D ReciprocalSqrtEstimate(this Vector3D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y), TSelf.ReciprocalSqrtEstimate(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D ScaleB(this Vector3D x, Vector3D n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y), TSelf.ScaleB(x.Z, n.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D ScaleB(this Vector3D x, int n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n), TSelf.ScaleB(x.Z, n)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D Pow(this Vector3D x, Vector3D y) + where TSelf : IPowerFunctions => + new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y), TSelf.Pow(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D Pow(this Vector3D x, TSelf y) + where TSelf : IPowerFunctions => + new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y), TSelf.Pow(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Cbrt(this Vector3D x) + where TSelf : IRootFunctions => + new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y), TSelf.Cbrt(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Sqrt(this Vector3D x) + where TSelf : IRootFunctions => + new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y), TSelf.Sqrt(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D RootN(this Vector3D x, int n) + where TSelf : IRootFunctions => + new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n), TSelf.RootN(x.Z, n)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D RootN(this Vector3D x, Vector3D n) + where TSelf : IRootFunctions => + new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y), TSelf.RootN(x.Z, n.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D Hypot(this Vector3D x, Vector3D y) + where TSelf : IRootFunctions => + new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y), TSelf.Hypot(x.Z, y.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D Hypot(this Vector3D x, TSelf y) + where TSelf : IRootFunctions => + new(TSelf.Hypot(x.X, y), TSelf.Hypot(x.Y, y), TSelf.Hypot(x.Z, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Log(this Vector3D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D Log(this Vector3D x, Vector3D newBase) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D Log(this Vector3D x, TSelf newBase) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase), TSelf.Log(x.Z, newBase)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D LogP1(this Vector3D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Log2(this Vector3D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Log2P1(this Vector3D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Log10(this Vector3D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Log10P1(this Vector3D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Exp(this Vector3D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D ExpM1(this Vector3D x) + where TSelf : IExponentialFunctions => + new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Exp2(this Vector3D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Exp2M1(this Vector3D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Exp10(this Vector3D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Exp10M1(this Vector3D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Acos(this Vector3D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Acos(x.X), TSelf.Acos(x.Y), TSelf.Acos(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D AcosPi(this Vector3D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y), TSelf.AcosPi(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Asin(this Vector3D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Asin(x.X), TSelf.Asin(x.Y), TSelf.Asin(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D AsinPi(this Vector3D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y), TSelf.AsinPi(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Atan(this Vector3D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Atan(x.X), TSelf.Atan(x.Y), TSelf.Atan(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D AtanPi(this Vector3D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y), TSelf.AtanPi(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Cos(this Vector3D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Cos(x.X), TSelf.Cos(x.Y), TSelf.Cos(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D CosPi(this Vector3D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y), TSelf.CosPi(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Sin(this Vector3D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Sin(x.X), TSelf.Sin(x.Y), TSelf.Sin(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D SinPi(this Vector3D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y), TSelf.SinPi(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Tan(this Vector3D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Tan(x.X), TSelf.Tan(x.Y), TSelf.Tan(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D TanPi(this Vector3D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y), TSelf.TanPi(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D DegreesToRadians(this Vector3D degrees) + where TSelf : ITrigonometricFunctions => + new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y), TSelf.DegreesToRadians(degrees.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D RadiansToDegrees(this Vector3D radians) + where TSelf : ITrigonometricFunctions => + new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y), TSelf.RadiansToDegrees(radians.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Acosh(this Vector3D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y), TSelf.Acosh(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Asinh(this Vector3D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y), TSelf.Asinh(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Atanh(this Vector3D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y), TSelf.Atanh(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Cosh(this Vector3D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y), TSelf.Cosh(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Sinh(this Vector3D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y), TSelf.Sinh(x.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector3D Tanh(this Vector3D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y), TSelf.Tanh(x.Z)); + } +} diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index 6fd81a1aa8..c18f9eee84 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -652,687 +652,4 @@ public static explicit operator Vector3D(Vector3D from) => public static explicit operator checked Vector3D(Vector3D from) => Vector3D.CreateChecked(from); } - - /// - /// Methods for working with . - /// - public static partial class Vector3D - { - /// Extensions for vectors with elements implementing . - extension(Vector3D vector) - where T : IRootFunctions - { - /// Gets the length of the vector. - public T Length => T.Sqrt(vector.LengthSquared); - } - - /// Extensions for vectors with elements implementing . - extension(Vector3D vector) - where T : INumberBase - { - /// Gets the length squared of the vector. - public T LengthSquared => Vector3D.Dot(vector, vector); - } - - /// Desconstructs a vector into its components. - /// The vector to deconstruct. - /// The X component. - /// The Y component. - /// The Z component. - public static void Deconstruct(this Vector3D vector, out T x, out T y, out T z) - where T : INumberBase - { - x = vector.X; - y = vector.Y; - z = vector.Z; - } - - /// Computes the dot product of two vectors. - public static T Dot(this Vector3D left, Vector3D right) - where T : INumberBase => - left.X * right.X + left.Y * right.Y + left.Z * right.Z; - - /// Reflects a vector over a normal vector. - public static Vector3D Reflect(Vector3D vector, Vector3D normal) - where T : INumberBase - { - T dot = vector.Dot(normal); - return vector - (normal * (dot + dot)); - } - - /// Normalizes a vector. - public static Vector3D Normalize(this Vector3D vector) - where T : IRootFunctions - { - T length = vector.Length; - return length != T.Zero ? vector / length : Vector3D.Zero; - } - - /// Returns the Euclidean distance between the two given points. - /// The first point. - /// The second point. - /// The distance. - public static T Distance(Vector3D value1, Vector3D value2) - where T : IRootFunctions => - T.Sqrt(DistanceSquared(value1, value2)); - - /// Returns the Euclidean distance squared between the two given points. - /// The first point. - /// The second point. - /// The distance squared. - public static T DistanceSquared(Vector3D value1, Vector3D value2) - where T : INumberBase - { - var difference = value1 - value2; - return Dot(difference, difference); - } - - /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). - public static Vector3D LerpClamped(Vector3D a, Vector3D b, T amount) - where T : IFloatingPointIeee754 => - Lerp(a, b, T.Clamp(amount, T.Zero, T.One)); - - /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). - public static Vector3D LerpClamped(Vector3D a, Vector3D b, Vector3D amount) - where T : IFloatingPointIeee754 => - new(T.Lerp(a.X, b.X, T.Clamp(amount.X, T.Zero, T.One)), - T.Lerp(a.Y, b.Y, T.Clamp(amount.Y, T.Zero, T.One)), - T.Lerp(a.Z, b.Z, T.Clamp(amount.Z, T.Zero, T.One))); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static (Vector3D Sin, Vector3D Cos) SinCos(this Vector3D x) - where T : ITrigonometricFunctions => - (new(T.Sin(x.X), T.Sin(x.Y), T.Sin(x.Z)), new(T.Cos(x.X), T.Cos(x.Y), T.Cos(x.Z))); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static (Vector3D SinPi, Vector3D CosPi) SinCosPi(this Vector3D x) - where T : ITrigonometricFunctions => - (new(T.SinPi(x.X), T.SinPi(x.Y), T.SinPi(x.Z)), new(T.CosPi(x.X), T.CosPi(x.Y), T.CosPi(x.Z))); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static (Vector3D Quotient, Vector3D Remainder) DivRem(Vector3D left, Vector3D right) - where T : IBinaryInteger - { - var (qX, rX) = T.DivRem(left.X, right.X); - var (qY, rY) = T.DivRem(left.Y, right.Y); - var (qZ, rZ) = T.DivRem(left.Z, right.Z); - return (new Vector3D(qX, qY, qZ), new Vector3D(rX, rY, rZ)); - } - - /// Multiplies a vector by a scalar value. - /// The source vector. - /// The scaling factor. - /// The scaled vector. - public static Vector3D Multiply(Vector3D left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a vector by a scalar value. - /// The scaling factor. - /// The source vector. - /// The scaled vector. - public static Vector3D Multiply(T left, Vector3D right) - where T : INumberBase => - left * right; - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Sign(this Vector3D value) - where TSelf : INumber => - new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D Max(this Vector3D x, Vector3D y) - where TSelf : INumber => - new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D Max(this Vector3D x, TSelf y) - where TSelf : INumber => - new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D MaxNumber(this Vector3D x, Vector3D y) - where TSelf : INumber => - new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D MaxNumber(this Vector3D x, TSelf y) - where TSelf : INumber => - new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D Min(this Vector3D x, Vector3D y) - where TSelf : INumber => - new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D Min(this Vector3D x, TSelf y) - where TSelf : INumber => - new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D MinNumber(this Vector3D x, Vector3D y) - where TSelf : INumber => - new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D MinNumber(this Vector3D x, TSelf y) - where TSelf : INumber => - new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D Clamp(this Vector3D value, Vector3D min, Vector3D max) - where TSelf : INumber => - new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A single value provided for . - public static Vector3D Clamp(this Vector3D value, TSelf min, TSelf max) - where TSelf : INumber => - new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D CopySign(this Vector3D value, Vector3D sign) - where TSelf : INumber => - new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D CopySign(this Vector3D value, TSelf sign) - where TSelf : INumber => - new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Abs(this Vector3D value) - where TSelf : INumberBase => - new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D MaxMagnitude(this Vector3D x, Vector3D y) - where TSelf : INumberBase => - new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D MaxMagnitudeNumber(this Vector3D x, Vector3D y) - where TSelf : INumberBase => - new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D MinMagnitude(this Vector3D x, Vector3D y) - where TSelf : INumberBase => - new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D MinMagnitudeNumber(this Vector3D x, Vector3D y) - where TSelf : INumberBase => - new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D PopCount(this Vector3D value) - where TSelf : IBinaryInteger => - new(TSelf.PopCount(value.X), TSelf.PopCount(value.Y), TSelf.PopCount(value.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D TrailingZeroCount(this Vector3D value) - where TSelf : IBinaryInteger => - new(TSelf.TrailingZeroCount(value.X), TSelf.TrailingZeroCount(value.Y), TSelf.TrailingZeroCount(value.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Ceiling(this Vector3D x) - where TSelf : IFloatingPoint => - new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y), TSelf.Ceiling(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Floor(this Vector3D x) - where TSelf : IFloatingPoint => - new(TSelf.Floor(x.X), TSelf.Floor(x.Y), TSelf.Floor(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Round(this Vector3D x) - where TSelf : IFloatingPoint => - new(TSelf.Round(x.X), TSelf.Round(x.Y), TSelf.Round(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D Round(this Vector3D x, int digits) - where TSelf : IFloatingPoint => - new(TSelf.Round(x.X, digits), TSelf.Round(x.Y, digits), TSelf.Round(x.Z, digits)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D Round(this Vector3D x, MidpointRounding mode) - where TSelf : IFloatingPoint => - new(TSelf.Round(x.X, mode), TSelf.Round(x.Y, mode), TSelf.Round(x.Z, mode)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A single value provided for . - public static Vector3D Round(this Vector3D x, int digits, MidpointRounding mode) - where TSelf : IFloatingPoint => - new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode), TSelf.Round(x.Z, digits, mode)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Truncate(this Vector3D x) - where TSelf : IFloatingPoint => - new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y), TSelf.Truncate(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D Atan2(this Vector3D y, Vector3D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y), TSelf.Atan2(y.Z, x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D Atan2Pi(this Vector3D y, Vector3D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y), TSelf.Atan2Pi(y.Z, x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D Lerp(this Vector3D value1, Vector3D value2, TSelf amount) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount), TSelf.Lerp(value1.Z, value2.Z, amount)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D BitDecrement(this Vector3D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y), TSelf.BitDecrement(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D BitIncrement(this Vector3D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y), TSelf.BitIncrement(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D FusedMultiplyAdd(this Vector3D left, Vector3D right, Vector3D addend) - where TSelf : IFloatingPointIeee754 => - new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D FusedMultiplyAdd(this Vector3D left, Vector3D right, TSelf addend) - where TSelf : IFloatingPointIeee754 => - new(TSelf.FusedMultiplyAdd(left.X, right.X, addend), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A vector whose members will be provided for . - public static Vector3D FusedMultiplyAdd(this Vector3D left, TSelf right, Vector3D addend) - where TSelf : IFloatingPointIeee754 => - new(TSelf.FusedMultiplyAdd(left.X, right, addend.X), TSelf.FusedMultiplyAdd(left.Y, right, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right, addend.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A single value provided for . - public static Vector3D FusedMultiplyAdd(this Vector3D left, TSelf right, TSelf addend) - where TSelf : IFloatingPointIeee754 => - new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend), TSelf.FusedMultiplyAdd(left.Z, right, addend)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D Ieee754Remainder(this Vector3D left, Vector3D right) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y), TSelf.Ieee754Remainder(left.Z, right.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D Ieee754Remainder(this Vector3D left, TSelf right) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right), TSelf.Ieee754Remainder(left.Z, right)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D ILogB(this Vector3D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y), TSelf.ILogB(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D ReciprocalEstimate(this Vector3D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y), TSelf.ReciprocalEstimate(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D ReciprocalSqrtEstimate(this Vector3D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y), TSelf.ReciprocalSqrtEstimate(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D ScaleB(this Vector3D x, Vector3D n) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y), TSelf.ScaleB(x.Z, n.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D ScaleB(this Vector3D x, int n) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n), TSelf.ScaleB(x.Z, n)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D Pow(this Vector3D x, Vector3D y) - where TSelf : IPowerFunctions => - new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y), TSelf.Pow(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D Pow(this Vector3D x, TSelf y) - where TSelf : IPowerFunctions => - new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y), TSelf.Pow(x.Z, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Cbrt(this Vector3D x) - where TSelf : IRootFunctions => - new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y), TSelf.Cbrt(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Sqrt(this Vector3D x) - where TSelf : IRootFunctions => - new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y), TSelf.Sqrt(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D RootN(this Vector3D x, int n) - where TSelf : IRootFunctions => - new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n), TSelf.RootN(x.Z, n)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D RootN(this Vector3D x, Vector3D n) - where TSelf : IRootFunctions => - new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y), TSelf.RootN(x.Z, n.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D Hypot(this Vector3D x, Vector3D y) - where TSelf : IRootFunctions => - new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y), TSelf.Hypot(x.Z, y.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D Hypot(this Vector3D x, TSelf y) - where TSelf : IRootFunctions => - new(TSelf.Hypot(x.X, y), TSelf.Hypot(x.Y, y), TSelf.Hypot(x.Z, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Log(this Vector3D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector3D Log(this Vector3D x, Vector3D newBase) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector3D Log(this Vector3D x, TSelf newBase) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase), TSelf.Log(x.Z, newBase)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D LogP1(this Vector3D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Log2(this Vector3D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Log2P1(this Vector3D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Log10(this Vector3D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Log10P1(this Vector3D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Exp(this Vector3D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D ExpM1(this Vector3D x) - where TSelf : IExponentialFunctions => - new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Exp2(this Vector3D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Exp2M1(this Vector3D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Exp10(this Vector3D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Exp10M1(this Vector3D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Acos(this Vector3D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Acos(x.X), TSelf.Acos(x.Y), TSelf.Acos(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D AcosPi(this Vector3D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y), TSelf.AcosPi(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Asin(this Vector3D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Asin(x.X), TSelf.Asin(x.Y), TSelf.Asin(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D AsinPi(this Vector3D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y), TSelf.AsinPi(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Atan(this Vector3D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Atan(x.X), TSelf.Atan(x.Y), TSelf.Atan(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D AtanPi(this Vector3D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y), TSelf.AtanPi(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Cos(this Vector3D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Cos(x.X), TSelf.Cos(x.Y), TSelf.Cos(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D CosPi(this Vector3D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y), TSelf.CosPi(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Sin(this Vector3D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Sin(x.X), TSelf.Sin(x.Y), TSelf.Sin(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D SinPi(this Vector3D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y), TSelf.SinPi(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Tan(this Vector3D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Tan(x.X), TSelf.Tan(x.Y), TSelf.Tan(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D TanPi(this Vector3D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y), TSelf.TanPi(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D DegreesToRadians(this Vector3D degrees) - where TSelf : ITrigonometricFunctions => - new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y), TSelf.DegreesToRadians(degrees.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D RadiansToDegrees(this Vector3D radians) - where TSelf : ITrigonometricFunctions => - new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y), TSelf.RadiansToDegrees(radians.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Acosh(this Vector3D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y), TSelf.Acosh(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Asinh(this Vector3D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y), TSelf.Asinh(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Atanh(this Vector3D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y), TSelf.Atanh(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Cosh(this Vector3D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y), TSelf.Cosh(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Sinh(this Vector3D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y), TSelf.Sinh(x.Z)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector3D Tanh(this Vector3D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y), TSelf.Tanh(x.Z)); - } } diff --git a/sources/Maths/Maths/Vector4D.Ops.gen.cs b/sources/Maths/Maths/Vector4D.Ops.gen.cs new file mode 100644 index 0000000000..aa844486f6 --- /dev/null +++ b/sources/Maths/Maths/Vector4D.Ops.gen.cs @@ -0,0 +1,694 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Silk.NET.Maths +{ + using System.Numerics; + + /// + /// Methods for working with . + /// + public static partial class Vector4D + { + /// Extensions for vectors with elements implementing . + extension(Vector4D vector) + where T : IRootFunctions + { + /// Gets the length of the vector. + public T Length => T.Sqrt(vector.LengthSquared); + } + + /// Extensions for vectors with elements implementing . + extension(Vector4D vector) + where T : INumberBase + { + /// Gets the length squared of the vector. + public T LengthSquared => Vector4D.Dot(vector, vector); + } + + /// Desconstructs a vector into its components. + /// The vector to deconstruct. + /// The X component. + /// The Y component. + /// The Z component. + /// The W component. + public static void Deconstruct(this Vector4D vector, out T x, out T y, out T z, out T w) + where T : INumberBase + { + x = vector.X; + y = vector.Y; + z = vector.Z; + w = vector.W; + } + + /// Computes the dot product of two vectors. + public static T Dot(this Vector4D left, Vector4D right) + where T : INumberBase => + left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W; + + /// Reflects a vector over a normal vector. + public static Vector4D Reflect(Vector4D vector, Vector4D normal) + where T : INumberBase + { + T dot = vector.Dot(normal); + return vector - (normal * (dot + dot)); + } + + /// Normalizes a vector. + public static Vector4D Normalize(this Vector4D vector) + where T : IRootFunctions + { + T length = vector.Length; + return length != T.Zero ? vector / length : Vector4D.Zero; + } + + /// Returns the Euclidean distance between the two given points. + /// The first point. + /// The second point. + /// The distance. + public static T Distance(Vector4D value1, Vector4D value2) + where T : IRootFunctions => + T.Sqrt(DistanceSquared(value1, value2)); + + /// Returns the Euclidean distance squared between the two given points. + /// The first point. + /// The second point. + /// The distance squared. + public static T DistanceSquared(Vector4D value1, Vector4D value2) + where T : INumberBase + { + var difference = value1 - value2; + return Dot(difference, difference); + } + + /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). + public static Vector4D LerpClamped(Vector4D a, Vector4D b, T amount) + where T : IFloatingPointIeee754 => + Lerp(a, b, T.Clamp(amount, T.Zero, T.One)); + + /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). + public static Vector4D LerpClamped(Vector4D a, Vector4D b, Vector4D amount) + where T : IFloatingPointIeee754 => + new(T.Lerp(a.X, b.X, T.Clamp(amount.X, T.Zero, T.One)), + T.Lerp(a.Y, b.Y, T.Clamp(amount.Y, T.Zero, T.One)), + T.Lerp(a.Z, b.Z, T.Clamp(amount.Z, T.Zero, T.One)), + T.Lerp(a.W, b.W, T.Clamp(amount.W, T.Zero, T.One))); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static (Vector4D Sin, Vector4D Cos) SinCos(this Vector4D x) + where T : ITrigonometricFunctions => + (new(T.Sin(x.X), T.Sin(x.Y), T.Sin(x.Z), T.Sin(x.W)), new(T.Cos(x.X), T.Cos(x.Y), T.Cos(x.Z), T.Cos(x.W))); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static (Vector4D SinPi, Vector4D CosPi) SinCosPi(this Vector4D x) + where T : ITrigonometricFunctions => + (new(T.SinPi(x.X), T.SinPi(x.Y), T.SinPi(x.Z), T.SinPi(x.W)), new(T.CosPi(x.X), T.CosPi(x.Y), T.CosPi(x.Z), T.CosPi(x.W))); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static (Vector4D Quotient, Vector4D Remainder) DivRem(Vector4D left, Vector4D right) + where T : IBinaryInteger + { + var (qX, rX) = T.DivRem(left.X, right.X); + var (qY, rY) = T.DivRem(left.Y, right.Y); + var (qZ, rZ) = T.DivRem(left.Z, right.Z); + var (qW, rW) = T.DivRem(left.W, right.W); + return (new Vector4D(qX, qY, qZ, qW), new Vector4D(rX, rY, rZ, rW)); + } + + /// Multiplies a vector by a scalar value. + /// The source vector. + /// The scaling factor. + /// The scaled vector. + public static Vector4D Multiply(Vector4D left, T right) + where T : INumberBase => + left * right; + + /// Multiplies a vector by a scalar value. + /// The scaling factor. + /// The source vector. + /// The scaled vector. + public static Vector4D Multiply(T left, Vector4D right) + where T : INumberBase => + left * right; + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Sign(this Vector4D value) + where TSelf : INumber => + new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z), TSelf.Sign(value.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D Max(this Vector4D x, Vector4D y) + where TSelf : INumber => + new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z), TSelf.Max(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D Max(this Vector4D x, TSelf y) + where TSelf : INumber => + new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y), TSelf.Max(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D MaxNumber(this Vector4D x, Vector4D y) + where TSelf : INumber => + new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z), TSelf.MaxNumber(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D MaxNumber(this Vector4D x, TSelf y) + where TSelf : INumber => + new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y), TSelf.MaxNumber(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D Min(this Vector4D x, Vector4D y) + where TSelf : INumber => + new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z), TSelf.Min(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D Min(this Vector4D x, TSelf y) + where TSelf : INumber => + new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y), TSelf.Min(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D MinNumber(this Vector4D x, Vector4D y) + where TSelf : INumber => + new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z), TSelf.MinNumber(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D MinNumber(this Vector4D x, TSelf y) + where TSelf : INumber => + new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y), TSelf.MinNumber(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D Clamp(this Vector4D value, Vector4D min, Vector4D max) + where TSelf : INumber => + new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z), TSelf.Clamp(value.W, min.W, max.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector4D Clamp(this Vector4D value, TSelf min, TSelf max) + where TSelf : INumber => + new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max), TSelf.Clamp(value.W, min, max)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D CopySign(this Vector4D value, Vector4D sign) + where TSelf : INumber => + new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z), TSelf.CopySign(value.W, sign.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D CopySign(this Vector4D value, TSelf sign) + where TSelf : INumber => + new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign), TSelf.CopySign(value.W, sign)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Abs(this Vector4D value) + where TSelf : INumberBase => + new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z), TSelf.Abs(value.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D MaxMagnitude(this Vector4D x, Vector4D y) + where TSelf : INumberBase => + new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z), TSelf.MaxMagnitude(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D MaxMagnitudeNumber(this Vector4D x, Vector4D y) + where TSelf : INumberBase => + new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z), TSelf.MaxMagnitudeNumber(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D MinMagnitude(this Vector4D x, Vector4D y) + where TSelf : INumberBase => + new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z), TSelf.MinMagnitude(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D MinMagnitudeNumber(this Vector4D x, Vector4D y) + where TSelf : INumberBase => + new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z), TSelf.MinMagnitudeNumber(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D PopCount(this Vector4D value) + where TSelf : IBinaryInteger => + new(TSelf.PopCount(value.X), TSelf.PopCount(value.Y), TSelf.PopCount(value.Z), TSelf.PopCount(value.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D TrailingZeroCount(this Vector4D value) + where TSelf : IBinaryInteger => + new(TSelf.TrailingZeroCount(value.X), TSelf.TrailingZeroCount(value.Y), TSelf.TrailingZeroCount(value.Z), TSelf.TrailingZeroCount(value.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Ceiling(this Vector4D x) + where TSelf : IFloatingPoint => + new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y), TSelf.Ceiling(x.Z), TSelf.Ceiling(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Floor(this Vector4D x) + where TSelf : IFloatingPoint => + new(TSelf.Floor(x.X), TSelf.Floor(x.Y), TSelf.Floor(x.Z), TSelf.Floor(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Round(this Vector4D x) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X), TSelf.Round(x.Y), TSelf.Round(x.Z), TSelf.Round(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D Round(this Vector4D x, int digits) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, digits), TSelf.Round(x.Y, digits), TSelf.Round(x.Z, digits), TSelf.Round(x.W, digits)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D Round(this Vector4D x, MidpointRounding mode) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, mode), TSelf.Round(x.Y, mode), TSelf.Round(x.Z, mode), TSelf.Round(x.W, mode)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector4D Round(this Vector4D x, int digits, MidpointRounding mode) + where TSelf : IFloatingPoint => + new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode), TSelf.Round(x.Z, digits, mode), TSelf.Round(x.W, digits, mode)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Truncate(this Vector4D x) + where TSelf : IFloatingPoint => + new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y), TSelf.Truncate(x.Z), TSelf.Truncate(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D Atan2(this Vector4D y, Vector4D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y), TSelf.Atan2(y.Z, x.Z), TSelf.Atan2(y.W, x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D Atan2Pi(this Vector4D y, Vector4D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y), TSelf.Atan2Pi(y.Z, x.Z), TSelf.Atan2Pi(y.W, x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D Lerp(this Vector4D value1, Vector4D value2, TSelf amount) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount), TSelf.Lerp(value1.Z, value2.Z, amount), TSelf.Lerp(value1.W, value2.W, amount)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D BitDecrement(this Vector4D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y), TSelf.BitDecrement(x.Z), TSelf.BitDecrement(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D BitIncrement(this Vector4D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y), TSelf.BitIncrement(x.Z), TSelf.BitIncrement(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D FusedMultiplyAdd(this Vector4D left, Vector4D right, Vector4D addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend.Z), TSelf.FusedMultiplyAdd(left.W, right.W, addend.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D FusedMultiplyAdd(this Vector4D left, Vector4D right, TSelf addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right.X, addend), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend), TSelf.FusedMultiplyAdd(left.W, right.W, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A vector whose members will be provided for . + public static Vector4D FusedMultiplyAdd(this Vector4D left, TSelf right, Vector4D addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right, addend.X), TSelf.FusedMultiplyAdd(left.Y, right, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right, addend.Z), TSelf.FusedMultiplyAdd(left.W, right, addend.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector4D FusedMultiplyAdd(this Vector4D left, TSelf right, TSelf addend) + where TSelf : IFloatingPointIeee754 => + new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend), TSelf.FusedMultiplyAdd(left.Z, right, addend), TSelf.FusedMultiplyAdd(left.W, right, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D Ieee754Remainder(this Vector4D left, Vector4D right) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y), TSelf.Ieee754Remainder(left.Z, right.Z), TSelf.Ieee754Remainder(left.W, right.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D Ieee754Remainder(this Vector4D left, TSelf right) + where TSelf : IFloatingPointIeee754 => + new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right), TSelf.Ieee754Remainder(left.Z, right), TSelf.Ieee754Remainder(left.W, right)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D ILogB(this Vector4D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y), TSelf.ILogB(x.Z), TSelf.ILogB(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D ReciprocalEstimate(this Vector4D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y), TSelf.ReciprocalEstimate(x.Z), TSelf.ReciprocalEstimate(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D ReciprocalSqrtEstimate(this Vector4D x) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y), TSelf.ReciprocalSqrtEstimate(x.Z), TSelf.ReciprocalSqrtEstimate(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D ScaleB(this Vector4D x, Vector4D n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y), TSelf.ScaleB(x.Z, n.Z), TSelf.ScaleB(x.W, n.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D ScaleB(this Vector4D x, int n) + where TSelf : IFloatingPointIeee754 => + new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n), TSelf.ScaleB(x.Z, n), TSelf.ScaleB(x.W, n)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D Pow(this Vector4D x, Vector4D y) + where TSelf : IPowerFunctions => + new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y), TSelf.Pow(x.Z, y.Z), TSelf.Pow(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D Pow(this Vector4D x, TSelf y) + where TSelf : IPowerFunctions => + new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y), TSelf.Pow(x.Z, y), TSelf.Pow(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Cbrt(this Vector4D x) + where TSelf : IRootFunctions => + new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y), TSelf.Cbrt(x.Z), TSelf.Cbrt(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Sqrt(this Vector4D x) + where TSelf : IRootFunctions => + new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y), TSelf.Sqrt(x.Z), TSelf.Sqrt(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D RootN(this Vector4D x, int n) + where TSelf : IRootFunctions => + new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n), TSelf.RootN(x.Z, n), TSelf.RootN(x.W, n)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D RootN(this Vector4D x, Vector4D n) + where TSelf : IRootFunctions => + new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y), TSelf.RootN(x.Z, n.Z), TSelf.RootN(x.W, n.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D Hypot(this Vector4D x, Vector4D y) + where TSelf : IRootFunctions => + new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y), TSelf.Hypot(x.Z, y.Z), TSelf.Hypot(x.W, y.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D Hypot(this Vector4D x, TSelf y) + where TSelf : IRootFunctions => + new(TSelf.Hypot(x.X, y), TSelf.Hypot(x.Y, y), TSelf.Hypot(x.Z, y), TSelf.Hypot(x.W, y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Log(this Vector4D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z), TSelf.Log(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D Log(this Vector4D x, Vector4D newBase) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z), TSelf.Log(x.W, newBase.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D Log(this Vector4D x, TSelf newBase) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase), TSelf.Log(x.Z, newBase), TSelf.Log(x.W, newBase)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D LogP1(this Vector4D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z), TSelf.LogP1(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Log2(this Vector4D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z), TSelf.Log2(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Log2P1(this Vector4D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z), TSelf.Log2P1(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Log10(this Vector4D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z), TSelf.Log10(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Log10P1(this Vector4D x) + where TSelf : ILogarithmicFunctions => + new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z), TSelf.Log10P1(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Exp(this Vector4D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z), TSelf.Exp(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D ExpM1(this Vector4D x) + where TSelf : IExponentialFunctions => + new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z), TSelf.ExpM1(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Exp2(this Vector4D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z), TSelf.Exp2(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Exp2M1(this Vector4D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z), TSelf.Exp2M1(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Exp10(this Vector4D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z), TSelf.Exp10(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Exp10M1(this Vector4D x) + where TSelf : IExponentialFunctions => + new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z), TSelf.Exp10M1(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Acos(this Vector4D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Acos(x.X), TSelf.Acos(x.Y), TSelf.Acos(x.Z), TSelf.Acos(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D AcosPi(this Vector4D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y), TSelf.AcosPi(x.Z), TSelf.AcosPi(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Asin(this Vector4D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Asin(x.X), TSelf.Asin(x.Y), TSelf.Asin(x.Z), TSelf.Asin(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D AsinPi(this Vector4D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y), TSelf.AsinPi(x.Z), TSelf.AsinPi(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Atan(this Vector4D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Atan(x.X), TSelf.Atan(x.Y), TSelf.Atan(x.Z), TSelf.Atan(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D AtanPi(this Vector4D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y), TSelf.AtanPi(x.Z), TSelf.AtanPi(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Cos(this Vector4D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Cos(x.X), TSelf.Cos(x.Y), TSelf.Cos(x.Z), TSelf.Cos(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D CosPi(this Vector4D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y), TSelf.CosPi(x.Z), TSelf.CosPi(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Sin(this Vector4D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Sin(x.X), TSelf.Sin(x.Y), TSelf.Sin(x.Z), TSelf.Sin(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D SinPi(this Vector4D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y), TSelf.SinPi(x.Z), TSelf.SinPi(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Tan(this Vector4D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.Tan(x.X), TSelf.Tan(x.Y), TSelf.Tan(x.Z), TSelf.Tan(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D TanPi(this Vector4D x) + where TSelf : ITrigonometricFunctions => + new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y), TSelf.TanPi(x.Z), TSelf.TanPi(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D DegreesToRadians(this Vector4D degrees) + where TSelf : ITrigonometricFunctions => + new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y), TSelf.DegreesToRadians(degrees.Z), TSelf.DegreesToRadians(degrees.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D RadiansToDegrees(this Vector4D radians) + where TSelf : ITrigonometricFunctions => + new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y), TSelf.RadiansToDegrees(radians.Z), TSelf.RadiansToDegrees(radians.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Acosh(this Vector4D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y), TSelf.Acosh(x.Z), TSelf.Acosh(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Asinh(this Vector4D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y), TSelf.Asinh(x.Z), TSelf.Asinh(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Atanh(this Vector4D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y), TSelf.Atanh(x.Z), TSelf.Atanh(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Cosh(this Vector4D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y), TSelf.Cosh(x.Z), TSelf.Cosh(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Sinh(this Vector4D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y), TSelf.Sinh(x.Z), TSelf.Sinh(x.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + public static Vector4D Tanh(this Vector4D x) + where TSelf : IHyperbolicFunctions => + new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y), TSelf.Tanh(x.Z), TSelf.Tanh(x.W)); + } +} diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index 0b24eadbd0..c48ba74b50 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -689,691 +689,4 @@ public static explicit operator Vector4D(Vector4D from) => public static explicit operator checked Vector4D(Vector4D from) => Vector4D.CreateChecked(from); } - - /// - /// Methods for working with . - /// - public static partial class Vector4D - { - /// Extensions for vectors with elements implementing . - extension(Vector4D vector) - where T : IRootFunctions - { - /// Gets the length of the vector. - public T Length => T.Sqrt(vector.LengthSquared); - } - - /// Extensions for vectors with elements implementing . - extension(Vector4D vector) - where T : INumberBase - { - /// Gets the length squared of the vector. - public T LengthSquared => Vector4D.Dot(vector, vector); - } - - /// Desconstructs a vector into its components. - /// The vector to deconstruct. - /// The X component. - /// The Y component. - /// The Z component. - /// The W component. - public static void Deconstruct(this Vector4D vector, out T x, out T y, out T z, out T w) - where T : INumberBase - { - x = vector.X; - y = vector.Y; - z = vector.Z; - w = vector.W; - } - - /// Computes the dot product of two vectors. - public static T Dot(this Vector4D left, Vector4D right) - where T : INumberBase => - left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W; - - /// Reflects a vector over a normal vector. - public static Vector4D Reflect(Vector4D vector, Vector4D normal) - where T : INumberBase - { - T dot = vector.Dot(normal); - return vector - (normal * (dot + dot)); - } - - /// Normalizes a vector. - public static Vector4D Normalize(this Vector4D vector) - where T : IRootFunctions - { - T length = vector.Length; - return length != T.Zero ? vector / length : Vector4D.Zero; - } - - /// Returns the Euclidean distance between the two given points. - /// The first point. - /// The second point. - /// The distance. - public static T Distance(Vector4D value1, Vector4D value2) - where T : IRootFunctions => - T.Sqrt(DistanceSquared(value1, value2)); - - /// Returns the Euclidean distance squared between the two given points. - /// The first point. - /// The second point. - /// The distance squared. - public static T DistanceSquared(Vector4D value1, Vector4D value2) - where T : INumberBase - { - var difference = value1 - value2; - return Dot(difference, difference); - } - - /// Linearly interpolates between two vectors using a scalar t-value (clamped between 0 and 1). - public static Vector4D LerpClamped(Vector4D a, Vector4D b, T amount) - where T : IFloatingPointIeee754 => - Lerp(a, b, T.Clamp(amount, T.Zero, T.One)); - - /// Linearly interpolates between two vectors using a vector t-value (clamped between 0 and 1). - public static Vector4D LerpClamped(Vector4D a, Vector4D b, Vector4D amount) - where T : IFloatingPointIeee754 => - new(T.Lerp(a.X, b.X, T.Clamp(amount.X, T.Zero, T.One)), - T.Lerp(a.Y, b.Y, T.Clamp(amount.Y, T.Zero, T.One)), - T.Lerp(a.Z, b.Z, T.Clamp(amount.Z, T.Zero, T.One)), - T.Lerp(a.W, b.W, T.Clamp(amount.W, T.Zero, T.One))); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static (Vector4D Sin, Vector4D Cos) SinCos(this Vector4D x) - where T : ITrigonometricFunctions => - (new(T.Sin(x.X), T.Sin(x.Y), T.Sin(x.Z), T.Sin(x.W)), new(T.Cos(x.X), T.Cos(x.Y), T.Cos(x.Z), T.Cos(x.W))); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static (Vector4D SinPi, Vector4D CosPi) SinCosPi(this Vector4D x) - where T : ITrigonometricFunctions => - (new(T.SinPi(x.X), T.SinPi(x.Y), T.SinPi(x.Z), T.SinPi(x.W)), new(T.CosPi(x.X), T.CosPi(x.Y), T.CosPi(x.Z), T.CosPi(x.W))); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static (Vector4D Quotient, Vector4D Remainder) DivRem(Vector4D left, Vector4D right) - where T : IBinaryInteger - { - var (qX, rX) = T.DivRem(left.X, right.X); - var (qY, rY) = T.DivRem(left.Y, right.Y); - var (qZ, rZ) = T.DivRem(left.Z, right.Z); - var (qW, rW) = T.DivRem(left.W, right.W); - return (new Vector4D(qX, qY, qZ, qW), new Vector4D(rX, rY, rZ, rW)); - } - - /// Multiplies a vector by a scalar value. - /// The source vector. - /// The scaling factor. - /// The scaled vector. - public static Vector4D Multiply(Vector4D left, T right) - where T : INumberBase => - left * right; - - /// Multiplies a vector by a scalar value. - /// The scaling factor. - /// The source vector. - /// The scaled vector. - public static Vector4D Multiply(T left, Vector4D right) - where T : INumberBase => - left * right; - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Sign(this Vector4D value) - where TSelf : INumber => - new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z), TSelf.Sign(value.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D Max(this Vector4D x, Vector4D y) - where TSelf : INumber => - new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z), TSelf.Max(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D Max(this Vector4D x, TSelf y) - where TSelf : INumber => - new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y), TSelf.Max(x.W, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D MaxNumber(this Vector4D x, Vector4D y) - where TSelf : INumber => - new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z), TSelf.MaxNumber(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D MaxNumber(this Vector4D x, TSelf y) - where TSelf : INumber => - new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y), TSelf.MaxNumber(x.W, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D Min(this Vector4D x, Vector4D y) - where TSelf : INumber => - new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z), TSelf.Min(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D Min(this Vector4D x, TSelf y) - where TSelf : INumber => - new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y), TSelf.Min(x.W, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D MinNumber(this Vector4D x, Vector4D y) - where TSelf : INumber => - new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z), TSelf.MinNumber(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D MinNumber(this Vector4D x, TSelf y) - where TSelf : INumber => - new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y), TSelf.MinNumber(x.W, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D Clamp(this Vector4D value, Vector4D min, Vector4D max) - where TSelf : INumber => - new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z), TSelf.Clamp(value.W, min.W, max.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A single value provided for . - public static Vector4D Clamp(this Vector4D value, TSelf min, TSelf max) - where TSelf : INumber => - new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max), TSelf.Clamp(value.W, min, max)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D CopySign(this Vector4D value, Vector4D sign) - where TSelf : INumber => - new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z), TSelf.CopySign(value.W, sign.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D CopySign(this Vector4D value, TSelf sign) - where TSelf : INumber => - new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign), TSelf.CopySign(value.W, sign)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Abs(this Vector4D value) - where TSelf : INumberBase => - new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z), TSelf.Abs(value.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D MaxMagnitude(this Vector4D x, Vector4D y) - where TSelf : INumberBase => - new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z), TSelf.MaxMagnitude(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D MaxMagnitudeNumber(this Vector4D x, Vector4D y) - where TSelf : INumberBase => - new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z), TSelf.MaxMagnitudeNumber(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D MinMagnitude(this Vector4D x, Vector4D y) - where TSelf : INumberBase => - new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z), TSelf.MinMagnitude(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D MinMagnitudeNumber(this Vector4D x, Vector4D y) - where TSelf : INumberBase => - new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z), TSelf.MinMagnitudeNumber(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D PopCount(this Vector4D value) - where TSelf : IBinaryInteger => - new(TSelf.PopCount(value.X), TSelf.PopCount(value.Y), TSelf.PopCount(value.Z), TSelf.PopCount(value.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D TrailingZeroCount(this Vector4D value) - where TSelf : IBinaryInteger => - new(TSelf.TrailingZeroCount(value.X), TSelf.TrailingZeroCount(value.Y), TSelf.TrailingZeroCount(value.Z), TSelf.TrailingZeroCount(value.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Ceiling(this Vector4D x) - where TSelf : IFloatingPoint => - new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y), TSelf.Ceiling(x.Z), TSelf.Ceiling(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Floor(this Vector4D x) - where TSelf : IFloatingPoint => - new(TSelf.Floor(x.X), TSelf.Floor(x.Y), TSelf.Floor(x.Z), TSelf.Floor(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Round(this Vector4D x) - where TSelf : IFloatingPoint => - new(TSelf.Round(x.X), TSelf.Round(x.Y), TSelf.Round(x.Z), TSelf.Round(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D Round(this Vector4D x, int digits) - where TSelf : IFloatingPoint => - new(TSelf.Round(x.X, digits), TSelf.Round(x.Y, digits), TSelf.Round(x.Z, digits), TSelf.Round(x.W, digits)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D Round(this Vector4D x, MidpointRounding mode) - where TSelf : IFloatingPoint => - new(TSelf.Round(x.X, mode), TSelf.Round(x.Y, mode), TSelf.Round(x.Z, mode), TSelf.Round(x.W, mode)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A single value provided for . - public static Vector4D Round(this Vector4D x, int digits, MidpointRounding mode) - where TSelf : IFloatingPoint => - new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode), TSelf.Round(x.Z, digits, mode), TSelf.Round(x.W, digits, mode)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Truncate(this Vector4D x) - where TSelf : IFloatingPoint => - new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y), TSelf.Truncate(x.Z), TSelf.Truncate(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D Atan2(this Vector4D y, Vector4D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y), TSelf.Atan2(y.Z, x.Z), TSelf.Atan2(y.W, x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D Atan2Pi(this Vector4D y, Vector4D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y), TSelf.Atan2Pi(y.Z, x.Z), TSelf.Atan2Pi(y.W, x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D Lerp(this Vector4D value1, Vector4D value2, TSelf amount) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount), TSelf.Lerp(value1.Z, value2.Z, amount), TSelf.Lerp(value1.W, value2.W, amount)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D BitDecrement(this Vector4D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y), TSelf.BitDecrement(x.Z), TSelf.BitDecrement(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D BitIncrement(this Vector4D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y), TSelf.BitIncrement(x.Z), TSelf.BitIncrement(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D FusedMultiplyAdd(this Vector4D left, Vector4D right, Vector4D addend) - where TSelf : IFloatingPointIeee754 => - new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend.Z), TSelf.FusedMultiplyAdd(left.W, right.W, addend.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D FusedMultiplyAdd(this Vector4D left, Vector4D right, TSelf addend) - where TSelf : IFloatingPointIeee754 => - new(TSelf.FusedMultiplyAdd(left.X, right.X, addend), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend), TSelf.FusedMultiplyAdd(left.W, right.W, addend)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A vector whose members will be provided for . - public static Vector4D FusedMultiplyAdd(this Vector4D left, TSelf right, Vector4D addend) - where TSelf : IFloatingPointIeee754 => - new(TSelf.FusedMultiplyAdd(left.X, right, addend.X), TSelf.FusedMultiplyAdd(left.Y, right, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right, addend.Z), TSelf.FusedMultiplyAdd(left.W, right, addend.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - /// A single value provided for . - public static Vector4D FusedMultiplyAdd(this Vector4D left, TSelf right, TSelf addend) - where TSelf : IFloatingPointIeee754 => - new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend), TSelf.FusedMultiplyAdd(left.Z, right, addend), TSelf.FusedMultiplyAdd(left.W, right, addend)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D Ieee754Remainder(this Vector4D left, Vector4D right) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y), TSelf.Ieee754Remainder(left.Z, right.Z), TSelf.Ieee754Remainder(left.W, right.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D Ieee754Remainder(this Vector4D left, TSelf right) - where TSelf : IFloatingPointIeee754 => - new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right), TSelf.Ieee754Remainder(left.Z, right), TSelf.Ieee754Remainder(left.W, right)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D ILogB(this Vector4D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y), TSelf.ILogB(x.Z), TSelf.ILogB(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D ReciprocalEstimate(this Vector4D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y), TSelf.ReciprocalEstimate(x.Z), TSelf.ReciprocalEstimate(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D ReciprocalSqrtEstimate(this Vector4D x) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y), TSelf.ReciprocalSqrtEstimate(x.Z), TSelf.ReciprocalSqrtEstimate(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D ScaleB(this Vector4D x, Vector4D n) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y), TSelf.ScaleB(x.Z, n.Z), TSelf.ScaleB(x.W, n.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D ScaleB(this Vector4D x, int n) - where TSelf : IFloatingPointIeee754 => - new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n), TSelf.ScaleB(x.Z, n), TSelf.ScaleB(x.W, n)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D Pow(this Vector4D x, Vector4D y) - where TSelf : IPowerFunctions => - new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y), TSelf.Pow(x.Z, y.Z), TSelf.Pow(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D Pow(this Vector4D x, TSelf y) - where TSelf : IPowerFunctions => - new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y), TSelf.Pow(x.Z, y), TSelf.Pow(x.W, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Cbrt(this Vector4D x) - where TSelf : IRootFunctions => - new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y), TSelf.Cbrt(x.Z), TSelf.Cbrt(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Sqrt(this Vector4D x) - where TSelf : IRootFunctions => - new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y), TSelf.Sqrt(x.Z), TSelf.Sqrt(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D RootN(this Vector4D x, int n) - where TSelf : IRootFunctions => - new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n), TSelf.RootN(x.Z, n), TSelf.RootN(x.W, n)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D RootN(this Vector4D x, Vector4D n) - where TSelf : IRootFunctions => - new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y), TSelf.RootN(x.Z, n.Z), TSelf.RootN(x.W, n.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D Hypot(this Vector4D x, Vector4D y) - where TSelf : IRootFunctions => - new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y), TSelf.Hypot(x.Z, y.Z), TSelf.Hypot(x.W, y.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D Hypot(this Vector4D x, TSelf y) - where TSelf : IRootFunctions => - new(TSelf.Hypot(x.X, y), TSelf.Hypot(x.Y, y), TSelf.Hypot(x.Z, y), TSelf.Hypot(x.W, y)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Log(this Vector4D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z), TSelf.Log(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A vector whose members will be provided for . - public static Vector4D Log(this Vector4D x, Vector4D newBase) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z), TSelf.Log(x.W, newBase.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - /// A single value provided for . - public static Vector4D Log(this Vector4D x, TSelf newBase) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase), TSelf.Log(x.Z, newBase), TSelf.Log(x.W, newBase)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D LogP1(this Vector4D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z), TSelf.LogP1(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Log2(this Vector4D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z), TSelf.Log2(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Log2P1(this Vector4D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z), TSelf.Log2P1(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Log10(this Vector4D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z), TSelf.Log10(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Log10P1(this Vector4D x) - where TSelf : ILogarithmicFunctions => - new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z), TSelf.Log10P1(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Exp(this Vector4D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z), TSelf.Exp(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D ExpM1(this Vector4D x) - where TSelf : IExponentialFunctions => - new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z), TSelf.ExpM1(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Exp2(this Vector4D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z), TSelf.Exp2(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Exp2M1(this Vector4D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z), TSelf.Exp2M1(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Exp10(this Vector4D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z), TSelf.Exp10(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Exp10M1(this Vector4D x) - where TSelf : IExponentialFunctions => - new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z), TSelf.Exp10M1(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Acos(this Vector4D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Acos(x.X), TSelf.Acos(x.Y), TSelf.Acos(x.Z), TSelf.Acos(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D AcosPi(this Vector4D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y), TSelf.AcosPi(x.Z), TSelf.AcosPi(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Asin(this Vector4D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Asin(x.X), TSelf.Asin(x.Y), TSelf.Asin(x.Z), TSelf.Asin(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D AsinPi(this Vector4D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y), TSelf.AsinPi(x.Z), TSelf.AsinPi(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Atan(this Vector4D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Atan(x.X), TSelf.Atan(x.Y), TSelf.Atan(x.Z), TSelf.Atan(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D AtanPi(this Vector4D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y), TSelf.AtanPi(x.Z), TSelf.AtanPi(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Cos(this Vector4D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Cos(x.X), TSelf.Cos(x.Y), TSelf.Cos(x.Z), TSelf.Cos(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D CosPi(this Vector4D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y), TSelf.CosPi(x.Z), TSelf.CosPi(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Sin(this Vector4D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Sin(x.X), TSelf.Sin(x.Y), TSelf.Sin(x.Z), TSelf.Sin(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D SinPi(this Vector4D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y), TSelf.SinPi(x.Z), TSelf.SinPi(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Tan(this Vector4D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.Tan(x.X), TSelf.Tan(x.Y), TSelf.Tan(x.Z), TSelf.Tan(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D TanPi(this Vector4D x) - where TSelf : ITrigonometricFunctions => - new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y), TSelf.TanPi(x.Z), TSelf.TanPi(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D DegreesToRadians(this Vector4D degrees) - where TSelf : ITrigonometricFunctions => - new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y), TSelf.DegreesToRadians(degrees.Z), TSelf.DegreesToRadians(degrees.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D RadiansToDegrees(this Vector4D radians) - where TSelf : ITrigonometricFunctions => - new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y), TSelf.RadiansToDegrees(radians.Z), TSelf.RadiansToDegrees(radians.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Acosh(this Vector4D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y), TSelf.Acosh(x.Z), TSelf.Acosh(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Asinh(this Vector4D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y), TSelf.Asinh(x.Z), TSelf.Asinh(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Atanh(this Vector4D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y), TSelf.Atanh(x.Z), TSelf.Atanh(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Cosh(this Vector4D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y), TSelf.Cosh(x.Z), TSelf.Cosh(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Sinh(this Vector4D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y), TSelf.Sinh(x.Z), TSelf.Sinh(x.W)); - - /// Applies to the provided arguments. - /// A vector whose members will be provided for . - public static Vector4D Tanh(this Vector4D x) - where TSelf : IHyperbolicFunctions => - new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y), TSelf.Tanh(x.Z), TSelf.Tanh(x.W)); - } } From 09e6b93bb3801ae1710c960c98964acc5c11659b Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 19 Jul 2025 17:22:41 -0700 Subject: [PATCH 59/67] Use columns for transpose implementation. --- sources/Maths/Maths/Matrix2X2.gen.cs | 4 ++-- sources/Maths/Maths/Matrix2X3.gen.cs | 6 +++--- sources/Maths/Maths/Matrix2X4.gen.cs | 8 ++++---- sources/Maths/Maths/Matrix3X2.gen.cs | 4 ++-- sources/Maths/Maths/Matrix3X3.gen.cs | 6 +++--- sources/Maths/Maths/Matrix3X4.gen.cs | 8 ++++---- sources/Maths/Maths/Matrix4X2.gen.cs | 4 ++-- sources/Maths/Maths/Matrix4X3.gen.cs | 6 +++--- sources/Maths/Maths/Matrix4X4.gen.cs | 8 ++++---- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index fb71b14e14..7a935800f6 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -157,8 +157,8 @@ public Matrix2X2 AsTruncating() /// Computes the transpose of the matrix. public Matrix2X2 Transpose() => - new(new(M11, M21), - new(M12, M22)); + new(Column1, + Column2); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. diff --git a/sources/Maths/Maths/Matrix2X3.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs index b5f76d74b6..94a41231bb 100644 --- a/sources/Maths/Maths/Matrix2X3.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -162,9 +162,9 @@ public Matrix2X3 AsTruncating() /// Computes the transpose of the matrix. public Matrix3X2 Transpose() => - new(new(M11, M21), - new(M12, M22), - new(M13, M23)); + new(Column1, + Column2, + Column3); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. diff --git a/sources/Maths/Maths/Matrix2X4.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs index b352063580..76db9f2347 100644 --- a/sources/Maths/Maths/Matrix2X4.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -176,10 +176,10 @@ public Matrix2X4 AsTruncating() /// Computes the transpose of the matrix. public Matrix4X2 Transpose() => - new(new(M11, M21), - new(M12, M22), - new(M13, M23), - new(M14, M24)); + new(Column1, + Column2, + Column3, + Column4); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index b78a593a44..57d26f74f2 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -167,8 +167,8 @@ public Matrix3X2 AsTruncating() /// Computes the transpose of the matrix. public Matrix2X3 Transpose() => - new(new(M11, M21, M31), - new(M12, M22, M32)); + new(Column1, + Column2); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index 33336a03a1..f9c95fb023 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -196,9 +196,9 @@ public Matrix3X3 AsTruncating() /// Computes the transpose of the matrix. public Matrix3X3 Transpose() => - new(new(M11, M21, M31), - new(M12, M22, M32), - new(M13, M23, M33)); + new(Column1, + Column2, + Column3); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. diff --git a/sources/Maths/Maths/Matrix3X4.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs index 2bf714652f..7e2e8b232e 100644 --- a/sources/Maths/Maths/Matrix3X4.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -205,10 +205,10 @@ public Matrix3X4 AsTruncating() /// Computes the transpose of the matrix. public Matrix4X3 Transpose() => - new(new(M11, M21, M31), - new(M12, M22, M32), - new(M13, M23, M33), - new(M14, M24, M34)); + new(Column1, + Column2, + Column3, + Column4); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. diff --git a/sources/Maths/Maths/Matrix4X2.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs index 736f70bab4..354e1d5cdb 100644 --- a/sources/Maths/Maths/Matrix4X2.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -186,8 +186,8 @@ public Matrix4X2 AsTruncating() /// Computes the transpose of the matrix. public Matrix2X4 Transpose() => - new(new(M11, M21, M31, M41), - new(M12, M22, M32, M42)); + new(Column1, + Column2); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. diff --git a/sources/Maths/Maths/Matrix4X3.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs index 90626d74b3..d00c8f3775 100644 --- a/sources/Maths/Maths/Matrix4X3.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -210,9 +210,9 @@ public Matrix4X3 AsTruncating() /// Computes the transpose of the matrix. public Matrix3X4 Transpose() => - new(new(M11, M21, M31, M41), - new(M12, M22, M32, M42), - new(M13, M23, M33, M43)); + new(Column1, + Column2, + Column3); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index a21819946d..cccdd20ac7 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -245,10 +245,10 @@ public Matrix4X4 AsTruncating() /// Computes the transpose of the matrix. public Matrix4X4 Transpose() => - new(new(M11, M21, M31, M41), - new(M12, M22, M32, M42), - new(M13, M23, M33, M43), - new(M14, M24, M34, M44)); + new(Column1, + Column2, + Column3, + Column4); /// Returns a boolean indicating whether the given two matrices are equal. /// The first matrix to compare. From 3f3898805294fb02cc2bec5fa6969d8345c74168 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 19 Jul 2025 17:24:48 -0700 Subject: [PATCH 60/67] Put properties and indexers before constructors. --- sources/Maths/Maths/Matrix2X2.gen.cs | 59 ++++++++------- sources/Maths/Maths/Matrix2X3.gen.cs | 79 ++++++++++---------- sources/Maths/Maths/Matrix2X4.gen.cs | 83 ++++++++++----------- sources/Maths/Maths/Matrix3X2.gen.cs | 83 ++++++++++----------- sources/Maths/Maths/Matrix3X3.gen.cs | 91 +++++++++++------------ sources/Maths/Maths/Matrix3X4.gen.cs | 91 +++++++++++------------ sources/Maths/Maths/Matrix4X2.gen.cs | 99 ++++++++++++------------- sources/Maths/Maths/Matrix4X3.gen.cs | 99 ++++++++++++------------- sources/Maths/Maths/Matrix4X4.gen.cs | 99 ++++++++++++------------- sources/Maths/Maths/Matrix5X4.gen.cs | 107 +++++++++++++-------------- sources/Maths/Maths/Vector2D.gen.cs | 47 ++++++------ sources/Maths/Maths/Vector3D.gen.cs | 61 ++++++++------- sources/Maths/Maths/Vector4D.gen.cs | 75 +++++++++---------- 13 files changed, 530 insertions(+), 543 deletions(-) diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index 7a935800f6..094ff51275 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -40,18 +40,25 @@ public partial struct Matrix2X2 : [IgnoreDataMember] public Vector2D Column2 => new(Row1.Y, Row2.Y); - /// Constructs a from the given rows. - public Matrix2X2(Vector2D row1, Vector2D row2) => - (Row1, Row2) = (row1, row2); + /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M11 => ref Row1.X; - /// Constructs a from the given components. - public Matrix2X2( - T m11, T m12, - T m21, T m22) - { - Row1 = new(m11, m12); - Row2 = new(m21, m22); - } + /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M12 => ref Row1.Y; + + /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M21 => ref Row2.X; + + /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M22 => ref Row2.Y; /// /// Indexer for the rows of this matrix. @@ -82,26 +89,18 @@ public ref Vector2D this[int row] [UnscopedRef] public ref T this[int row, int column] => ref this[row][column]; - /// Gets the element in the 1st row and 1st column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M22 => ref Row2.Y; + /// Constructs a from the given rows. + public Matrix2X2(Vector2D row1, Vector2D row2) => + (Row1, Row2) = (row1, row2); + /// Constructs a from the given components. + public Matrix2X2( + T m11, T m12, + T m21, T m22) + { + Row1 = new(m11, m12); + Row2 = new(m21, m22); + } /// public override string ToString() => diff --git a/sources/Maths/Maths/Matrix2X3.gen.cs b/sources/Maths/Maths/Matrix2X3.gen.cs index 94a41231bb..154678319a 100644 --- a/sources/Maths/Maths/Matrix2X3.gen.cs +++ b/sources/Maths/Maths/Matrix2X3.gen.cs @@ -35,18 +35,35 @@ public partial struct Matrix2X3 : [IgnoreDataMember] public Vector2D Column3 => new(Row1.Z, Row2.Z); - /// Constructs a from the given rows. - public Matrix2X3(Vector3D row1, Vector3D row2) => - (Row1, Row2) = (row1, row2); + /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M11 => ref Row1.X; - /// Constructs a from the given components. - public Matrix2X3( - T m11, T m12, T m13, - T m21, T m22, T m23) - { - Row1 = new(m11, m12, m13); - Row2 = new(m21, m22, m23); - } + /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M12 => ref Row1.Y; + + /// Gets the element in the 1st row and 3rd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M13 => ref Row1.Z; + + /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M21 => ref Row2.X; + + /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M22 => ref Row2.Y; + + /// Gets the element in the 2nd row and 3rd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M23 => ref Row2.Z; /// /// Indexer for the rows of this matrix. @@ -77,36 +94,18 @@ public ref Vector3D this[int row] [UnscopedRef] public ref T this[int row, int column] => ref this[row][column]; - /// Gets the element in the 1st row and 1st column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 1st row and 3rd column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M13 => ref Row1.Z; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// Gets the element in the 2nd row and 3rd column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M23 => ref Row2.Z; + /// Constructs a from the given rows. + public Matrix2X3(Vector3D row1, Vector3D row2) => + (Row1, Row2) = (row1, row2); + /// Constructs a from the given components. + public Matrix2X3( + T m11, T m12, T m13, + T m21, T m22, T m23) + { + Row1 = new(m11, m12, m13); + Row2 = new(m21, m22, m23); + } /// public override string ToString() => diff --git a/sources/Maths/Maths/Matrix2X4.gen.cs b/sources/Maths/Maths/Matrix2X4.gen.cs index 76db9f2347..799c1553dc 100644 --- a/sources/Maths/Maths/Matrix2X4.gen.cs +++ b/sources/Maths/Maths/Matrix2X4.gen.cs @@ -39,48 +39,6 @@ public partial struct Matrix2X4 : [IgnoreDataMember] public Vector2D Column4 => new(Row1.W, Row2.W); - /// Constructs a from the given rows. - public Matrix2X4(Vector4D row1, Vector4D row2) => - (Row1, Row2) = (row1, row2); - - /// Constructs a from the given components. - public Matrix2X4( - T m11, T m12, T m13, T m14, - T m21, T m22, T m23, T m24) - { - Row1 = new(m11, m12, m13, m14); - Row2 = new(m21, m22, m23, m24); - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - [UnscopedRef] - public ref Vector4D this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - } - - throw new IndexOutOfRangeException(); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - /// Gets the element in the 1st row and 1st column of the matrix. [DataMember] [UnscopedRef] @@ -121,6 +79,47 @@ public ref Vector4D this[int row] [UnscopedRef] public ref T M24 => ref Row2.W; + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. + [UnscopedRef] + public ref Vector4D this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + } + + throw new IndexOutOfRangeException(); + } + } + + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. + [UnscopedRef] + public ref T this[int row, int column] => ref this[row][column]; + + /// Constructs a from the given rows. + public Matrix2X4(Vector4D row1, Vector4D row2) => + (Row1, Row2) = (row1, row2); + + /// Constructs a from the given components. + public Matrix2X4( + T m11, T m12, T m13, T m14, + T m21, T m22, T m23, T m24) + { + Row1 = new(m11, m12, m13, m14); + Row2 = new(m21, m22, m23, m24); + } /// public override string ToString() => diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index 57d26f74f2..1efe780d2d 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -35,20 +35,35 @@ public partial struct Matrix3X2 : [IgnoreDataMember] public Vector3D Column2 => new(Row1.Y, Row2.Y, Row3.Y); - /// Constructs a from the given rows. - public Matrix3X2(Vector2D row1, Vector2D row2, Vector2D row3) => - (Row1, Row2, Row3) = (row1, row2, row3); + /// Gets the element in the 1st row and 1st column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M11 => ref Row1.X; - /// Constructs a from the given components. - public Matrix3X2( - T m11, T m12, - T m21, T m22, - T m31, T m32) - { - Row1 = new(m11, m12); - Row2 = new(m21, m22); - Row3 = new(m31, m32); - } + /// Gets the element in the 1st row and 2nd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M12 => ref Row1.Y; + + /// Gets the element in the 2nd row and 1st column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M21 => ref Row2.X; + + /// Gets the element in the 2nd row and 2nd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M22 => ref Row2.Y; + + /// Gets the element in the 3rd row and 1st column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M31 => ref Row3.X; + + /// Gets the element in the 3rd row and 2nd column of the matrix. + [DataMember] + [UnscopedRef] + public ref T M32 => ref Row3.Y; /// /// Indexer for the rows of this matrix. @@ -81,36 +96,20 @@ public ref Vector2D this[int row] [UnscopedRef] public ref T this[int row, int column] => ref this[row][column]; - /// Gets the element in the 1st row and 1st column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M11 => ref Row1.X; - - /// Gets the element in the 1st row and 2nd column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M12 => ref Row1.Y; - - /// Gets the element in the 2nd row and 1st column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M21 => ref Row2.X; - - /// Gets the element in the 2nd row and 2nd column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M22 => ref Row2.Y; - - /// Gets the element in the 3rd row and 1st column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M31 => ref Row3.X; - - /// Gets the element in the 3rd row and 2nd column of the matrix. - [DataMember] - [UnscopedRef] - public ref T M32 => ref Row3.Y; + /// Constructs a from the given rows. + public Matrix3X2(Vector2D row1, Vector2D row2, Vector2D row3) => + (Row1, Row2, Row3) = (row1, row2, row3); + /// Constructs a from the given components. + public Matrix3X2( + T m11, T m12, + T m21, T m22, + T m31, T m32) + { + Row1 = new(m11, m12); + Row2 = new(m21, m22); + Row3 = new(m31, m32); + } /// public override string ToString() => diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index f9c95fb023..7a5f1ffaf3 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -49,52 +49,6 @@ public partial struct Matrix3X3 : [IgnoreDataMember] public Vector3D Column3 => new(Row1.Z, Row2.Z, Row3.Z); - /// Constructs a from the given rows. - public Matrix3X3(Vector3D row1, Vector3D row2, Vector3D row3) => - (Row1, Row2, Row3) = (row1, row2, row3); - - /// Constructs a from the given components. - public Matrix3X3( - T m11, T m12, T m13, - T m21, T m22, T m23, - T m31, T m32, T m33) - { - Row1 = new(m11, m12, m13); - Row2 = new(m21, m22, m23); - Row3 = new(m31, m32, m33); - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - [UnscopedRef] - public ref Vector3D this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - } - - throw new IndexOutOfRangeException(); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - /// Gets the element in the 1st row and 1st column of the matrix. [DataMember] [UnscopedRef] @@ -140,6 +94,51 @@ public ref Vector3D this[int row] [UnscopedRef] public ref T M33 => ref Row3.Z; + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. + [UnscopedRef] + public ref Vector3D this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + } + + throw new IndexOutOfRangeException(); + } + } + + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. + [UnscopedRef] + public ref T this[int row, int column] => ref this[row][column]; + + /// Constructs a from the given rows. + public Matrix3X3(Vector3D row1, Vector3D row2, Vector3D row3) => + (Row1, Row2, Row3) = (row1, row2, row3); + + /// Constructs a from the given components. + public Matrix3X3( + T m11, T m12, T m13, + T m21, T m22, T m23, + T m31, T m32, T m33) + { + Row1 = new(m11, m12, m13); + Row2 = new(m21, m22, m23); + Row3 = new(m31, m32, m33); + } /// public override string ToString() => diff --git a/sources/Maths/Maths/Matrix3X4.gen.cs b/sources/Maths/Maths/Matrix3X4.gen.cs index 7e2e8b232e..68495939a2 100644 --- a/sources/Maths/Maths/Matrix3X4.gen.cs +++ b/sources/Maths/Maths/Matrix3X4.gen.cs @@ -43,52 +43,6 @@ public partial struct Matrix3X4 : [IgnoreDataMember] public Vector3D Column4 => new(Row1.W, Row2.W, Row3.W); - /// Constructs a from the given rows. - public Matrix3X4(Vector4D row1, Vector4D row2, Vector4D row3) => - (Row1, Row2, Row3) = (row1, row2, row3); - - /// Constructs a from the given components. - public Matrix3X4( - T m11, T m12, T m13, T m14, - T m21, T m22, T m23, T m24, - T m31, T m32, T m33, T m34) - { - Row1 = new(m11, m12, m13, m14); - Row2 = new(m21, m22, m23, m24); - Row3 = new(m31, m32, m33, m34); - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - [UnscopedRef] - public ref Vector4D this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - } - - throw new IndexOutOfRangeException(); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - /// Gets the element in the 1st row and 1st column of the matrix. [DataMember] [UnscopedRef] @@ -149,6 +103,51 @@ public ref Vector4D this[int row] [UnscopedRef] public ref T M34 => ref Row3.W; + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. + [UnscopedRef] + public ref Vector4D this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + } + + throw new IndexOutOfRangeException(); + } + } + + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. + [UnscopedRef] + public ref T this[int row, int column] => ref this[row][column]; + + /// Constructs a from the given rows. + public Matrix3X4(Vector4D row1, Vector4D row2, Vector4D row3) => + (Row1, Row2, Row3) = (row1, row2, row3); + + /// Constructs a from the given components. + public Matrix3X4( + T m11, T m12, T m13, T m14, + T m21, T m22, T m23, T m24, + T m31, T m32, T m33, T m34) + { + Row1 = new(m11, m12, m13, m14); + Row2 = new(m21, m22, m23, m24); + Row3 = new(m31, m32, m33, m34); + } /// public override string ToString() => diff --git a/sources/Maths/Maths/Matrix4X2.gen.cs b/sources/Maths/Maths/Matrix4X2.gen.cs index 354e1d5cdb..45879c2005 100644 --- a/sources/Maths/Maths/Matrix4X2.gen.cs +++ b/sources/Maths/Maths/Matrix4X2.gen.cs @@ -39,56 +39,6 @@ public partial struct Matrix4X2 : [IgnoreDataMember] public Vector4D Column2 => new(Row1.Y, Row2.Y, Row3.Y, Row4.Y); - /// Constructs a from the given rows. - public Matrix4X2(Vector2D row1, Vector2D row2, Vector2D row3, Vector2D row4) => - (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); - - /// Constructs a from the given components. - public Matrix4X2( - T m11, T m12, - T m21, T m22, - T m31, T m32, - T m41, T m42) - { - Row1 = new(m11, m12); - Row2 = new(m21, m22); - Row3 = new(m31, m32); - Row4 = new(m41, m42); - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - [UnscopedRef] - public ref Vector2D this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - case 3: - return ref Row4; - } - - throw new IndexOutOfRangeException(); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - /// Gets the element in the 1st row and 1st column of the matrix. [DataMember] [UnscopedRef] @@ -129,6 +79,55 @@ public ref Vector2D this[int row] [UnscopedRef] public ref T M42 => ref Row4.Y; + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. + [UnscopedRef] + public ref Vector2D this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + } + + throw new IndexOutOfRangeException(); + } + } + + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. + [UnscopedRef] + public ref T this[int row, int column] => ref this[row][column]; + + /// Constructs a from the given rows. + public Matrix4X2(Vector2D row1, Vector2D row2, Vector2D row3, Vector2D row4) => + (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + + /// Constructs a from the given components. + public Matrix4X2( + T m11, T m12, + T m21, T m22, + T m31, T m32, + T m41, T m42) + { + Row1 = new(m11, m12); + Row2 = new(m21, m22); + Row3 = new(m31, m32); + Row4 = new(m41, m42); + } /// public override string ToString() => diff --git a/sources/Maths/Maths/Matrix4X3.gen.cs b/sources/Maths/Maths/Matrix4X3.gen.cs index d00c8f3775..862eb3256c 100644 --- a/sources/Maths/Maths/Matrix4X3.gen.cs +++ b/sources/Maths/Maths/Matrix4X3.gen.cs @@ -43,56 +43,6 @@ public partial struct Matrix4X3 : [IgnoreDataMember] public Vector4D Column3 => new(Row1.Z, Row2.Z, Row3.Z, Row4.Z); - /// Constructs a from the given rows. - public Matrix4X3(Vector3D row1, Vector3D row2, Vector3D row3, Vector3D row4) => - (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); - - /// Constructs a from the given components. - public Matrix4X3( - T m11, T m12, T m13, - T m21, T m22, T m23, - T m31, T m32, T m33, - T m41, T m42, T m43) - { - Row1 = new(m11, m12, m13); - Row2 = new(m21, m22, m23); - Row3 = new(m31, m32, m33); - Row4 = new(m41, m42, m43); - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - [UnscopedRef] - public ref Vector3D this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - case 3: - return ref Row4; - } - - throw new IndexOutOfRangeException(); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - /// Gets the element in the 1st row and 1st column of the matrix. [DataMember] [UnscopedRef] @@ -153,6 +103,55 @@ public ref Vector3D this[int row] [UnscopedRef] public ref T M43 => ref Row4.Z; + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. + [UnscopedRef] + public ref Vector3D this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + } + + throw new IndexOutOfRangeException(); + } + } + + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. + [UnscopedRef] + public ref T this[int row, int column] => ref this[row][column]; + + /// Constructs a from the given rows. + public Matrix4X3(Vector3D row1, Vector3D row2, Vector3D row3, Vector3D row4) => + (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + + /// Constructs a from the given components. + public Matrix4X3( + T m11, T m12, T m13, + T m21, T m22, T m23, + T m31, T m32, T m33, + T m41, T m42, T m43) + { + Row1 = new(m11, m12, m13); + Row2 = new(m21, m22, m23); + Row3 = new(m31, m32, m33); + Row4 = new(m41, m42, m43); + } /// public override string ToString() => diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index cccdd20ac7..7b16c8d341 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -58,56 +58,6 @@ public partial struct Matrix4X4 : [IgnoreDataMember] public Vector4D Column4 => new(Row1.W, Row2.W, Row3.W, Row4.W); - /// Constructs a from the given rows. - public Matrix4X4(Vector4D row1, Vector4D row2, Vector4D row3, Vector4D row4) => - (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); - - /// Constructs a from the given components. - public Matrix4X4( - T m11, T m12, T m13, T m14, - T m21, T m22, T m23, T m24, - T m31, T m32, T m33, T m34, - T m41, T m42, T m43, T m44) - { - Row1 = new(m11, m12, m13, m14); - Row2 = new(m21, m22, m23, m24); - Row3 = new(m31, m32, m33, m34); - Row4 = new(m41, m42, m43, m44); - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - [UnscopedRef] - public ref Vector4D this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - case 3: - return ref Row4; - } - - throw new IndexOutOfRangeException(); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - /// Gets the element in the 1st row and 1st column of the matrix. [DataMember] [UnscopedRef] @@ -188,6 +138,55 @@ public ref Vector4D this[int row] [UnscopedRef] public ref T M44 => ref Row4.W; + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. + [UnscopedRef] + public ref Vector4D this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + } + + throw new IndexOutOfRangeException(); + } + } + + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. + [UnscopedRef] + public ref T this[int row, int column] => ref this[row][column]; + + /// Constructs a from the given rows. + public Matrix4X4(Vector4D row1, Vector4D row2, Vector4D row3, Vector4D row4) => + (Row1, Row2, Row3, Row4) = (row1, row2, row3, row4); + + /// Constructs a from the given components. + public Matrix4X4( + T m11, T m12, T m13, T m14, + T m21, T m22, T m23, T m24, + T m31, T m32, T m33, T m34, + T m41, T m42, T m43, T m44) + { + Row1 = new(m11, m12, m13, m14); + Row2 = new(m21, m22, m23, m24); + Row3 = new(m31, m32, m33, m34); + Row4 = new(m41, m42, m43, m44); + } /// public override string ToString() => diff --git a/sources/Maths/Maths/Matrix5X4.gen.cs b/sources/Maths/Maths/Matrix5X4.gen.cs index 18207c9630..4a2161dc38 100644 --- a/sources/Maths/Maths/Matrix5X4.gen.cs +++ b/sources/Maths/Maths/Matrix5X4.gen.cs @@ -35,60 +35,6 @@ public partial struct Matrix5X4 : [IgnoreDataMember] public Vector4D Row5; - /// Constructs a from the given rows. - public Matrix5X4(Vector4D row1, Vector4D row2, Vector4D row3, Vector4D row4, Vector4D row5) => - (Row1, Row2, Row3, Row4, Row5) = (row1, row2, row3, row4, row5); - - /// Constructs a from the given components. - public Matrix5X4( - T m11, T m12, T m13, T m14, - T m21, T m22, T m23, T m24, - T m31, T m32, T m33, T m34, - T m41, T m42, T m43, T m44, - T m51, T m52, T m53, T m54) - { - Row1 = new(m11, m12, m13, m14); - Row2 = new(m21, m22, m23, m24); - Row3 = new(m31, m32, m33, m34); - Row4 = new(m41, m42, m43, m44); - Row5 = new(m51, m52, m53, m54); - } - - /// - /// Indexer for the rows of this matrix. - /// - /// The row to select. Zero based. - [UnscopedRef] - public ref Vector4D this[int row] - { - get - { - switch (row) - { - case 0: - return ref Row1; - case 1: - return ref Row2; - case 2: - return ref Row3; - case 3: - return ref Row4; - case 4: - return ref Row5; - } - - throw new IndexOutOfRangeException(); - } - } - - /// - /// Indexer for the values in this matrix. - /// - /// The row to select. Zero based. - /// The column to select. Zero based. - [UnscopedRef] - public ref T this[int row, int column] => ref this[row][column]; - /// Gets the element in the 1st row and 1st column of the matrix. [DataMember] [UnscopedRef] @@ -189,6 +135,59 @@ public ref Vector4D this[int row] [UnscopedRef] public ref T M54 => ref Row5.W; + /// + /// Indexer for the rows of this matrix. + /// + /// The row to select. Zero based. + [UnscopedRef] + public ref Vector4D this[int row] + { + get + { + switch (row) + { + case 0: + return ref Row1; + case 1: + return ref Row2; + case 2: + return ref Row3; + case 3: + return ref Row4; + case 4: + return ref Row5; + } + + throw new IndexOutOfRangeException(); + } + } + + /// + /// Indexer for the values in this matrix. + /// + /// The row to select. Zero based. + /// The column to select. Zero based. + [UnscopedRef] + public ref T this[int row, int column] => ref this[row][column]; + + /// Constructs a from the given rows. + public Matrix5X4(Vector4D row1, Vector4D row2, Vector4D row3, Vector4D row4, Vector4D row5) => + (Row1, Row2, Row3, Row4, Row5) = (row1, row2, row3, row4, row5); + + /// Constructs a from the given components. + public Matrix5X4( + T m11, T m12, T m13, T m14, + T m21, T m22, T m23, T m24, + T m31, T m32, T m33, T m34, + T m41, T m42, T m43, T m44, + T m51, T m52, T m53, T m54) + { + Row1 = new(m11, m12, m13, m14); + Row2 = new(m21, m22, m23, m24); + Row3 = new(m31, m32, m33, m34); + Row4 = new(m41, m42, m43, m44); + Row5 = new(m51, m52, m53, m54); + } /// public override string ToString() => diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index 46eb432135..a67f7666ac 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -21,28 +21,6 @@ public partial struct Vector2D : IUtf8SpanParsable> where T : INumberBase { - /// The X component of the vector. - public T X; - - /// The Y component of the vector. - public T Y; - - /// Initializes all components of the vector to the same value. - public Vector2D(T value) => (X, Y) = (value, value); - - /// Initializes the vector with individual component values. - public Vector2D(T x, T y) => (X, Y) = (x, y); - - /// Initializes the vector from a span of 2 values. - public Vector2D(ReadOnlySpan values) - { - if (values.Length != 2) - throw new ArgumentException("Input span must contain exactly 2 elements.", nameof(values)); - - X = values[0]; - Y = values[1]; - } - /// Gets a vector whose 2 elements are equal to one. public static Vector2D One => new(T.One); @@ -55,6 +33,14 @@ public Vector2D(ReadOnlySpan values) /// Gets the vector (0, 1). public static Vector2D UnitY => new(T.Zero, T.One); + /// The X component of the vector. + public T X; + + /// The Y component of the vector. + public T Y; + + /// The number of elements in the vector. + public int Count => 2; /// T IReadOnlyList.this[int index] => this[index]; @@ -77,8 +63,21 @@ public ref T this[int index] } } - /// The number of elements in the vector. - public int Count => 2; + /// Initializes all components of the vector to the same value. + public Vector2D(T value) => (X, Y) = (value, value); + + /// Initializes the vector with individual component values. + public Vector2D(T x, T y) => (X, Y) = (x, y); + + /// Initializes the vector from a span of 2 values. + public Vector2D(ReadOnlySpan values) + { + if (values.Length != 2) + throw new ArgumentException("Input span must contain exactly 2 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + } /// IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index c18f9eee84..bacb3f7666 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -21,35 +21,6 @@ public partial struct Vector3D : IUtf8SpanParsable> where T : INumberBase { - /// The X component of the vector. - public T X; - - /// The Y component of the vector. - public T Y; - - /// The Z component of the vector. - public T Z; - - /// Initializes all components of the vector to the same value. - public Vector3D(T value) => (X, Y, Z) = (value, value, value); - - /// Initializes the vector with individual component values. - public Vector3D(T x, T y, T z) => (X, Y, Z) = (x, y, z); - - /// Initializes the vector using a for the initial elements, and the specified component for the remainder. - public Vector3D(Vector2D other, T z) => (X, Y, Z) = (other.X, other.Y, z); - - /// Initializes the vector from a span of 3 values. - public Vector3D(ReadOnlySpan values) - { - if (values.Length != 3) - throw new ArgumentException("Input span must contain exactly 3 elements.", nameof(values)); - - X = values[0]; - Y = values[1]; - Z = values[2]; - } - /// Gets a vector whose 3 elements are equal to one. public static Vector3D One => new(T.One); @@ -65,6 +36,17 @@ public Vector3D(ReadOnlySpan values) /// Gets the vector (0, 0, 1). public static Vector3D UnitZ => new(T.Zero, T.Zero, T.One); + /// The X component of the vector. + public T X; + + /// The Y component of the vector. + public T Y; + + /// The Z component of the vector. + public T Z; + + /// The number of elements in the vector. + public int Count => 3; /// T IReadOnlyList.this[int index] => this[index]; @@ -89,8 +71,25 @@ public ref T this[int index] } } - /// The number of elements in the vector. - public int Count => 3; + /// Initializes all components of the vector to the same value. + public Vector3D(T value) => (X, Y, Z) = (value, value, value); + + /// Initializes the vector with individual component values. + public Vector3D(T x, T y, T z) => (X, Y, Z) = (x, y, z); + + /// Initializes the vector using a for the initial elements, and the specified component for the remainder. + public Vector3D(Vector2D other, T z) => (X, Y, Z) = (other.X, other.Y, z); + + /// Initializes the vector from a span of 3 values. + public Vector3D(ReadOnlySpan values) + { + if (values.Length != 3) + throw new ArgumentException("Input span must contain exactly 3 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + Z = values[2]; + } /// IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index c48ba74b50..eb76f897f8 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -21,42 +21,6 @@ public partial struct Vector4D : IUtf8SpanParsable> where T : INumberBase { - /// The X component of the vector. - public T X; - - /// The Y component of the vector. - public T Y; - - /// The Z component of the vector. - public T Z; - - /// The W component of the vector. - public T W; - - /// Initializes all components of the vector to the same value. - public Vector4D(T value) => (X, Y, Z, W) = (value, value, value, value); - - /// Initializes the vector with individual component values. - public Vector4D(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); - - /// Initializes the vector using a for the initial elements, and the specified components for the remainder. - public Vector4D(Vector2D other, T z, T w) => (X, Y, Z, W) = (other.X, other.Y, z, w); - - /// Initializes the vector using a for the initial elements, and the specified component for the remainder. - public Vector4D(Vector3D other, T w) => (X, Y, Z, W) = (other.X, other.Y, other.Z, w); - - /// Initializes the vector from a span of 4 values. - public Vector4D(ReadOnlySpan values) - { - if (values.Length != 4) - throw new ArgumentException("Input span must contain exactly 4 elements.", nameof(values)); - - X = values[0]; - Y = values[1]; - Z = values[2]; - W = values[3]; - } - /// Gets a vector whose 4 elements are equal to one. public static Vector4D One => new(T.One); @@ -75,6 +39,20 @@ public Vector4D(ReadOnlySpan values) /// Gets the vector (0, 0, 0, 1). public static Vector4D UnitW => new(T.Zero, T.Zero, T.Zero, T.One); + /// The X component of the vector. + public T X; + + /// The Y component of the vector. + public T Y; + + /// The Z component of the vector. + public T Z; + + /// The W component of the vector. + public T W; + + /// The number of elements in the vector. + public int Count => 4; /// T IReadOnlyList.this[int index] => this[index]; @@ -101,8 +79,29 @@ public ref T this[int index] } } - /// The number of elements in the vector. - public int Count => 4; + /// Initializes all components of the vector to the same value. + public Vector4D(T value) => (X, Y, Z, W) = (value, value, value, value); + + /// Initializes the vector with individual component values. + public Vector4D(T x, T y, T z, T w) => (X, Y, Z, W) = (x, y, z, w); + + /// Initializes the vector using a for the initial elements, and the specified components for the remainder. + public Vector4D(Vector2D other, T z, T w) => (X, Y, Z, W) = (other.X, other.Y, z, w); + + /// Initializes the vector using a for the initial elements, and the specified component for the remainder. + public Vector4D(Vector3D other, T w) => (X, Y, Z, W) = (other.X, other.Y, other.Z, w); + + /// Initializes the vector from a span of 4 values. + public Vector4D(ReadOnlySpan values) + { + if (values.Length != 4) + throw new ArgumentException("Input span must contain exactly 4 elements.", nameof(values)); + + X = values[0]; + Y = values[1]; + Z = values[2]; + W = values[3]; + } /// IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); From 0b6113855cecbae3389d7a70900d66f436a7eee7 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 19 Jul 2025 19:30:18 -0700 Subject: [PATCH 61/67] Generate System.Numerics conversions. --- sources/Maths/Maths/Matrix3X2.cs | 12 -------- sources/Maths/Maths/Matrix3X2.gen.cs | 24 ++++++++++++++++ sources/Maths/Maths/Matrix4X4.gen.cs | 28 +++++++++++++++++++ .../PublicAPI/net8.0/PublicAPI.Unshipped.txt | 25 +++++++++++++---- sources/Maths/Maths/Vector2D.cs | 11 -------- sources/Maths/Maths/Vector2D.gen.cs | 16 +++++++++++ sources/Maths/Maths/Vector3D.cs | 11 -------- sources/Maths/Maths/Vector3D.gen.cs | 16 +++++++++++ sources/Maths/Maths/Vector4D.cs | 18 ------------ sources/Maths/Maths/Vector4D.gen.cs | 16 +++++++++++ 10 files changed, 119 insertions(+), 58 deletions(-) delete mode 100644 sources/Maths/Maths/Vector4D.cs diff --git a/sources/Maths/Maths/Matrix3X2.cs b/sources/Maths/Maths/Matrix3X2.cs index 7565f3a6da..9a1c68fe83 100644 --- a/sources/Maths/Maths/Matrix3X2.cs +++ b/sources/Maths/Maths/Matrix3X2.cs @@ -88,17 +88,5 @@ public readonly T GetDeterminant() return (Row1.X * Row2.Y) - (Row2.X * Row1.Y); } - - /// - /// Converts a into a one. - /// - /// The source matrix - /// The matrix - public static explicit operator System.Numerics.Matrix3x2(Matrix3X2 from) - => new( - float.CreateTruncating(from.M11), float.CreateTruncating(from.M12), - float.CreateTruncating(from.M21), float.CreateTruncating(from.M22), - float.CreateTruncating(from.M31), float.CreateTruncating(from.M32) - ); } } diff --git a/sources/Maths/Maths/Matrix3X2.gen.cs b/sources/Maths/Maths/Matrix3X2.gen.cs index 1efe780d2d..24d5dfca03 100644 --- a/sources/Maths/Maths/Matrix3X2.gen.cs +++ b/sources/Maths/Maths/Matrix3X2.gen.cs @@ -260,6 +260,30 @@ public Matrix2X3 Transpose() => left.M21 * right.Row1 + left.M22 * right.Row2, left.M31 * right.Row1 + left.M32 * right.Row2); + /// Converts a to a . + public static explicit operator Matrix3X2(Matrix3x2 from) => + new(T.CreateTruncating(from.M11), T.CreateTruncating(from.M12), + T.CreateTruncating(from.M21), T.CreateTruncating(from.M22), + T.CreateTruncating(from.M31), T.CreateTruncating(from.M32)); + + /// Converts a to a . + public static explicit operator checked Matrix3X2(Matrix3x2 from) => + new(T.CreateChecked(from.M11), T.CreateChecked(from.M12), + T.CreateChecked(from.M21), T.CreateChecked(from.M22), + T.CreateChecked(from.M31), T.CreateChecked(from.M32)); + + /// Converts a to . + public static explicit operator Matrix3x2(Matrix3X2 from) => + new(float.CreateTruncating(from.M11), float.CreateTruncating(from.M12), + float.CreateTruncating(from.M21), float.CreateTruncating(from.M22), + float.CreateTruncating(from.M31), float.CreateTruncating(from.M32)); + + /// Converts a to . + public static explicit operator checked Matrix3x2(Matrix3X2 from) => + new(float.CreateChecked(from.M11), float.CreateChecked(from.M12), + float.CreateChecked(from.M21), float.CreateChecked(from.M22), + float.CreateChecked(from.M31), float.CreateChecked(from.M32)); + /// /// Converts a matrix of into one with an underlying type of . /// diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index 7b16c8d341..c6e64ccf31 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -375,6 +375,34 @@ public Matrix4X4 Transpose() => left.M31 * right.Row1 + left.M32 * right.Row2 + left.M33 * right.Row3 + left.M34 * right.Row4, left.M41 * right.Row1 + left.M42 * right.Row2 + left.M43 * right.Row3 + left.M44 * right.Row4); + /// Converts a to a . + public static explicit operator Matrix4X4(Matrix4x4 from) => + new(T.CreateTruncating(from.M11), T.CreateTruncating(from.M12), T.CreateTruncating(from.M13), T.CreateTruncating(from.M14), + T.CreateTruncating(from.M21), T.CreateTruncating(from.M22), T.CreateTruncating(from.M23), T.CreateTruncating(from.M24), + T.CreateTruncating(from.M31), T.CreateTruncating(from.M32), T.CreateTruncating(from.M33), T.CreateTruncating(from.M34), + T.CreateTruncating(from.M41), T.CreateTruncating(from.M42), T.CreateTruncating(from.M43), T.CreateTruncating(from.M44)); + + /// Converts a to a . + public static explicit operator checked Matrix4X4(Matrix4x4 from) => + new(T.CreateChecked(from.M11), T.CreateChecked(from.M12), T.CreateChecked(from.M13), T.CreateChecked(from.M14), + T.CreateChecked(from.M21), T.CreateChecked(from.M22), T.CreateChecked(from.M23), T.CreateChecked(from.M24), + T.CreateChecked(from.M31), T.CreateChecked(from.M32), T.CreateChecked(from.M33), T.CreateChecked(from.M34), + T.CreateChecked(from.M41), T.CreateChecked(from.M42), T.CreateChecked(from.M43), T.CreateChecked(from.M44)); + + /// Converts a to . + public static explicit operator Matrix4x4(Matrix4X4 from) => + new(float.CreateTruncating(from.M11), float.CreateTruncating(from.M12), float.CreateTruncating(from.M13), float.CreateTruncating(from.M14), + float.CreateTruncating(from.M21), float.CreateTruncating(from.M22), float.CreateTruncating(from.M23), float.CreateTruncating(from.M24), + float.CreateTruncating(from.M31), float.CreateTruncating(from.M32), float.CreateTruncating(from.M33), float.CreateTruncating(from.M34), + float.CreateTruncating(from.M41), float.CreateTruncating(from.M42), float.CreateTruncating(from.M43), float.CreateTruncating(from.M44)); + + /// Converts a to . + public static explicit operator checked Matrix4x4(Matrix4X4 from) => + new(float.CreateChecked(from.M11), float.CreateChecked(from.M12), float.CreateChecked(from.M13), float.CreateChecked(from.M14), + float.CreateChecked(from.M21), float.CreateChecked(from.M22), float.CreateChecked(from.M23), float.CreateChecked(from.M24), + float.CreateChecked(from.M31), float.CreateChecked(from.M32), float.CreateChecked(from.M33), float.CreateChecked(from.M34), + float.CreateChecked(from.M41), float.CreateChecked(from.M42), float.CreateChecked(from.M43), float.CreateChecked(from.M44)); + /// /// Converts a matrix of into one with an underlying type of . /// diff --git a/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt b/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt index db5673f7b7..58088aad41 100644 --- a/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt +++ b/sources/Maths/Maths/PublicAPI/net8.0/PublicAPI.Unshipped.txt @@ -882,9 +882,11 @@ static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matr static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(System.Numerics.Matrix3x2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked System.Numerics.Matrix3x2(Silk.NET.Maths.Matrix3X2 from) -> System.Numerics.Matrix3x2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 @@ -894,6 +896,7 @@ static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(System.Numerics.Matrix3x2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 @@ -1196,9 +1199,11 @@ static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matr static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(System.Numerics.Matrix4x4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked System.Numerics.Matrix4x4(Silk.NET.Maths.Matrix4X4 from) -> System.Numerics.Matrix4x4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 @@ -1208,9 +1213,11 @@ static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(System.Numerics.Matrix4x4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator System.Numerics.Matrix4x4(Silk.NET.Maths.Matrix4X4 from) -> System.Numerics.Matrix4x4 static Silk.NET.Maths.Matrix4X4.Identity.get -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.operator !=(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> bool static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix2X4 @@ -1461,9 +1468,11 @@ static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vecto static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(System.Numerics.Vector2 from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked System.Numerics.Vector2(Silk.NET.Maths.Vector2D from) -> System.Numerics.Vector2 static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D @@ -1473,11 +1482,11 @@ static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(System.Numerics.Vector2 v) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(System.Numerics.Vector2 from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.explicit operator System.Numerics.Vector2(Silk.NET.Maths.Vector2D v) -> System.Numerics.Vector2 +static Silk.NET.Maths.Vector2D.explicit operator System.Numerics.Vector2(Silk.NET.Maths.Vector2D from) -> System.Numerics.Vector2 static Silk.NET.Maths.Vector2D.implicit operator (T X, T Y)(Silk.NET.Maths.Vector2D v) -> (T X, T Y) static Silk.NET.Maths.Vector2D.implicit operator Silk.NET.Maths.Vector2D((T X, T Y) v) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.One.get -> Silk.NET.Maths.Vector2D @@ -1614,9 +1623,11 @@ static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vecto static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(System.Numerics.Vector3 from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked System.Numerics.Vector3(Silk.NET.Maths.Vector3D from) -> System.Numerics.Vector3 static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D @@ -1626,11 +1637,11 @@ static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(System.Numerics.Vector3 v) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(System.Numerics.Vector3 from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.explicit operator System.Numerics.Vector3(Silk.NET.Maths.Vector3D v) -> System.Numerics.Vector3 +static Silk.NET.Maths.Vector3D.explicit operator System.Numerics.Vector3(Silk.NET.Maths.Vector3D from) -> System.Numerics.Vector3 static Silk.NET.Maths.Vector3D.implicit operator (T X, T Y, T Z)(Silk.NET.Maths.Vector3D v) -> (T X, T Y, T Z) static Silk.NET.Maths.Vector3D.implicit operator Silk.NET.Maths.Vector3D((T X, T Y, T Z) v) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.One.get -> Silk.NET.Maths.Vector3D @@ -1767,9 +1778,11 @@ static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vecto static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(System.Numerics.Vector4 from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked System.Numerics.Vector4(Silk.NET.Maths.Vector4D from) -> System.Numerics.Vector4 static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D @@ -1779,11 +1792,11 @@ static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(System.Numerics.Vector4 v) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(System.Numerics.Vector4 from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.explicit operator System.Numerics.Vector4(Silk.NET.Maths.Vector4D v) -> System.Numerics.Vector4 +static Silk.NET.Maths.Vector4D.explicit operator System.Numerics.Vector4(Silk.NET.Maths.Vector4D from) -> System.Numerics.Vector4 static Silk.NET.Maths.Vector4D.implicit operator (T X, T Y, T Z, T W)(Silk.NET.Maths.Vector4D v) -> (T X, T Y, T Z, T W) static Silk.NET.Maths.Vector4D.implicit operator Silk.NET.Maths.Vector4D((T X, T Y, T Z, T W) v) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.One.get -> Silk.NET.Maths.Vector4D diff --git a/sources/Maths/Maths/Vector2D.cs b/sources/Maths/Maths/Vector2D.cs index 5ddbc35e62..971c5efd73 100644 --- a/sources/Maths/Maths/Vector2D.cs +++ b/sources/Maths/Maths/Vector2D.cs @@ -5,17 +5,6 @@ namespace Silk.NET.Maths { - public partial struct Vector2D - { - /// Explicitly casts a to a . - public static explicit operator Vector2D(Vector2 v) => - new Vector2D((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T))); - - /// Explicitly casts a to . - public static explicit operator Vector2(Vector2D v) => - new Vector2(Convert.ToSingle(v.X), Convert.ToSingle(v.Y)); - } - public static partial class Vector2D { /// Computes the cross product of two vectors. diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index a67f7666ac..cf5e86ad42 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -422,6 +422,22 @@ public static implicit operator (T X, T Y)(Vector2D v) => public static Vector2D operator /(Vector2D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar); + /// Converts a to a . + public static explicit operator Vector2D(Vector2 from) => + new(T.CreateTruncating(from.X), T.CreateTruncating(from.Y)); + + /// Converts a to a . + public static explicit operator checked Vector2D(Vector2 from) => + new(T.CreateChecked(from.X), T.CreateChecked(from.Y)); + + /// Converts a to . + public static explicit operator Vector2(Vector2D from) => + new(float.CreateTruncating(from.X), float.CreateTruncating(from.Y)); + + /// Converts a to . + public static explicit operator checked Vector2(Vector2D from) => + new(float.CreateChecked(from.X), float.CreateChecked(from.Y)); + /// /// Converts a vector of into one with an underlying type of . /// diff --git a/sources/Maths/Maths/Vector3D.cs b/sources/Maths/Maths/Vector3D.cs index 3cc0606531..ae19df2159 100644 --- a/sources/Maths/Maths/Vector3D.cs +++ b/sources/Maths/Maths/Vector3D.cs @@ -5,17 +5,6 @@ namespace Silk.NET.Maths { - public partial struct Vector3D - { - /// Explicitly casts a to a . - public static explicit operator Vector3D(Vector3 v) => - new Vector3D((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T))); - - /// Explicitly casts a to . - public static explicit operator Vector3(Vector3D v) => - new Vector3(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z)); - } - public static partial class Vector3D { /// Computes the cross product of two vectors. diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index bacb3f7666..62ef495c5d 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -459,6 +459,22 @@ public static implicit operator (T X, T Y, T Z)(Vector3D v) => public static Vector3D operator /(Vector3D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar); + /// Converts a to a . + public static explicit operator Vector3D(Vector3 from) => + new(T.CreateTruncating(from.X), T.CreateTruncating(from.Y), T.CreateTruncating(from.Z)); + + /// Converts a to a . + public static explicit operator checked Vector3D(Vector3 from) => + new(T.CreateChecked(from.X), T.CreateChecked(from.Y), T.CreateChecked(from.Z)); + + /// Converts a to . + public static explicit operator Vector3(Vector3D from) => + new(float.CreateTruncating(from.X), float.CreateTruncating(from.Y), float.CreateTruncating(from.Z)); + + /// Converts a to . + public static explicit operator checked Vector3(Vector3D from) => + new(float.CreateChecked(from.X), float.CreateChecked(from.Y), float.CreateChecked(from.Z)); + /// /// Converts a vector of into one with an underlying type of . /// diff --git a/sources/Maths/Maths/Vector4D.cs b/sources/Maths/Maths/Vector4D.cs deleted file mode 100644 index 9aeff8dfa9..0000000000 --- a/sources/Maths/Maths/Vector4D.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Numerics; - -namespace Silk.NET.Maths -{ - public partial struct Vector4D - { - /// Explicitly casts a to a . - public static explicit operator Vector4D(Vector4 v) => - new Vector4D((T)Convert.ChangeType(v.X, typeof(T)), (T)Convert.ChangeType(v.Y, typeof(T)), (T)Convert.ChangeType(v.Z, typeof(T)), (T)Convert.ChangeType(v.W, typeof(T))); - - /// Explicitly casts a to . - public static explicit operator Vector4(Vector4D v) => - new Vector4(Convert.ToSingle(v.X), Convert.ToSingle(v.Y), Convert.ToSingle(v.Z), Convert.ToSingle(v.W)); - } -} diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index eb76f897f8..ecf4747aaa 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -496,6 +496,22 @@ public static implicit operator (T X, T Y, T Z, T W)(Vector4D v) => public static Vector4D operator /(Vector4D vector, T scalar) => new(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); + /// Converts a to a . + public static explicit operator Vector4D(Vector4 from) => + new(T.CreateTruncating(from.X), T.CreateTruncating(from.Y), T.CreateTruncating(from.Z), T.CreateTruncating(from.W)); + + /// Converts a to a . + public static explicit operator checked Vector4D(Vector4 from) => + new(T.CreateChecked(from.X), T.CreateChecked(from.Y), T.CreateChecked(from.Z), T.CreateChecked(from.W)); + + /// Converts a to . + public static explicit operator Vector4(Vector4D from) => + new(float.CreateTruncating(from.X), float.CreateTruncating(from.Y), float.CreateTruncating(from.Z), float.CreateTruncating(from.W)); + + /// Converts a to . + public static explicit operator checked Vector4(Vector4D from) => + new(float.CreateChecked(from.X), float.CreateChecked(from.Y), float.CreateChecked(from.Z), float.CreateChecked(from.W)); + /// /// Converts a vector of into one with an underlying type of . /// From 43a813077f46260aed9f907fac4dd059e5499115 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 19 Jul 2025 19:31:44 -0700 Subject: [PATCH 62/67] Small fixup to pending Decompose method. --- sources/Maths/Maths/Matrix4X4.Ops.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/Maths/Maths/Matrix4X4.Ops.cs b/sources/Maths/Maths/Matrix4X4.Ops.cs index 8ed0783162..3f4a4b28cc 100644 --- a/sources/Maths/Maths/Matrix4X4.Ops.cs +++ b/sources/Maths/Maths/Matrix4X4.Ops.cs @@ -1208,7 +1208,7 @@ private static Vector128 Permute(Vector128 value, byte control) /// The translation component of the transformation matrix /// True if the source matrix was successfully decomposed; False otherwise. public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out Quaternion rotation, out Vector3D translation) - where T : INumberBase + where T : INumber, IRootFunctions, ITrigonometricFunctions { bool result = true; @@ -1385,13 +1385,13 @@ public static bool Decompose(Matrix4X4 matrix, out Vector3D scale, out if (!(T.CreateTruncating(DecomposeEpsilon) >= det)) { // Non-SRT matrix encountered - rotation = Legacy.Quaternion.Identity; + rotation = Quaternion.Identity; result = false; } else { // generate the quaternion from the matrix - rotation = Legacy.Quaternion.CreateFromRotationMatrix(matTemp); + rotation = Quaternion.CreateFromRotationMatrix(matTemp); } } } From 5d73712654f8bf3f23a7df04271b8a48d1cfabc8 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 19 Jul 2025 20:14:48 -0700 Subject: [PATCH 63/67] Use aggressive inlining for static properties. Use T.One and T.Zero for identity matrices. --- sources/Maths/Maths/Matrix2X2.gen.cs | 4 +-- sources/Maths/Maths/Matrix3X3.gen.cs | 6 ++--- sources/Maths/Maths/Matrix4X4.gen.cs | 8 +++--- sources/Maths/Maths/Vector2D.gen.cs | 25 ++++++++++++++++--- sources/Maths/Maths/Vector3D.gen.cs | 31 +++++++++++++++++++---- sources/Maths/Maths/Vector4D.gen.cs | 37 +++++++++++++++++++++++----- 6 files changed, 87 insertions(+), 24 deletions(-) diff --git a/sources/Maths/Maths/Matrix2X2.gen.cs b/sources/Maths/Maths/Matrix2X2.gen.cs index 094ff51275..a7ec0021c2 100644 --- a/sources/Maths/Maths/Matrix2X2.gen.cs +++ b/sources/Maths/Maths/Matrix2X2.gen.cs @@ -17,8 +17,8 @@ public partial struct Matrix2X2 : { /// Gets the multiplicative identity matrix of size 2x2. public static Matrix2X2 Identity { get; } = new( - new(T.MultiplicativeIdentity, T.Zero), - new(T.Zero, T.MultiplicativeIdentity)); + new(T.One, T.Zero), + new(T.Zero, T.One)); /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] diff --git a/sources/Maths/Maths/Matrix3X3.gen.cs b/sources/Maths/Maths/Matrix3X3.gen.cs index 7a5f1ffaf3..37afef295b 100644 --- a/sources/Maths/Maths/Matrix3X3.gen.cs +++ b/sources/Maths/Maths/Matrix3X3.gen.cs @@ -17,9 +17,9 @@ public partial struct Matrix3X3 : { /// Gets the multiplicative identity matrix of size 3x3. public static Matrix3X3 Identity { get; } = new( - new(T.MultiplicativeIdentity, T.Zero, T.Zero), - new(T.Zero, T.MultiplicativeIdentity, T.Zero), - new(T.Zero, T.Zero, T.MultiplicativeIdentity)); + new(T.One, T.Zero, T.Zero), + new(T.Zero, T.One, T.Zero), + new(T.Zero, T.Zero, T.One)); /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] diff --git a/sources/Maths/Maths/Matrix4X4.gen.cs b/sources/Maths/Maths/Matrix4X4.gen.cs index c6e64ccf31..53c9fb4eb6 100644 --- a/sources/Maths/Maths/Matrix4X4.gen.cs +++ b/sources/Maths/Maths/Matrix4X4.gen.cs @@ -17,10 +17,10 @@ public partial struct Matrix4X4 : { /// Gets the multiplicative identity matrix of size 4x4. public static Matrix4X4 Identity { get; } = new( - new(T.MultiplicativeIdentity, T.Zero, T.Zero, T.Zero), - new(T.Zero, T.MultiplicativeIdentity, T.Zero, T.Zero), - new(T.Zero, T.Zero, T.MultiplicativeIdentity, T.Zero), - new(T.Zero, T.Zero, T.Zero, T.MultiplicativeIdentity)); + new(T.One, T.Zero, T.Zero, T.Zero), + new(T.Zero, T.One, T.Zero, T.Zero), + new(T.Zero, T.Zero, T.One, T.Zero), + new(T.Zero, T.Zero, T.Zero, T.One)); /// Returns whether the matrix is the identity matrix. [IgnoreDataMember] diff --git a/sources/Maths/Maths/Vector2D.gen.cs b/sources/Maths/Maths/Vector2D.gen.cs index cf5e86ad42..77783887a9 100644 --- a/sources/Maths/Maths/Vector2D.gen.cs +++ b/sources/Maths/Maths/Vector2D.gen.cs @@ -6,6 +6,7 @@ namespace Silk.NET.Maths using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; @@ -22,16 +23,32 @@ public partial struct Vector2D : where T : INumberBase { /// Gets a vector whose 2 elements are equal to one. - public static Vector2D One => new(T.One); + public static Vector2D One + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.One); + } /// Returns a vector whose 2 elements are equal to zero. - public static Vector2D Zero => default; + public static Vector2D Zero + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.Zero); + } /// Gets the vector (1, 0). - public static Vector2D UnitX => new(T.One, T.Zero); + public static Vector2D UnitX + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.One, T.Zero); + } /// Gets the vector (0, 1). - public static Vector2D UnitY => new(T.Zero, T.One); + public static Vector2D UnitY + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.Zero, T.One); + } /// The X component of the vector. public T X; diff --git a/sources/Maths/Maths/Vector3D.gen.cs b/sources/Maths/Maths/Vector3D.gen.cs index 62ef495c5d..73b7c614e0 100644 --- a/sources/Maths/Maths/Vector3D.gen.cs +++ b/sources/Maths/Maths/Vector3D.gen.cs @@ -6,6 +6,7 @@ namespace Silk.NET.Maths using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; @@ -22,19 +23,39 @@ public partial struct Vector3D : where T : INumberBase { /// Gets a vector whose 3 elements are equal to one. - public static Vector3D One => new(T.One); + public static Vector3D One + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.One); + } /// Returns a vector whose 3 elements are equal to zero. - public static Vector3D Zero => default; + public static Vector3D Zero + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.Zero); + } /// Gets the vector (1, 0, 0). - public static Vector3D UnitX => new(T.One, T.Zero, T.Zero); + public static Vector3D UnitX + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.One, T.Zero, T.Zero); + } /// Gets the vector (0, 1, 0). - public static Vector3D UnitY => new(T.Zero, T.One, T.Zero); + public static Vector3D UnitY + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.Zero, T.One, T.Zero); + } /// Gets the vector (0, 0, 1). - public static Vector3D UnitZ => new(T.Zero, T.Zero, T.One); + public static Vector3D UnitZ + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.Zero, T.Zero, T.One); + } /// The X component of the vector. public T X; diff --git a/sources/Maths/Maths/Vector4D.gen.cs b/sources/Maths/Maths/Vector4D.gen.cs index ecf4747aaa..e2c1c78e01 100644 --- a/sources/Maths/Maths/Vector4D.gen.cs +++ b/sources/Maths/Maths/Vector4D.gen.cs @@ -6,6 +6,7 @@ namespace Silk.NET.Maths using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Numerics; + using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; @@ -22,22 +23,46 @@ public partial struct Vector4D : where T : INumberBase { /// Gets a vector whose 4 elements are equal to one. - public static Vector4D One => new(T.One); + public static Vector4D One + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.One); + } /// Returns a vector whose 4 elements are equal to zero. - public static Vector4D Zero => default; + public static Vector4D Zero + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.Zero); + } /// Gets the vector (1, 0, 0, 0). - public static Vector4D UnitX => new(T.One, T.Zero, T.Zero, T.Zero); + public static Vector4D UnitX + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.One, T.Zero, T.Zero, T.Zero); + } /// Gets the vector (0, 1, 0, 0). - public static Vector4D UnitY => new(T.Zero, T.One, T.Zero, T.Zero); + public static Vector4D UnitY + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.Zero, T.One, T.Zero, T.Zero); + } /// Gets the vector (0, 0, 1, 0). - public static Vector4D UnitZ => new(T.Zero, T.Zero, T.One, T.Zero); + public static Vector4D UnitZ + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.Zero, T.Zero, T.One, T.Zero); + } /// Gets the vector (0, 0, 0, 1). - public static Vector4D UnitW => new(T.Zero, T.Zero, T.Zero, T.One); + public static Vector4D UnitW + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get => new(T.Zero, T.Zero, T.Zero, T.One); + } /// The X component of the vector. public T X; From 6ae88de1494b3fbc69ce9d92bae41f58cb23941b Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 19 Jul 2025 21:29:01 -0700 Subject: [PATCH 64/67] Rename vector operation files. --- sources/Maths/Maths/{Vector2D.cs => Vector2D.Ops.cs} | 0 sources/Maths/Maths/{Vector3D.cs => Vector3D.Ops.cs} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename sources/Maths/Maths/{Vector2D.cs => Vector2D.Ops.cs} (100%) rename sources/Maths/Maths/{Vector3D.cs => Vector3D.Ops.cs} (100%) diff --git a/sources/Maths/Maths/Vector2D.cs b/sources/Maths/Maths/Vector2D.Ops.cs similarity index 100% rename from sources/Maths/Maths/Vector2D.cs rename to sources/Maths/Maths/Vector2D.Ops.cs diff --git a/sources/Maths/Maths/Vector3D.cs b/sources/Maths/Maths/Vector3D.Ops.cs similarity index 100% rename from sources/Maths/Maths/Vector3D.cs rename to sources/Maths/Maths/Vector3D.Ops.cs From 516c52ed530b1ee1f5d256fde57c8614029a8089 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sun, 21 Sep 2025 15:21:39 -0700 Subject: [PATCH 65/67] Removed `this` modifiers from generated extension methods. Added MultiplyAddEstimate. --- sources/Maths/Maths/Vector2D.Ops.gen.cs | 208 ++++++++++++++---------- sources/Maths/Maths/Vector3D.Ops.cs | 2 +- sources/Maths/Maths/Vector3D.Ops.gen.cs | 208 ++++++++++++++---------- sources/Maths/Maths/Vector4D.Ops.gen.cs | 208 ++++++++++++++---------- 4 files changed, 361 insertions(+), 265 deletions(-) diff --git a/sources/Maths/Maths/Vector2D.Ops.gen.cs b/sources/Maths/Maths/Vector2D.Ops.gen.cs index 15469506ff..dac99096fa 100644 --- a/sources/Maths/Maths/Vector2D.Ops.gen.cs +++ b/sources/Maths/Maths/Vector2D.Ops.gen.cs @@ -38,7 +38,7 @@ public static void Deconstruct(this Vector2D vector, out T x, out T y) } /// Computes the dot product of two vectors. - public static T Dot(this Vector2D left, Vector2D right) + public static T Dot(Vector2D left, Vector2D right) where T : INumberBase => left.X * right.X + left.Y * right.Y; @@ -90,13 +90,13 @@ public static Vector2D LerpClamped(Vector2D a, Vector2D b, Vector2D< /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static (Vector2D Sin, Vector2D Cos) SinCos(this Vector2D x) + public static (Vector2D Sin, Vector2D Cos) SinCos(Vector2D x) where T : ITrigonometricFunctions => (new(T.Sin(x.X), T.Sin(x.Y)), new(T.Cos(x.X), T.Cos(x.Y))); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static (Vector2D SinPi, Vector2D CosPi) SinCosPi(this Vector2D x) + public static (Vector2D SinPi, Vector2D CosPi) SinCosPi(Vector2D x) where T : ITrigonometricFunctions => (new(T.SinPi(x.X), T.SinPi(x.Y)), new(T.CosPi(x.X), T.CosPi(x.Y))); @@ -129,63 +129,63 @@ public static Vector2D Multiply(T left, Vector2D right) /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Sign(this Vector2D value) + public static Vector2D Sign(Vector2D value) where TSelf : INumber => new(TSelf.Sign(value.X), TSelf.Sign(value.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D Max(this Vector2D x, Vector2D y) + public static Vector2D Max(Vector2D x, Vector2D y) where TSelf : INumber => new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D Max(this Vector2D x, TSelf y) + public static Vector2D Max(Vector2D x, TSelf y) where TSelf : INumber => new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D MaxNumber(this Vector2D x, Vector2D y) + public static Vector2D MaxNumber(Vector2D x, Vector2D y) where TSelf : INumber => new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D MaxNumber(this Vector2D x, TSelf y) + public static Vector2D MaxNumber(Vector2D x, TSelf y) where TSelf : INumber => new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D Min(this Vector2D x, Vector2D y) + public static Vector2D Min(Vector2D x, Vector2D y) where TSelf : INumber => new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D Min(this Vector2D x, TSelf y) + public static Vector2D Min(Vector2D x, TSelf y) where TSelf : INumber => new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D MinNumber(this Vector2D x, Vector2D y) + public static Vector2D MinNumber(Vector2D x, Vector2D y) where TSelf : INumber => new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D MinNumber(this Vector2D x, TSelf y) + public static Vector2D MinNumber(Vector2D x, TSelf y) where TSelf : INumber => new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y)); @@ -193,7 +193,7 @@ public static Vector2D MinNumber(this Vector2D x, TSelf y) /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D Clamp(this Vector2D value, Vector2D min, Vector2D max) + public static Vector2D Clamp(Vector2D value, Vector2D min, Vector2D max) where TSelf : INumber => new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y)); @@ -201,99 +201,131 @@ public static Vector2D Clamp(this Vector2D value, Vector2D< /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector2D Clamp(this Vector2D value, TSelf min, TSelf max) + public static Vector2D Clamp(Vector2D value, TSelf min, TSelf max) where TSelf : INumber => new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D CopySign(this Vector2D value, Vector2D sign) + public static Vector2D CopySign(Vector2D value, Vector2D sign) where TSelf : INumber => new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D CopySign(this Vector2D value, TSelf sign) + public static Vector2D CopySign(Vector2D value, TSelf sign) where TSelf : INumber => new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Abs(this Vector2D value) + public static Vector2D Abs(Vector2D value) where TSelf : INumberBase => new(TSelf.Abs(value.X), TSelf.Abs(value.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D MaxMagnitude(this Vector2D x, Vector2D y) + public static Vector2D MaxMagnitude(Vector2D x, Vector2D y) where TSelf : INumberBase => new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D MaxMagnitudeNumber(this Vector2D x, Vector2D y) + public static Vector2D MaxMagnitudeNumber(Vector2D x, Vector2D y) where TSelf : INumberBase => new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D MinMagnitude(this Vector2D x, Vector2D y) + public static Vector2D MinMagnitude(Vector2D x, Vector2D y) where TSelf : INumberBase => new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D MinMagnitudeNumber(this Vector2D x, Vector2D y) + public static Vector2D MinMagnitudeNumber(Vector2D x, Vector2D y) where TSelf : INumberBase => new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector2D MultiplyAddEstimate(Vector2D left, Vector2D right, Vector2D addend) + where TSelf : INumberBase => + new(TSelf.MultiplyAddEstimate(left.X, right.X, addend.X), TSelf.MultiplyAddEstimate(left.Y, right.Y, addend.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector2D MultiplyAddEstimate(Vector2D left, Vector2D right, TSelf addend) + where TSelf : INumberBase => + new(TSelf.MultiplyAddEstimate(left.X, right.X, addend), TSelf.MultiplyAddEstimate(left.Y, right.Y, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A vector whose members will be provided for . + public static Vector2D MultiplyAddEstimate(Vector2D left, TSelf right, Vector2D addend) + where TSelf : INumberBase => + new(TSelf.MultiplyAddEstimate(left.X, right, addend.X), TSelf.MultiplyAddEstimate(left.Y, right, addend.Y)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector2D MultiplyAddEstimate(Vector2D left, TSelf right, TSelf addend) + where TSelf : INumberBase => + new(TSelf.MultiplyAddEstimate(left.X, right, addend), TSelf.MultiplyAddEstimate(left.Y, right, addend)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D PopCount(this Vector2D value) + public static Vector2D PopCount(Vector2D value) where TSelf : IBinaryInteger => new(TSelf.PopCount(value.X), TSelf.PopCount(value.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D TrailingZeroCount(this Vector2D value) + public static Vector2D TrailingZeroCount(Vector2D value) where TSelf : IBinaryInteger => new(TSelf.TrailingZeroCount(value.X), TSelf.TrailingZeroCount(value.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Ceiling(this Vector2D x) + public static Vector2D Ceiling(Vector2D x) where TSelf : IFloatingPoint => new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Floor(this Vector2D x) + public static Vector2D Floor(Vector2D x) where TSelf : IFloatingPoint => new(TSelf.Floor(x.X), TSelf.Floor(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Round(this Vector2D x) + public static Vector2D Round(Vector2D x) where TSelf : IFloatingPoint => new(TSelf.Round(x.X), TSelf.Round(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D Round(this Vector2D x, int digits) + public static Vector2D Round(Vector2D x, int digits) where TSelf : IFloatingPoint => new(TSelf.Round(x.X, digits), TSelf.Round(x.Y, digits)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D Round(this Vector2D x, MidpointRounding mode) + public static Vector2D Round(Vector2D x, MidpointRounding mode) where TSelf : IFloatingPoint => new(TSelf.Round(x.X, mode), TSelf.Round(x.Y, mode)); @@ -301,27 +333,27 @@ public static Vector2D Round(this Vector2D x, MidpointRound /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector2D Round(this Vector2D x, int digits, MidpointRounding mode) + public static Vector2D Round(Vector2D x, int digits, MidpointRounding mode) where TSelf : IFloatingPoint => new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Truncate(this Vector2D x) + public static Vector2D Truncate(Vector2D x) where TSelf : IFloatingPoint => new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D Atan2(this Vector2D y, Vector2D x) + public static Vector2D Atan2(Vector2D y, Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D Atan2Pi(this Vector2D y, Vector2D x) + public static Vector2D Atan2Pi(Vector2D y, Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y)); @@ -329,19 +361,19 @@ public static Vector2D Atan2Pi(this Vector2D y, Vector2DA vector whose members will be provided for . /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D Lerp(this Vector2D value1, Vector2D value2, TSelf amount) + public static Vector2D Lerp(Vector2D value1, Vector2D value2, TSelf amount) where TSelf : IFloatingPointIeee754 => new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D BitDecrement(this Vector2D x) + public static Vector2D BitDecrement(Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D BitIncrement(this Vector2D x) + public static Vector2D BitIncrement(Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y)); @@ -349,7 +381,7 @@ public static Vector2D BitIncrement(this Vector2D x) /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D FusedMultiplyAdd(this Vector2D left, Vector2D right, Vector2D addend) + public static Vector2D FusedMultiplyAdd(Vector2D left, Vector2D right, Vector2D addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y)); @@ -357,7 +389,7 @@ public static Vector2D FusedMultiplyAdd(this Vector2D left, /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D FusedMultiplyAdd(this Vector2D left, Vector2D right, TSelf addend) + public static Vector2D FusedMultiplyAdd(Vector2D left, Vector2D right, TSelf addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right.X, addend), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend)); @@ -365,7 +397,7 @@ public static Vector2D FusedMultiplyAdd(this Vector2D left, /// A vector whose members will be provided for . /// A single value provided for . /// A vector whose members will be provided for . - public static Vector2D FusedMultiplyAdd(this Vector2D left, TSelf right, Vector2D addend) + public static Vector2D FusedMultiplyAdd(Vector2D left, TSelf right, Vector2D addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right, addend.X), TSelf.FusedMultiplyAdd(left.Y, right, addend.Y)); @@ -373,313 +405,313 @@ public static Vector2D FusedMultiplyAdd(this Vector2D left, /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector2D FusedMultiplyAdd(this Vector2D left, TSelf right, TSelf addend) + public static Vector2D FusedMultiplyAdd(Vector2D left, TSelf right, TSelf addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D Ieee754Remainder(this Vector2D left, Vector2D right) + public static Vector2D Ieee754Remainder(Vector2D left, Vector2D right) where TSelf : IFloatingPointIeee754 => new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D Ieee754Remainder(this Vector2D left, TSelf right) + public static Vector2D Ieee754Remainder(Vector2D left, TSelf right) where TSelf : IFloatingPointIeee754 => new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D ILogB(this Vector2D x) + public static Vector2D ILogB(Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D ReciprocalEstimate(this Vector2D x) + public static Vector2D ReciprocalEstimate(Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D ReciprocalSqrtEstimate(this Vector2D x) + public static Vector2D ReciprocalSqrtEstimate(Vector2D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D ScaleB(this Vector2D x, Vector2D n) + public static Vector2D ScaleB(Vector2D x, Vector2D n) where TSelf : IFloatingPointIeee754 => new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D ScaleB(this Vector2D x, int n) + public static Vector2D ScaleB(Vector2D x, int n) where TSelf : IFloatingPointIeee754 => new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D Pow(this Vector2D x, Vector2D y) + public static Vector2D Pow(Vector2D x, Vector2D y) where TSelf : IPowerFunctions => new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D Pow(this Vector2D x, TSelf y) + public static Vector2D Pow(Vector2D x, TSelf y) where TSelf : IPowerFunctions => new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Cbrt(this Vector2D x) + public static Vector2D Cbrt(Vector2D x) where TSelf : IRootFunctions => new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Sqrt(this Vector2D x) + public static Vector2D Sqrt(Vector2D x) where TSelf : IRootFunctions => new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D RootN(this Vector2D x, int n) + public static Vector2D RootN(Vector2D x, int n) where TSelf : IRootFunctions => new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D RootN(this Vector2D x, Vector2D n) + public static Vector2D RootN(Vector2D x, Vector2D n) where TSelf : IRootFunctions => new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D Hypot(this Vector2D x, Vector2D y) + public static Vector2D Hypot(Vector2D x, Vector2D y) where TSelf : IRootFunctions => new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D Hypot(this Vector2D x, TSelf y) + public static Vector2D Hypot(Vector2D x, TSelf y) where TSelf : IRootFunctions => new(TSelf.Hypot(x.X, y), TSelf.Hypot(x.Y, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Log(this Vector2D x) + public static Vector2D Log(Vector2D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector2D Log(this Vector2D x, Vector2D newBase) + public static Vector2D Log(Vector2D x, Vector2D newBase) where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector2D Log(this Vector2D x, TSelf newBase) + public static Vector2D Log(Vector2D x, TSelf newBase) where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D LogP1(this Vector2D x) + public static Vector2D LogP1(Vector2D x) where TSelf : ILogarithmicFunctions => new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Log2(this Vector2D x) + public static Vector2D Log2(Vector2D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log2(x.X), TSelf.Log2(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Log2P1(this Vector2D x) + public static Vector2D Log2P1(Vector2D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Log10(this Vector2D x) + public static Vector2D Log10(Vector2D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log10(x.X), TSelf.Log10(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Log10P1(this Vector2D x) + public static Vector2D Log10P1(Vector2D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Exp(this Vector2D x) + public static Vector2D Exp(Vector2D x) where TSelf : IExponentialFunctions => new(TSelf.Exp(x.X), TSelf.Exp(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D ExpM1(this Vector2D x) + public static Vector2D ExpM1(Vector2D x) where TSelf : IExponentialFunctions => new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Exp2(this Vector2D x) + public static Vector2D Exp2(Vector2D x) where TSelf : IExponentialFunctions => new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Exp2M1(this Vector2D x) + public static Vector2D Exp2M1(Vector2D x) where TSelf : IExponentialFunctions => new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Exp10(this Vector2D x) + public static Vector2D Exp10(Vector2D x) where TSelf : IExponentialFunctions => new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Exp10M1(this Vector2D x) + public static Vector2D Exp10M1(Vector2D x) where TSelf : IExponentialFunctions => new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Acos(this Vector2D x) + public static Vector2D Acos(Vector2D x) where TSelf : ITrigonometricFunctions => new(TSelf.Acos(x.X), TSelf.Acos(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D AcosPi(this Vector2D x) + public static Vector2D AcosPi(Vector2D x) where TSelf : ITrigonometricFunctions => new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Asin(this Vector2D x) + public static Vector2D Asin(Vector2D x) where TSelf : ITrigonometricFunctions => new(TSelf.Asin(x.X), TSelf.Asin(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D AsinPi(this Vector2D x) + public static Vector2D AsinPi(Vector2D x) where TSelf : ITrigonometricFunctions => new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Atan(this Vector2D x) + public static Vector2D Atan(Vector2D x) where TSelf : ITrigonometricFunctions => new(TSelf.Atan(x.X), TSelf.Atan(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D AtanPi(this Vector2D x) + public static Vector2D AtanPi(Vector2D x) where TSelf : ITrigonometricFunctions => new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Cos(this Vector2D x) + public static Vector2D Cos(Vector2D x) where TSelf : ITrigonometricFunctions => new(TSelf.Cos(x.X), TSelf.Cos(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D CosPi(this Vector2D x) + public static Vector2D CosPi(Vector2D x) where TSelf : ITrigonometricFunctions => new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Sin(this Vector2D x) + public static Vector2D Sin(Vector2D x) where TSelf : ITrigonometricFunctions => new(TSelf.Sin(x.X), TSelf.Sin(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D SinPi(this Vector2D x) + public static Vector2D SinPi(Vector2D x) where TSelf : ITrigonometricFunctions => new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Tan(this Vector2D x) + public static Vector2D Tan(Vector2D x) where TSelf : ITrigonometricFunctions => new(TSelf.Tan(x.X), TSelf.Tan(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D TanPi(this Vector2D x) + public static Vector2D TanPi(Vector2D x) where TSelf : ITrigonometricFunctions => new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D DegreesToRadians(this Vector2D degrees) + public static Vector2D DegreesToRadians(Vector2D degrees) where TSelf : ITrigonometricFunctions => new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D RadiansToDegrees(this Vector2D radians) + public static Vector2D RadiansToDegrees(Vector2D radians) where TSelf : ITrigonometricFunctions => new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Acosh(this Vector2D x) + public static Vector2D Acosh(Vector2D x) where TSelf : IHyperbolicFunctions => new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Asinh(this Vector2D x) + public static Vector2D Asinh(Vector2D x) where TSelf : IHyperbolicFunctions => new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Atanh(this Vector2D x) + public static Vector2D Atanh(Vector2D x) where TSelf : IHyperbolicFunctions => new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Cosh(this Vector2D x) + public static Vector2D Cosh(Vector2D x) where TSelf : IHyperbolicFunctions => new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Sinh(this Vector2D x) + public static Vector2D Sinh(Vector2D x) where TSelf : IHyperbolicFunctions => new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector2D Tanh(this Vector2D x) + public static Vector2D Tanh(Vector2D x) where TSelf : IHyperbolicFunctions => new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y)); } diff --git a/sources/Maths/Maths/Vector3D.Ops.cs b/sources/Maths/Maths/Vector3D.Ops.cs index ae19df2159..e5ee09279f 100644 --- a/sources/Maths/Maths/Vector3D.Ops.cs +++ b/sources/Maths/Maths/Vector3D.Ops.cs @@ -8,7 +8,7 @@ namespace Silk.NET.Maths public static partial class Vector3D { /// Computes the cross product of two vectors. - public static Vector3D Cross(this Vector3D left, Vector3D right) + public static Vector3D Cross(Vector3D left, Vector3D right) where T : INumberBase => new Vector3D( (left.Y * right.Z) - (left.Z * right.Y), diff --git a/sources/Maths/Maths/Vector3D.Ops.gen.cs b/sources/Maths/Maths/Vector3D.Ops.gen.cs index dcbd4f369a..fd9f024e48 100644 --- a/sources/Maths/Maths/Vector3D.Ops.gen.cs +++ b/sources/Maths/Maths/Vector3D.Ops.gen.cs @@ -40,7 +40,7 @@ public static void Deconstruct(this Vector3D vector, out T x, out T y, out } /// Computes the dot product of two vectors. - public static T Dot(this Vector3D left, Vector3D right) + public static T Dot(Vector3D left, Vector3D right) where T : INumberBase => left.X * right.X + left.Y * right.Y + left.Z * right.Z; @@ -93,13 +93,13 @@ public static Vector3D LerpClamped(Vector3D a, Vector3D b, Vector3D< /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static (Vector3D Sin, Vector3D Cos) SinCos(this Vector3D x) + public static (Vector3D Sin, Vector3D Cos) SinCos(Vector3D x) where T : ITrigonometricFunctions => (new(T.Sin(x.X), T.Sin(x.Y), T.Sin(x.Z)), new(T.Cos(x.X), T.Cos(x.Y), T.Cos(x.Z))); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static (Vector3D SinPi, Vector3D CosPi) SinCosPi(this Vector3D x) + public static (Vector3D SinPi, Vector3D CosPi) SinCosPi(Vector3D x) where T : ITrigonometricFunctions => (new(T.SinPi(x.X), T.SinPi(x.Y), T.SinPi(x.Z)), new(T.CosPi(x.X), T.CosPi(x.Y), T.CosPi(x.Z))); @@ -133,63 +133,63 @@ public static Vector3D Multiply(T left, Vector3D right) /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Sign(this Vector3D value) + public static Vector3D Sign(Vector3D value) where TSelf : INumber => new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D Max(this Vector3D x, Vector3D y) + public static Vector3D Max(Vector3D x, Vector3D y) where TSelf : INumber => new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D Max(this Vector3D x, TSelf y) + public static Vector3D Max(Vector3D x, TSelf y) where TSelf : INumber => new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D MaxNumber(this Vector3D x, Vector3D y) + public static Vector3D MaxNumber(Vector3D x, Vector3D y) where TSelf : INumber => new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D MaxNumber(this Vector3D x, TSelf y) + public static Vector3D MaxNumber(Vector3D x, TSelf y) where TSelf : INumber => new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D Min(this Vector3D x, Vector3D y) + public static Vector3D Min(Vector3D x, Vector3D y) where TSelf : INumber => new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D Min(this Vector3D x, TSelf y) + public static Vector3D Min(Vector3D x, TSelf y) where TSelf : INumber => new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D MinNumber(this Vector3D x, Vector3D y) + public static Vector3D MinNumber(Vector3D x, Vector3D y) where TSelf : INumber => new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D MinNumber(this Vector3D x, TSelf y) + public static Vector3D MinNumber(Vector3D x, TSelf y) where TSelf : INumber => new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y)); @@ -197,7 +197,7 @@ public static Vector3D MinNumber(this Vector3D x, TSelf y) /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D Clamp(this Vector3D value, Vector3D min, Vector3D max) + public static Vector3D Clamp(Vector3D value, Vector3D min, Vector3D max) where TSelf : INumber => new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z)); @@ -205,99 +205,131 @@ public static Vector3D Clamp(this Vector3D value, Vector3D< /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector3D Clamp(this Vector3D value, TSelf min, TSelf max) + public static Vector3D Clamp(Vector3D value, TSelf min, TSelf max) where TSelf : INumber => new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D CopySign(this Vector3D value, Vector3D sign) + public static Vector3D CopySign(Vector3D value, Vector3D sign) where TSelf : INumber => new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D CopySign(this Vector3D value, TSelf sign) + public static Vector3D CopySign(Vector3D value, TSelf sign) where TSelf : INumber => new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Abs(this Vector3D value) + public static Vector3D Abs(Vector3D value) where TSelf : INumberBase => new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D MaxMagnitude(this Vector3D x, Vector3D y) + public static Vector3D MaxMagnitude(Vector3D x, Vector3D y) where TSelf : INumberBase => new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D MaxMagnitudeNumber(this Vector3D x, Vector3D y) + public static Vector3D MaxMagnitudeNumber(Vector3D x, Vector3D y) where TSelf : INumberBase => new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D MinMagnitude(this Vector3D x, Vector3D y) + public static Vector3D MinMagnitude(Vector3D x, Vector3D y) where TSelf : INumberBase => new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D MinMagnitudeNumber(this Vector3D x, Vector3D y) + public static Vector3D MinMagnitudeNumber(Vector3D x, Vector3D y) where TSelf : INumberBase => new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector3D MultiplyAddEstimate(Vector3D left, Vector3D right, Vector3D addend) + where TSelf : INumberBase => + new(TSelf.MultiplyAddEstimate(left.X, right.X, addend.X), TSelf.MultiplyAddEstimate(left.Y, right.Y, addend.Y), TSelf.MultiplyAddEstimate(left.Z, right.Z, addend.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector3D MultiplyAddEstimate(Vector3D left, Vector3D right, TSelf addend) + where TSelf : INumberBase => + new(TSelf.MultiplyAddEstimate(left.X, right.X, addend), TSelf.MultiplyAddEstimate(left.Y, right.Y, addend), TSelf.MultiplyAddEstimate(left.Z, right.Z, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A vector whose members will be provided for . + public static Vector3D MultiplyAddEstimate(Vector3D left, TSelf right, Vector3D addend) + where TSelf : INumberBase => + new(TSelf.MultiplyAddEstimate(left.X, right, addend.X), TSelf.MultiplyAddEstimate(left.Y, right, addend.Y), TSelf.MultiplyAddEstimate(left.Z, right, addend.Z)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector3D MultiplyAddEstimate(Vector3D left, TSelf right, TSelf addend) + where TSelf : INumberBase => + new(TSelf.MultiplyAddEstimate(left.X, right, addend), TSelf.MultiplyAddEstimate(left.Y, right, addend), TSelf.MultiplyAddEstimate(left.Z, right, addend)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D PopCount(this Vector3D value) + public static Vector3D PopCount(Vector3D value) where TSelf : IBinaryInteger => new(TSelf.PopCount(value.X), TSelf.PopCount(value.Y), TSelf.PopCount(value.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D TrailingZeroCount(this Vector3D value) + public static Vector3D TrailingZeroCount(Vector3D value) where TSelf : IBinaryInteger => new(TSelf.TrailingZeroCount(value.X), TSelf.TrailingZeroCount(value.Y), TSelf.TrailingZeroCount(value.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Ceiling(this Vector3D x) + public static Vector3D Ceiling(Vector3D x) where TSelf : IFloatingPoint => new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y), TSelf.Ceiling(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Floor(this Vector3D x) + public static Vector3D Floor(Vector3D x) where TSelf : IFloatingPoint => new(TSelf.Floor(x.X), TSelf.Floor(x.Y), TSelf.Floor(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Round(this Vector3D x) + public static Vector3D Round(Vector3D x) where TSelf : IFloatingPoint => new(TSelf.Round(x.X), TSelf.Round(x.Y), TSelf.Round(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D Round(this Vector3D x, int digits) + public static Vector3D Round(Vector3D x, int digits) where TSelf : IFloatingPoint => new(TSelf.Round(x.X, digits), TSelf.Round(x.Y, digits), TSelf.Round(x.Z, digits)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D Round(this Vector3D x, MidpointRounding mode) + public static Vector3D Round(Vector3D x, MidpointRounding mode) where TSelf : IFloatingPoint => new(TSelf.Round(x.X, mode), TSelf.Round(x.Y, mode), TSelf.Round(x.Z, mode)); @@ -305,27 +337,27 @@ public static Vector3D Round(this Vector3D x, MidpointRound /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector3D Round(this Vector3D x, int digits, MidpointRounding mode) + public static Vector3D Round(Vector3D x, int digits, MidpointRounding mode) where TSelf : IFloatingPoint => new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode), TSelf.Round(x.Z, digits, mode)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Truncate(this Vector3D x) + public static Vector3D Truncate(Vector3D x) where TSelf : IFloatingPoint => new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y), TSelf.Truncate(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D Atan2(this Vector3D y, Vector3D x) + public static Vector3D Atan2(Vector3D y, Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y), TSelf.Atan2(y.Z, x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D Atan2Pi(this Vector3D y, Vector3D x) + public static Vector3D Atan2Pi(Vector3D y, Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y), TSelf.Atan2Pi(y.Z, x.Z)); @@ -333,19 +365,19 @@ public static Vector3D Atan2Pi(this Vector3D y, Vector3DA vector whose members will be provided for . /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D Lerp(this Vector3D value1, Vector3D value2, TSelf amount) + public static Vector3D Lerp(Vector3D value1, Vector3D value2, TSelf amount) where TSelf : IFloatingPointIeee754 => new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount), TSelf.Lerp(value1.Z, value2.Z, amount)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D BitDecrement(this Vector3D x) + public static Vector3D BitDecrement(Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y), TSelf.BitDecrement(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D BitIncrement(this Vector3D x) + public static Vector3D BitIncrement(Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y), TSelf.BitIncrement(x.Z)); @@ -353,7 +385,7 @@ public static Vector3D BitIncrement(this Vector3D x) /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D FusedMultiplyAdd(this Vector3D left, Vector3D right, Vector3D addend) + public static Vector3D FusedMultiplyAdd(Vector3D left, Vector3D right, Vector3D addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend.Z)); @@ -361,7 +393,7 @@ public static Vector3D FusedMultiplyAdd(this Vector3D left, /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D FusedMultiplyAdd(this Vector3D left, Vector3D right, TSelf addend) + public static Vector3D FusedMultiplyAdd(Vector3D left, Vector3D right, TSelf addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right.X, addend), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend)); @@ -369,7 +401,7 @@ public static Vector3D FusedMultiplyAdd(this Vector3D left, /// A vector whose members will be provided for . /// A single value provided for . /// A vector whose members will be provided for . - public static Vector3D FusedMultiplyAdd(this Vector3D left, TSelf right, Vector3D addend) + public static Vector3D FusedMultiplyAdd(Vector3D left, TSelf right, Vector3D addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right, addend.X), TSelf.FusedMultiplyAdd(left.Y, right, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right, addend.Z)); @@ -377,313 +409,313 @@ public static Vector3D FusedMultiplyAdd(this Vector3D left, /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector3D FusedMultiplyAdd(this Vector3D left, TSelf right, TSelf addend) + public static Vector3D FusedMultiplyAdd(Vector3D left, TSelf right, TSelf addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend), TSelf.FusedMultiplyAdd(left.Z, right, addend)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D Ieee754Remainder(this Vector3D left, Vector3D right) + public static Vector3D Ieee754Remainder(Vector3D left, Vector3D right) where TSelf : IFloatingPointIeee754 => new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y), TSelf.Ieee754Remainder(left.Z, right.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D Ieee754Remainder(this Vector3D left, TSelf right) + public static Vector3D Ieee754Remainder(Vector3D left, TSelf right) where TSelf : IFloatingPointIeee754 => new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right), TSelf.Ieee754Remainder(left.Z, right)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D ILogB(this Vector3D x) + public static Vector3D ILogB(Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y), TSelf.ILogB(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D ReciprocalEstimate(this Vector3D x) + public static Vector3D ReciprocalEstimate(Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y), TSelf.ReciprocalEstimate(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D ReciprocalSqrtEstimate(this Vector3D x) + public static Vector3D ReciprocalSqrtEstimate(Vector3D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y), TSelf.ReciprocalSqrtEstimate(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D ScaleB(this Vector3D x, Vector3D n) + public static Vector3D ScaleB(Vector3D x, Vector3D n) where TSelf : IFloatingPointIeee754 => new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y), TSelf.ScaleB(x.Z, n.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D ScaleB(this Vector3D x, int n) + public static Vector3D ScaleB(Vector3D x, int n) where TSelf : IFloatingPointIeee754 => new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n), TSelf.ScaleB(x.Z, n)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D Pow(this Vector3D x, Vector3D y) + public static Vector3D Pow(Vector3D x, Vector3D y) where TSelf : IPowerFunctions => new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y), TSelf.Pow(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D Pow(this Vector3D x, TSelf y) + public static Vector3D Pow(Vector3D x, TSelf y) where TSelf : IPowerFunctions => new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y), TSelf.Pow(x.Z, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Cbrt(this Vector3D x) + public static Vector3D Cbrt(Vector3D x) where TSelf : IRootFunctions => new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y), TSelf.Cbrt(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Sqrt(this Vector3D x) + public static Vector3D Sqrt(Vector3D x) where TSelf : IRootFunctions => new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y), TSelf.Sqrt(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D RootN(this Vector3D x, int n) + public static Vector3D RootN(Vector3D x, int n) where TSelf : IRootFunctions => new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n), TSelf.RootN(x.Z, n)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D RootN(this Vector3D x, Vector3D n) + public static Vector3D RootN(Vector3D x, Vector3D n) where TSelf : IRootFunctions => new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y), TSelf.RootN(x.Z, n.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D Hypot(this Vector3D x, Vector3D y) + public static Vector3D Hypot(Vector3D x, Vector3D y) where TSelf : IRootFunctions => new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y), TSelf.Hypot(x.Z, y.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D Hypot(this Vector3D x, TSelf y) + public static Vector3D Hypot(Vector3D x, TSelf y) where TSelf : IRootFunctions => new(TSelf.Hypot(x.X, y), TSelf.Hypot(x.Y, y), TSelf.Hypot(x.Z, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Log(this Vector3D x) + public static Vector3D Log(Vector3D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector3D Log(this Vector3D x, Vector3D newBase) + public static Vector3D Log(Vector3D x, Vector3D newBase) where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector3D Log(this Vector3D x, TSelf newBase) + public static Vector3D Log(Vector3D x, TSelf newBase) where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase), TSelf.Log(x.Z, newBase)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D LogP1(this Vector3D x) + public static Vector3D LogP1(Vector3D x) where TSelf : ILogarithmicFunctions => new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Log2(this Vector3D x) + public static Vector3D Log2(Vector3D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Log2P1(this Vector3D x) + public static Vector3D Log2P1(Vector3D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Log10(this Vector3D x) + public static Vector3D Log10(Vector3D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Log10P1(this Vector3D x) + public static Vector3D Log10P1(Vector3D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Exp(this Vector3D x) + public static Vector3D Exp(Vector3D x) where TSelf : IExponentialFunctions => new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D ExpM1(this Vector3D x) + public static Vector3D ExpM1(Vector3D x) where TSelf : IExponentialFunctions => new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Exp2(this Vector3D x) + public static Vector3D Exp2(Vector3D x) where TSelf : IExponentialFunctions => new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Exp2M1(this Vector3D x) + public static Vector3D Exp2M1(Vector3D x) where TSelf : IExponentialFunctions => new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Exp10(this Vector3D x) + public static Vector3D Exp10(Vector3D x) where TSelf : IExponentialFunctions => new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Exp10M1(this Vector3D x) + public static Vector3D Exp10M1(Vector3D x) where TSelf : IExponentialFunctions => new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Acos(this Vector3D x) + public static Vector3D Acos(Vector3D x) where TSelf : ITrigonometricFunctions => new(TSelf.Acos(x.X), TSelf.Acos(x.Y), TSelf.Acos(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D AcosPi(this Vector3D x) + public static Vector3D AcosPi(Vector3D x) where TSelf : ITrigonometricFunctions => new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y), TSelf.AcosPi(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Asin(this Vector3D x) + public static Vector3D Asin(Vector3D x) where TSelf : ITrigonometricFunctions => new(TSelf.Asin(x.X), TSelf.Asin(x.Y), TSelf.Asin(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D AsinPi(this Vector3D x) + public static Vector3D AsinPi(Vector3D x) where TSelf : ITrigonometricFunctions => new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y), TSelf.AsinPi(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Atan(this Vector3D x) + public static Vector3D Atan(Vector3D x) where TSelf : ITrigonometricFunctions => new(TSelf.Atan(x.X), TSelf.Atan(x.Y), TSelf.Atan(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D AtanPi(this Vector3D x) + public static Vector3D AtanPi(Vector3D x) where TSelf : ITrigonometricFunctions => new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y), TSelf.AtanPi(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Cos(this Vector3D x) + public static Vector3D Cos(Vector3D x) where TSelf : ITrigonometricFunctions => new(TSelf.Cos(x.X), TSelf.Cos(x.Y), TSelf.Cos(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D CosPi(this Vector3D x) + public static Vector3D CosPi(Vector3D x) where TSelf : ITrigonometricFunctions => new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y), TSelf.CosPi(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Sin(this Vector3D x) + public static Vector3D Sin(Vector3D x) where TSelf : ITrigonometricFunctions => new(TSelf.Sin(x.X), TSelf.Sin(x.Y), TSelf.Sin(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D SinPi(this Vector3D x) + public static Vector3D SinPi(Vector3D x) where TSelf : ITrigonometricFunctions => new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y), TSelf.SinPi(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Tan(this Vector3D x) + public static Vector3D Tan(Vector3D x) where TSelf : ITrigonometricFunctions => new(TSelf.Tan(x.X), TSelf.Tan(x.Y), TSelf.Tan(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D TanPi(this Vector3D x) + public static Vector3D TanPi(Vector3D x) where TSelf : ITrigonometricFunctions => new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y), TSelf.TanPi(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D DegreesToRadians(this Vector3D degrees) + public static Vector3D DegreesToRadians(Vector3D degrees) where TSelf : ITrigonometricFunctions => new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y), TSelf.DegreesToRadians(degrees.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D RadiansToDegrees(this Vector3D radians) + public static Vector3D RadiansToDegrees(Vector3D radians) where TSelf : ITrigonometricFunctions => new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y), TSelf.RadiansToDegrees(radians.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Acosh(this Vector3D x) + public static Vector3D Acosh(Vector3D x) where TSelf : IHyperbolicFunctions => new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y), TSelf.Acosh(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Asinh(this Vector3D x) + public static Vector3D Asinh(Vector3D x) where TSelf : IHyperbolicFunctions => new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y), TSelf.Asinh(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Atanh(this Vector3D x) + public static Vector3D Atanh(Vector3D x) where TSelf : IHyperbolicFunctions => new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y), TSelf.Atanh(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Cosh(this Vector3D x) + public static Vector3D Cosh(Vector3D x) where TSelf : IHyperbolicFunctions => new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y), TSelf.Cosh(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Sinh(this Vector3D x) + public static Vector3D Sinh(Vector3D x) where TSelf : IHyperbolicFunctions => new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y), TSelf.Sinh(x.Z)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector3D Tanh(this Vector3D x) + public static Vector3D Tanh(Vector3D x) where TSelf : IHyperbolicFunctions => new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y), TSelf.Tanh(x.Z)); } diff --git a/sources/Maths/Maths/Vector4D.Ops.gen.cs b/sources/Maths/Maths/Vector4D.Ops.gen.cs index aa844486f6..8819b66a1c 100644 --- a/sources/Maths/Maths/Vector4D.Ops.gen.cs +++ b/sources/Maths/Maths/Vector4D.Ops.gen.cs @@ -42,7 +42,7 @@ public static void Deconstruct(this Vector4D vector, out T x, out T y, out } /// Computes the dot product of two vectors. - public static T Dot(this Vector4D left, Vector4D right) + public static T Dot(Vector4D left, Vector4D right) where T : INumberBase => left.X * right.X + left.Y * right.Y + left.Z * right.Z + left.W * right.W; @@ -96,13 +96,13 @@ public static Vector4D LerpClamped(Vector4D a, Vector4D b, Vector4D< /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static (Vector4D Sin, Vector4D Cos) SinCos(this Vector4D x) + public static (Vector4D Sin, Vector4D Cos) SinCos(Vector4D x) where T : ITrigonometricFunctions => (new(T.Sin(x.X), T.Sin(x.Y), T.Sin(x.Z), T.Sin(x.W)), new(T.Cos(x.X), T.Cos(x.Y), T.Cos(x.Z), T.Cos(x.W))); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static (Vector4D SinPi, Vector4D CosPi) SinCosPi(this Vector4D x) + public static (Vector4D SinPi, Vector4D CosPi) SinCosPi(Vector4D x) where T : ITrigonometricFunctions => (new(T.SinPi(x.X), T.SinPi(x.Y), T.SinPi(x.Z), T.SinPi(x.W)), new(T.CosPi(x.X), T.CosPi(x.Y), T.CosPi(x.Z), T.CosPi(x.W))); @@ -137,63 +137,63 @@ public static Vector4D Multiply(T left, Vector4D right) /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Sign(this Vector4D value) + public static Vector4D Sign(Vector4D value) where TSelf : INumber => new(TSelf.Sign(value.X), TSelf.Sign(value.Y), TSelf.Sign(value.Z), TSelf.Sign(value.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D Max(this Vector4D x, Vector4D y) + public static Vector4D Max(Vector4D x, Vector4D y) where TSelf : INumber => new(TSelf.Max(x.X, y.X), TSelf.Max(x.Y, y.Y), TSelf.Max(x.Z, y.Z), TSelf.Max(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D Max(this Vector4D x, TSelf y) + public static Vector4D Max(Vector4D x, TSelf y) where TSelf : INumber => new(TSelf.Max(x.X, y), TSelf.Max(x.Y, y), TSelf.Max(x.Z, y), TSelf.Max(x.W, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D MaxNumber(this Vector4D x, Vector4D y) + public static Vector4D MaxNumber(Vector4D x, Vector4D y) where TSelf : INumber => new(TSelf.MaxNumber(x.X, y.X), TSelf.MaxNumber(x.Y, y.Y), TSelf.MaxNumber(x.Z, y.Z), TSelf.MaxNumber(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D MaxNumber(this Vector4D x, TSelf y) + public static Vector4D MaxNumber(Vector4D x, TSelf y) where TSelf : INumber => new(TSelf.MaxNumber(x.X, y), TSelf.MaxNumber(x.Y, y), TSelf.MaxNumber(x.Z, y), TSelf.MaxNumber(x.W, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D Min(this Vector4D x, Vector4D y) + public static Vector4D Min(Vector4D x, Vector4D y) where TSelf : INumber => new(TSelf.Min(x.X, y.X), TSelf.Min(x.Y, y.Y), TSelf.Min(x.Z, y.Z), TSelf.Min(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D Min(this Vector4D x, TSelf y) + public static Vector4D Min(Vector4D x, TSelf y) where TSelf : INumber => new(TSelf.Min(x.X, y), TSelf.Min(x.Y, y), TSelf.Min(x.Z, y), TSelf.Min(x.W, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D MinNumber(this Vector4D x, Vector4D y) + public static Vector4D MinNumber(Vector4D x, Vector4D y) where TSelf : INumber => new(TSelf.MinNumber(x.X, y.X), TSelf.MinNumber(x.Y, y.Y), TSelf.MinNumber(x.Z, y.Z), TSelf.MinNumber(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D MinNumber(this Vector4D x, TSelf y) + public static Vector4D MinNumber(Vector4D x, TSelf y) where TSelf : INumber => new(TSelf.MinNumber(x.X, y), TSelf.MinNumber(x.Y, y), TSelf.MinNumber(x.Z, y), TSelf.MinNumber(x.W, y)); @@ -201,7 +201,7 @@ public static Vector4D MinNumber(this Vector4D x, TSelf y) /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D Clamp(this Vector4D value, Vector4D min, Vector4D max) + public static Vector4D Clamp(Vector4D value, Vector4D min, Vector4D max) where TSelf : INumber => new(TSelf.Clamp(value.X, min.X, max.X), TSelf.Clamp(value.Y, min.Y, max.Y), TSelf.Clamp(value.Z, min.Z, max.Z), TSelf.Clamp(value.W, min.W, max.W)); @@ -209,99 +209,131 @@ public static Vector4D Clamp(this Vector4D value, Vector4D< /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector4D Clamp(this Vector4D value, TSelf min, TSelf max) + public static Vector4D Clamp(Vector4D value, TSelf min, TSelf max) where TSelf : INumber => new(TSelf.Clamp(value.X, min, max), TSelf.Clamp(value.Y, min, max), TSelf.Clamp(value.Z, min, max), TSelf.Clamp(value.W, min, max)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D CopySign(this Vector4D value, Vector4D sign) + public static Vector4D CopySign(Vector4D value, Vector4D sign) where TSelf : INumber => new(TSelf.CopySign(value.X, sign.X), TSelf.CopySign(value.Y, sign.Y), TSelf.CopySign(value.Z, sign.Z), TSelf.CopySign(value.W, sign.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D CopySign(this Vector4D value, TSelf sign) + public static Vector4D CopySign(Vector4D value, TSelf sign) where TSelf : INumber => new(TSelf.CopySign(value.X, sign), TSelf.CopySign(value.Y, sign), TSelf.CopySign(value.Z, sign), TSelf.CopySign(value.W, sign)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Abs(this Vector4D value) + public static Vector4D Abs(Vector4D value) where TSelf : INumberBase => new(TSelf.Abs(value.X), TSelf.Abs(value.Y), TSelf.Abs(value.Z), TSelf.Abs(value.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D MaxMagnitude(this Vector4D x, Vector4D y) + public static Vector4D MaxMagnitude(Vector4D x, Vector4D y) where TSelf : INumberBase => new(TSelf.MaxMagnitude(x.X, y.X), TSelf.MaxMagnitude(x.Y, y.Y), TSelf.MaxMagnitude(x.Z, y.Z), TSelf.MaxMagnitude(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D MaxMagnitudeNumber(this Vector4D x, Vector4D y) + public static Vector4D MaxMagnitudeNumber(Vector4D x, Vector4D y) where TSelf : INumberBase => new(TSelf.MaxMagnitudeNumber(x.X, y.X), TSelf.MaxMagnitudeNumber(x.Y, y.Y), TSelf.MaxMagnitudeNumber(x.Z, y.Z), TSelf.MaxMagnitudeNumber(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D MinMagnitude(this Vector4D x, Vector4D y) + public static Vector4D MinMagnitude(Vector4D x, Vector4D y) where TSelf : INumberBase => new(TSelf.MinMagnitude(x.X, y.X), TSelf.MinMagnitude(x.Y, y.Y), TSelf.MinMagnitude(x.Z, y.Z), TSelf.MinMagnitude(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D MinMagnitudeNumber(this Vector4D x, Vector4D y) + public static Vector4D MinMagnitudeNumber(Vector4D x, Vector4D y) where TSelf : INumberBase => new(TSelf.MinMagnitudeNumber(x.X, y.X), TSelf.MinMagnitudeNumber(x.Y, y.Y), TSelf.MinMagnitudeNumber(x.Z, y.Z), TSelf.MinMagnitudeNumber(x.W, y.W)); + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + public static Vector4D MultiplyAddEstimate(Vector4D left, Vector4D right, Vector4D addend) + where TSelf : INumberBase => + new(TSelf.MultiplyAddEstimate(left.X, right.X, addend.X), TSelf.MultiplyAddEstimate(left.Y, right.Y, addend.Y), TSelf.MultiplyAddEstimate(left.Z, right.Z, addend.Z), TSelf.MultiplyAddEstimate(left.W, right.W, addend.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A vector whose members will be provided for . + /// A single value provided for . + public static Vector4D MultiplyAddEstimate(Vector4D left, Vector4D right, TSelf addend) + where TSelf : INumberBase => + new(TSelf.MultiplyAddEstimate(left.X, right.X, addend), TSelf.MultiplyAddEstimate(left.Y, right.Y, addend), TSelf.MultiplyAddEstimate(left.Z, right.Z, addend), TSelf.MultiplyAddEstimate(left.W, right.W, addend)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A vector whose members will be provided for . + public static Vector4D MultiplyAddEstimate(Vector4D left, TSelf right, Vector4D addend) + where TSelf : INumberBase => + new(TSelf.MultiplyAddEstimate(left.X, right, addend.X), TSelf.MultiplyAddEstimate(left.Y, right, addend.Y), TSelf.MultiplyAddEstimate(left.Z, right, addend.Z), TSelf.MultiplyAddEstimate(left.W, right, addend.W)); + + /// Applies to the provided arguments. + /// A vector whose members will be provided for . + /// A single value provided for . + /// A single value provided for . + public static Vector4D MultiplyAddEstimate(Vector4D left, TSelf right, TSelf addend) + where TSelf : INumberBase => + new(TSelf.MultiplyAddEstimate(left.X, right, addend), TSelf.MultiplyAddEstimate(left.Y, right, addend), TSelf.MultiplyAddEstimate(left.Z, right, addend), TSelf.MultiplyAddEstimate(left.W, right, addend)); + /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D PopCount(this Vector4D value) + public static Vector4D PopCount(Vector4D value) where TSelf : IBinaryInteger => new(TSelf.PopCount(value.X), TSelf.PopCount(value.Y), TSelf.PopCount(value.Z), TSelf.PopCount(value.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D TrailingZeroCount(this Vector4D value) + public static Vector4D TrailingZeroCount(Vector4D value) where TSelf : IBinaryInteger => new(TSelf.TrailingZeroCount(value.X), TSelf.TrailingZeroCount(value.Y), TSelf.TrailingZeroCount(value.Z), TSelf.TrailingZeroCount(value.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Ceiling(this Vector4D x) + public static Vector4D Ceiling(Vector4D x) where TSelf : IFloatingPoint => new(TSelf.Ceiling(x.X), TSelf.Ceiling(x.Y), TSelf.Ceiling(x.Z), TSelf.Ceiling(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Floor(this Vector4D x) + public static Vector4D Floor(Vector4D x) where TSelf : IFloatingPoint => new(TSelf.Floor(x.X), TSelf.Floor(x.Y), TSelf.Floor(x.Z), TSelf.Floor(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Round(this Vector4D x) + public static Vector4D Round(Vector4D x) where TSelf : IFloatingPoint => new(TSelf.Round(x.X), TSelf.Round(x.Y), TSelf.Round(x.Z), TSelf.Round(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D Round(this Vector4D x, int digits) + public static Vector4D Round(Vector4D x, int digits) where TSelf : IFloatingPoint => new(TSelf.Round(x.X, digits), TSelf.Round(x.Y, digits), TSelf.Round(x.Z, digits), TSelf.Round(x.W, digits)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D Round(this Vector4D x, MidpointRounding mode) + public static Vector4D Round(Vector4D x, MidpointRounding mode) where TSelf : IFloatingPoint => new(TSelf.Round(x.X, mode), TSelf.Round(x.Y, mode), TSelf.Round(x.Z, mode), TSelf.Round(x.W, mode)); @@ -309,27 +341,27 @@ public static Vector4D Round(this Vector4D x, MidpointRound /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector4D Round(this Vector4D x, int digits, MidpointRounding mode) + public static Vector4D Round(Vector4D x, int digits, MidpointRounding mode) where TSelf : IFloatingPoint => new(TSelf.Round(x.X, digits, mode), TSelf.Round(x.Y, digits, mode), TSelf.Round(x.Z, digits, mode), TSelf.Round(x.W, digits, mode)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Truncate(this Vector4D x) + public static Vector4D Truncate(Vector4D x) where TSelf : IFloatingPoint => new(TSelf.Truncate(x.X), TSelf.Truncate(x.Y), TSelf.Truncate(x.Z), TSelf.Truncate(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D Atan2(this Vector4D y, Vector4D x) + public static Vector4D Atan2(Vector4D y, Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.Atan2(y.X, x.X), TSelf.Atan2(y.Y, x.Y), TSelf.Atan2(y.Z, x.Z), TSelf.Atan2(y.W, x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D Atan2Pi(this Vector4D y, Vector4D x) + public static Vector4D Atan2Pi(Vector4D y, Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.Atan2Pi(y.X, x.X), TSelf.Atan2Pi(y.Y, x.Y), TSelf.Atan2Pi(y.Z, x.Z), TSelf.Atan2Pi(y.W, x.W)); @@ -337,19 +369,19 @@ public static Vector4D Atan2Pi(this Vector4D y, Vector4DA vector whose members will be provided for . /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D Lerp(this Vector4D value1, Vector4D value2, TSelf amount) + public static Vector4D Lerp(Vector4D value1, Vector4D value2, TSelf amount) where TSelf : IFloatingPointIeee754 => new(TSelf.Lerp(value1.X, value2.X, amount), TSelf.Lerp(value1.Y, value2.Y, amount), TSelf.Lerp(value1.Z, value2.Z, amount), TSelf.Lerp(value1.W, value2.W, amount)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D BitDecrement(this Vector4D x) + public static Vector4D BitDecrement(Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.BitDecrement(x.X), TSelf.BitDecrement(x.Y), TSelf.BitDecrement(x.Z), TSelf.BitDecrement(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D BitIncrement(this Vector4D x) + public static Vector4D BitIncrement(Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.BitIncrement(x.X), TSelf.BitIncrement(x.Y), TSelf.BitIncrement(x.Z), TSelf.BitIncrement(x.W)); @@ -357,7 +389,7 @@ public static Vector4D BitIncrement(this Vector4D x) /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D FusedMultiplyAdd(this Vector4D left, Vector4D right, Vector4D addend) + public static Vector4D FusedMultiplyAdd(Vector4D left, Vector4D right, Vector4D addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right.X, addend.X), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend.Z), TSelf.FusedMultiplyAdd(left.W, right.W, addend.W)); @@ -365,7 +397,7 @@ public static Vector4D FusedMultiplyAdd(this Vector4D left, /// A vector whose members will be provided for . /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D FusedMultiplyAdd(this Vector4D left, Vector4D right, TSelf addend) + public static Vector4D FusedMultiplyAdd(Vector4D left, Vector4D right, TSelf addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right.X, addend), TSelf.FusedMultiplyAdd(left.Y, right.Y, addend), TSelf.FusedMultiplyAdd(left.Z, right.Z, addend), TSelf.FusedMultiplyAdd(left.W, right.W, addend)); @@ -373,7 +405,7 @@ public static Vector4D FusedMultiplyAdd(this Vector4D left, /// A vector whose members will be provided for . /// A single value provided for . /// A vector whose members will be provided for . - public static Vector4D FusedMultiplyAdd(this Vector4D left, TSelf right, Vector4D addend) + public static Vector4D FusedMultiplyAdd(Vector4D left, TSelf right, Vector4D addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right, addend.X), TSelf.FusedMultiplyAdd(left.Y, right, addend.Y), TSelf.FusedMultiplyAdd(left.Z, right, addend.Z), TSelf.FusedMultiplyAdd(left.W, right, addend.W)); @@ -381,313 +413,313 @@ public static Vector4D FusedMultiplyAdd(this Vector4D left, /// A vector whose members will be provided for . /// A single value provided for . /// A single value provided for . - public static Vector4D FusedMultiplyAdd(this Vector4D left, TSelf right, TSelf addend) + public static Vector4D FusedMultiplyAdd(Vector4D left, TSelf right, TSelf addend) where TSelf : IFloatingPointIeee754 => new(TSelf.FusedMultiplyAdd(left.X, right, addend), TSelf.FusedMultiplyAdd(left.Y, right, addend), TSelf.FusedMultiplyAdd(left.Z, right, addend), TSelf.FusedMultiplyAdd(left.W, right, addend)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D Ieee754Remainder(this Vector4D left, Vector4D right) + public static Vector4D Ieee754Remainder(Vector4D left, Vector4D right) where TSelf : IFloatingPointIeee754 => new(TSelf.Ieee754Remainder(left.X, right.X), TSelf.Ieee754Remainder(left.Y, right.Y), TSelf.Ieee754Remainder(left.Z, right.Z), TSelf.Ieee754Remainder(left.W, right.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D Ieee754Remainder(this Vector4D left, TSelf right) + public static Vector4D Ieee754Remainder(Vector4D left, TSelf right) where TSelf : IFloatingPointIeee754 => new(TSelf.Ieee754Remainder(left.X, right), TSelf.Ieee754Remainder(left.Y, right), TSelf.Ieee754Remainder(left.Z, right), TSelf.Ieee754Remainder(left.W, right)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D ILogB(this Vector4D x) + public static Vector4D ILogB(Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ILogB(x.X), TSelf.ILogB(x.Y), TSelf.ILogB(x.Z), TSelf.ILogB(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D ReciprocalEstimate(this Vector4D x) + public static Vector4D ReciprocalEstimate(Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ReciprocalEstimate(x.X), TSelf.ReciprocalEstimate(x.Y), TSelf.ReciprocalEstimate(x.Z), TSelf.ReciprocalEstimate(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D ReciprocalSqrtEstimate(this Vector4D x) + public static Vector4D ReciprocalSqrtEstimate(Vector4D x) where TSelf : IFloatingPointIeee754 => new(TSelf.ReciprocalSqrtEstimate(x.X), TSelf.ReciprocalSqrtEstimate(x.Y), TSelf.ReciprocalSqrtEstimate(x.Z), TSelf.ReciprocalSqrtEstimate(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D ScaleB(this Vector4D x, Vector4D n) + public static Vector4D ScaleB(Vector4D x, Vector4D n) where TSelf : IFloatingPointIeee754 => new(TSelf.ScaleB(x.X, n.X), TSelf.ScaleB(x.Y, n.Y), TSelf.ScaleB(x.Z, n.Z), TSelf.ScaleB(x.W, n.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D ScaleB(this Vector4D x, int n) + public static Vector4D ScaleB(Vector4D x, int n) where TSelf : IFloatingPointIeee754 => new(TSelf.ScaleB(x.X, n), TSelf.ScaleB(x.Y, n), TSelf.ScaleB(x.Z, n), TSelf.ScaleB(x.W, n)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D Pow(this Vector4D x, Vector4D y) + public static Vector4D Pow(Vector4D x, Vector4D y) where TSelf : IPowerFunctions => new(TSelf.Pow(x.X, y.X), TSelf.Pow(x.Y, y.Y), TSelf.Pow(x.Z, y.Z), TSelf.Pow(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D Pow(this Vector4D x, TSelf y) + public static Vector4D Pow(Vector4D x, TSelf y) where TSelf : IPowerFunctions => new(TSelf.Pow(x.X, y), TSelf.Pow(x.Y, y), TSelf.Pow(x.Z, y), TSelf.Pow(x.W, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Cbrt(this Vector4D x) + public static Vector4D Cbrt(Vector4D x) where TSelf : IRootFunctions => new(TSelf.Cbrt(x.X), TSelf.Cbrt(x.Y), TSelf.Cbrt(x.Z), TSelf.Cbrt(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Sqrt(this Vector4D x) + public static Vector4D Sqrt(Vector4D x) where TSelf : IRootFunctions => new(TSelf.Sqrt(x.X), TSelf.Sqrt(x.Y), TSelf.Sqrt(x.Z), TSelf.Sqrt(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D RootN(this Vector4D x, int n) + public static Vector4D RootN(Vector4D x, int n) where TSelf : IRootFunctions => new(TSelf.RootN(x.X, n), TSelf.RootN(x.Y, n), TSelf.RootN(x.Z, n), TSelf.RootN(x.W, n)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D RootN(this Vector4D x, Vector4D n) + public static Vector4D RootN(Vector4D x, Vector4D n) where TSelf : IRootFunctions => new(TSelf.RootN(x.X, n.X), TSelf.RootN(x.Y, n.Y), TSelf.RootN(x.Z, n.Z), TSelf.RootN(x.W, n.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D Hypot(this Vector4D x, Vector4D y) + public static Vector4D Hypot(Vector4D x, Vector4D y) where TSelf : IRootFunctions => new(TSelf.Hypot(x.X, y.X), TSelf.Hypot(x.Y, y.Y), TSelf.Hypot(x.Z, y.Z), TSelf.Hypot(x.W, y.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D Hypot(this Vector4D x, TSelf y) + public static Vector4D Hypot(Vector4D x, TSelf y) where TSelf : IRootFunctions => new(TSelf.Hypot(x.X, y), TSelf.Hypot(x.Y, y), TSelf.Hypot(x.Z, y), TSelf.Hypot(x.W, y)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Log(this Vector4D x) + public static Vector4D Log(Vector4D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X), TSelf.Log(x.Y), TSelf.Log(x.Z), TSelf.Log(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A vector whose members will be provided for . - public static Vector4D Log(this Vector4D x, Vector4D newBase) + public static Vector4D Log(Vector4D x, Vector4D newBase) where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X, newBase.X), TSelf.Log(x.Y, newBase.Y), TSelf.Log(x.Z, newBase.Z), TSelf.Log(x.W, newBase.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . /// A single value provided for . - public static Vector4D Log(this Vector4D x, TSelf newBase) + public static Vector4D Log(Vector4D x, TSelf newBase) where TSelf : ILogarithmicFunctions => new(TSelf.Log(x.X, newBase), TSelf.Log(x.Y, newBase), TSelf.Log(x.Z, newBase), TSelf.Log(x.W, newBase)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D LogP1(this Vector4D x) + public static Vector4D LogP1(Vector4D x) where TSelf : ILogarithmicFunctions => new(TSelf.LogP1(x.X), TSelf.LogP1(x.Y), TSelf.LogP1(x.Z), TSelf.LogP1(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Log2(this Vector4D x) + public static Vector4D Log2(Vector4D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log2(x.X), TSelf.Log2(x.Y), TSelf.Log2(x.Z), TSelf.Log2(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Log2P1(this Vector4D x) + public static Vector4D Log2P1(Vector4D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log2P1(x.X), TSelf.Log2P1(x.Y), TSelf.Log2P1(x.Z), TSelf.Log2P1(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Log10(this Vector4D x) + public static Vector4D Log10(Vector4D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log10(x.X), TSelf.Log10(x.Y), TSelf.Log10(x.Z), TSelf.Log10(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Log10P1(this Vector4D x) + public static Vector4D Log10P1(Vector4D x) where TSelf : ILogarithmicFunctions => new(TSelf.Log10P1(x.X), TSelf.Log10P1(x.Y), TSelf.Log10P1(x.Z), TSelf.Log10P1(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Exp(this Vector4D x) + public static Vector4D Exp(Vector4D x) where TSelf : IExponentialFunctions => new(TSelf.Exp(x.X), TSelf.Exp(x.Y), TSelf.Exp(x.Z), TSelf.Exp(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D ExpM1(this Vector4D x) + public static Vector4D ExpM1(Vector4D x) where TSelf : IExponentialFunctions => new(TSelf.ExpM1(x.X), TSelf.ExpM1(x.Y), TSelf.ExpM1(x.Z), TSelf.ExpM1(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Exp2(this Vector4D x) + public static Vector4D Exp2(Vector4D x) where TSelf : IExponentialFunctions => new(TSelf.Exp2(x.X), TSelf.Exp2(x.Y), TSelf.Exp2(x.Z), TSelf.Exp2(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Exp2M1(this Vector4D x) + public static Vector4D Exp2M1(Vector4D x) where TSelf : IExponentialFunctions => new(TSelf.Exp2M1(x.X), TSelf.Exp2M1(x.Y), TSelf.Exp2M1(x.Z), TSelf.Exp2M1(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Exp10(this Vector4D x) + public static Vector4D Exp10(Vector4D x) where TSelf : IExponentialFunctions => new(TSelf.Exp10(x.X), TSelf.Exp10(x.Y), TSelf.Exp10(x.Z), TSelf.Exp10(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Exp10M1(this Vector4D x) + public static Vector4D Exp10M1(Vector4D x) where TSelf : IExponentialFunctions => new(TSelf.Exp10M1(x.X), TSelf.Exp10M1(x.Y), TSelf.Exp10M1(x.Z), TSelf.Exp10M1(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Acos(this Vector4D x) + public static Vector4D Acos(Vector4D x) where TSelf : ITrigonometricFunctions => new(TSelf.Acos(x.X), TSelf.Acos(x.Y), TSelf.Acos(x.Z), TSelf.Acos(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D AcosPi(this Vector4D x) + public static Vector4D AcosPi(Vector4D x) where TSelf : ITrigonometricFunctions => new(TSelf.AcosPi(x.X), TSelf.AcosPi(x.Y), TSelf.AcosPi(x.Z), TSelf.AcosPi(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Asin(this Vector4D x) + public static Vector4D Asin(Vector4D x) where TSelf : ITrigonometricFunctions => new(TSelf.Asin(x.X), TSelf.Asin(x.Y), TSelf.Asin(x.Z), TSelf.Asin(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D AsinPi(this Vector4D x) + public static Vector4D AsinPi(Vector4D x) where TSelf : ITrigonometricFunctions => new(TSelf.AsinPi(x.X), TSelf.AsinPi(x.Y), TSelf.AsinPi(x.Z), TSelf.AsinPi(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Atan(this Vector4D x) + public static Vector4D Atan(Vector4D x) where TSelf : ITrigonometricFunctions => new(TSelf.Atan(x.X), TSelf.Atan(x.Y), TSelf.Atan(x.Z), TSelf.Atan(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D AtanPi(this Vector4D x) + public static Vector4D AtanPi(Vector4D x) where TSelf : ITrigonometricFunctions => new(TSelf.AtanPi(x.X), TSelf.AtanPi(x.Y), TSelf.AtanPi(x.Z), TSelf.AtanPi(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Cos(this Vector4D x) + public static Vector4D Cos(Vector4D x) where TSelf : ITrigonometricFunctions => new(TSelf.Cos(x.X), TSelf.Cos(x.Y), TSelf.Cos(x.Z), TSelf.Cos(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D CosPi(this Vector4D x) + public static Vector4D CosPi(Vector4D x) where TSelf : ITrigonometricFunctions => new(TSelf.CosPi(x.X), TSelf.CosPi(x.Y), TSelf.CosPi(x.Z), TSelf.CosPi(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Sin(this Vector4D x) + public static Vector4D Sin(Vector4D x) where TSelf : ITrigonometricFunctions => new(TSelf.Sin(x.X), TSelf.Sin(x.Y), TSelf.Sin(x.Z), TSelf.Sin(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D SinPi(this Vector4D x) + public static Vector4D SinPi(Vector4D x) where TSelf : ITrigonometricFunctions => new(TSelf.SinPi(x.X), TSelf.SinPi(x.Y), TSelf.SinPi(x.Z), TSelf.SinPi(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Tan(this Vector4D x) + public static Vector4D Tan(Vector4D x) where TSelf : ITrigonometricFunctions => new(TSelf.Tan(x.X), TSelf.Tan(x.Y), TSelf.Tan(x.Z), TSelf.Tan(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D TanPi(this Vector4D x) + public static Vector4D TanPi(Vector4D x) where TSelf : ITrigonometricFunctions => new(TSelf.TanPi(x.X), TSelf.TanPi(x.Y), TSelf.TanPi(x.Z), TSelf.TanPi(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D DegreesToRadians(this Vector4D degrees) + public static Vector4D DegreesToRadians(Vector4D degrees) where TSelf : ITrigonometricFunctions => new(TSelf.DegreesToRadians(degrees.X), TSelf.DegreesToRadians(degrees.Y), TSelf.DegreesToRadians(degrees.Z), TSelf.DegreesToRadians(degrees.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D RadiansToDegrees(this Vector4D radians) + public static Vector4D RadiansToDegrees(Vector4D radians) where TSelf : ITrigonometricFunctions => new(TSelf.RadiansToDegrees(radians.X), TSelf.RadiansToDegrees(radians.Y), TSelf.RadiansToDegrees(radians.Z), TSelf.RadiansToDegrees(radians.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Acosh(this Vector4D x) + public static Vector4D Acosh(Vector4D x) where TSelf : IHyperbolicFunctions => new(TSelf.Acosh(x.X), TSelf.Acosh(x.Y), TSelf.Acosh(x.Z), TSelf.Acosh(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Asinh(this Vector4D x) + public static Vector4D Asinh(Vector4D x) where TSelf : IHyperbolicFunctions => new(TSelf.Asinh(x.X), TSelf.Asinh(x.Y), TSelf.Asinh(x.Z), TSelf.Asinh(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Atanh(this Vector4D x) + public static Vector4D Atanh(Vector4D x) where TSelf : IHyperbolicFunctions => new(TSelf.Atanh(x.X), TSelf.Atanh(x.Y), TSelf.Atanh(x.Z), TSelf.Atanh(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Cosh(this Vector4D x) + public static Vector4D Cosh(Vector4D x) where TSelf : IHyperbolicFunctions => new(TSelf.Cosh(x.X), TSelf.Cosh(x.Y), TSelf.Cosh(x.Z), TSelf.Cosh(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Sinh(this Vector4D x) + public static Vector4D Sinh(Vector4D x) where TSelf : IHyperbolicFunctions => new(TSelf.Sinh(x.X), TSelf.Sinh(x.Y), TSelf.Sinh(x.Z), TSelf.Sinh(x.W)); /// Applies to the provided arguments. /// A vector whose members will be provided for . - public static Vector4D Tanh(this Vector4D x) + public static Vector4D Tanh(Vector4D x) where TSelf : IHyperbolicFunctions => new(TSelf.Tanh(x.X), TSelf.Tanh(x.Y), TSelf.Tanh(x.Z), TSelf.Tanh(x.W)); } From 59587cd9dd407e4a649396d82549fd5ea9258893 Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Fri, 2 Jan 2026 12:37:23 -0800 Subject: [PATCH 66/67] Don't use infix Dot() function. --- sources/Maths/Maths/Vector2D.Ops.gen.cs | 2 +- sources/Maths/Maths/Vector3D.Ops.gen.cs | 2 +- sources/Maths/Maths/Vector4D.Ops.gen.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/Maths/Maths/Vector2D.Ops.gen.cs b/sources/Maths/Maths/Vector2D.Ops.gen.cs index dac99096fa..4a7acc7caa 100644 --- a/sources/Maths/Maths/Vector2D.Ops.gen.cs +++ b/sources/Maths/Maths/Vector2D.Ops.gen.cs @@ -46,7 +46,7 @@ public static T Dot(Vector2D left, Vector2D right) public static Vector2D Reflect(Vector2D vector, Vector2D normal) where T : INumberBase { - T dot = vector.Dot(normal); + T dot = Dot(vector, normal); return vector - (normal * (dot + dot)); } diff --git a/sources/Maths/Maths/Vector3D.Ops.gen.cs b/sources/Maths/Maths/Vector3D.Ops.gen.cs index fd9f024e48..cf50b96a4a 100644 --- a/sources/Maths/Maths/Vector3D.Ops.gen.cs +++ b/sources/Maths/Maths/Vector3D.Ops.gen.cs @@ -48,7 +48,7 @@ public static T Dot(Vector3D left, Vector3D right) public static Vector3D Reflect(Vector3D vector, Vector3D normal) where T : INumberBase { - T dot = vector.Dot(normal); + T dot = Dot(vector, normal); return vector - (normal * (dot + dot)); } diff --git a/sources/Maths/Maths/Vector4D.Ops.gen.cs b/sources/Maths/Maths/Vector4D.Ops.gen.cs index 8819b66a1c..b6b3ceaa42 100644 --- a/sources/Maths/Maths/Vector4D.Ops.gen.cs +++ b/sources/Maths/Maths/Vector4D.Ops.gen.cs @@ -50,7 +50,7 @@ public static T Dot(Vector4D left, Vector4D right) public static Vector4D Reflect(Vector4D vector, Vector4D normal) where T : INumberBase { - T dot = vector.Dot(normal); + T dot = Dot(vector, normal); return vector - (normal * (dot + dot)); } From 6c9eace6e67ad92402752a604106d46a154f95ce Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Fri, 2 Jan 2026 12:37:28 -0800 Subject: [PATCH 67/67] Synced PublicAPI.Unshipped.txt --- .../PublicAPI/net10.0/PublicAPI.Unshipped.txt | 1413 +++++++++++------ 1 file changed, 919 insertions(+), 494 deletions(-) diff --git a/sources/Maths/Maths/PublicAPI/net10.0/PublicAPI.Unshipped.txt b/sources/Maths/Maths/PublicAPI/net10.0/PublicAPI.Unshipped.txt index 3552eec334..e3b1e3e3c8 100644 --- a/sources/Maths/Maths/PublicAPI/net10.0/PublicAPI.Unshipped.txt +++ b/sources/Maths/Maths/PublicAPI/net10.0/PublicAPI.Unshipped.txt @@ -60,8 +60,12 @@ override Silk.NET.Maths.Vector3D.ToString() -> string! override Silk.NET.Maths.Vector4D.Equals(object? obj) -> bool override Silk.NET.Maths.Vector4D.GetHashCode() -> int override Silk.NET.Maths.Vector4D.ToString() -> string! +Silk.NET.Maths.Box2D Silk.NET.Maths.Box2D Silk.NET.Maths.Box2D.As() -> Silk.NET.Maths.Box2D +Silk.NET.Maths.Box2D.AsChecked() -> Silk.NET.Maths.Box2D +Silk.NET.Maths.Box2D.AsSaturating() -> Silk.NET.Maths.Box2D +Silk.NET.Maths.Box2D.AsTruncating() -> Silk.NET.Maths.Box2D Silk.NET.Maths.Box2D.Box2D() -> void Silk.NET.Maths.Box2D.Box2D(Silk.NET.Maths.Vector2D min, Silk.NET.Maths.Vector2D max) -> void Silk.NET.Maths.Box2D.Box2D(Silk.NET.Maths.Vector2D min, T maxX, T maxY) -> void @@ -71,7 +75,6 @@ Silk.NET.Maths.Box2D.Center.get -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Box2D.Contains(Silk.NET.Maths.Box2D other) -> bool Silk.NET.Maths.Box2D.Contains(Silk.NET.Maths.Vector2D point) -> bool Silk.NET.Maths.Box2D.Equals(Silk.NET.Maths.Box2D other) -> bool -Silk.NET.Maths.Box2D.GetDistanceToNearestEdge(Silk.NET.Maths.Vector2D point) -> T Silk.NET.Maths.Box2D.GetInflated(Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Box2D Silk.NET.Maths.Box2D.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Box2D Silk.NET.Maths.Box2D.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Box2D @@ -79,6 +82,7 @@ Silk.NET.Maths.Box2D.GetTranslated(Silk.NET.Maths.Vector2D distance) -> Si Silk.NET.Maths.Box2D.Max -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Box2D.Min -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Box2D.Size.get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Box3D Silk.NET.Maths.Box3D Silk.NET.Maths.Box3D.As() -> Silk.NET.Maths.Box3D Silk.NET.Maths.Box3D.Box3D() -> void @@ -90,7 +94,6 @@ Silk.NET.Maths.Box3D.Center.get -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Box3D.Contains(Silk.NET.Maths.Box3D other) -> bool Silk.NET.Maths.Box3D.Contains(Silk.NET.Maths.Vector3D point) -> bool Silk.NET.Maths.Box3D.Equals(Silk.NET.Maths.Box3D other) -> bool -Silk.NET.Maths.Box3D.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D point) -> T Silk.NET.Maths.Box3D.GetInflated(Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Box3D Silk.NET.Maths.Box3D.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Box3D Silk.NET.Maths.Box3D.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Box3D @@ -98,6 +101,7 @@ Silk.NET.Maths.Box3D.GetTranslated(Silk.NET.Maths.Vector3D distance) -> Si Silk.NET.Maths.Box3D.Max -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Box3D.Min -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Box3D.Size.get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Circle Silk.NET.Maths.Circle Silk.NET.Maths.Circle.As() -> Silk.NET.Maths.Circle Silk.NET.Maths.Circle.Center -> Silk.NET.Maths.Vector2D @@ -105,16 +109,14 @@ Silk.NET.Maths.Circle.Circle() -> void Silk.NET.Maths.Circle.Circle(Silk.NET.Maths.Vector2D center, T radius) -> void Silk.NET.Maths.Circle.Circle(T centerX, T centerY, T radius) -> void Silk.NET.Maths.Circle.Circumference.get -> T -Silk.NET.Maths.Circle.Contains(Silk.NET.Maths.Circle other) -> bool -Silk.NET.Maths.Circle.Contains(Silk.NET.Maths.Vector2D point) -> bool Silk.NET.Maths.Circle.Diameter.get -> T Silk.NET.Maths.Circle.Equals(Silk.NET.Maths.Circle other) -> bool Silk.NET.Maths.Circle.GetDistanceToNearestEdge(Silk.NET.Maths.Vector2D point) -> T Silk.NET.Maths.Circle.GetDistanceToNearestEdgeSquared(Silk.NET.Maths.Vector2D point) -> T -Silk.NET.Maths.Circle.GetInflated(Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Circle Silk.NET.Maths.Circle.GetTranslated(Silk.NET.Maths.Vector2D distance) -> Silk.NET.Maths.Circle Silk.NET.Maths.Circle.Radius -> T Silk.NET.Maths.Circle.SquaredRadius.get -> T +Silk.NET.Maths.Cube Silk.NET.Maths.Cube Silk.NET.Maths.Cube.As() -> Silk.NET.Maths.Cube Silk.NET.Maths.Cube.Center.get -> Silk.NET.Maths.Vector3D @@ -126,7 +128,6 @@ Silk.NET.Maths.Cube.Cube(Silk.NET.Maths.Vector3D origin, T sizeX, T sizeY, Silk.NET.Maths.Cube.Cube(T originX, T originY, T originZ, Silk.NET.Maths.Vector3D size) -> void Silk.NET.Maths.Cube.Cube(T originX, T originY, T originZ, T sizeX, T sizeY, T sizeZ) -> void Silk.NET.Maths.Cube.Equals(Silk.NET.Maths.Cube other) -> bool -Silk.NET.Maths.Cube.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D point) -> T Silk.NET.Maths.Cube.GetInflated(Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Cube Silk.NET.Maths.Cube.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Cube Silk.NET.Maths.Cube.GetScaled(Silk.NET.Maths.Vector3D scale, Silk.NET.Maths.Vector3D anchor) -> Silk.NET.Maths.Cube @@ -138,19 +139,18 @@ Silk.NET.Maths.Cube.Size -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix2X2 Silk.NET.Maths.Matrix2X2 Silk.NET.Maths.Matrix2X2.As() -> Silk.NET.Maths.Matrix2X2 +Silk.NET.Maths.Matrix2X2.AsChecked() -> Silk.NET.Maths.Matrix2X2 +Silk.NET.Maths.Matrix2X2.AsSaturating() -> Silk.NET.Maths.Matrix2X2 +Silk.NET.Maths.Matrix2X2.AsTruncating() -> Silk.NET.Maths.Matrix2X2 Silk.NET.Maths.Matrix2X2.Column1.get -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix2X2.Column2.get -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix2X2.Equals(Silk.NET.Maths.Matrix2X2 other) -> bool Silk.NET.Maths.Matrix2X2.GetDeterminant() -> T Silk.NET.Maths.Matrix2X2.IsIdentity.get -> bool Silk.NET.Maths.Matrix2X2.M11.get -> T -Silk.NET.Maths.Matrix2X2.M11.set -> void Silk.NET.Maths.Matrix2X2.M12.get -> T -Silk.NET.Maths.Matrix2X2.M12.set -> void Silk.NET.Maths.Matrix2X2.M21.get -> T -Silk.NET.Maths.Matrix2X2.M21.set -> void Silk.NET.Maths.Matrix2X2.M22.get -> T -Silk.NET.Maths.Matrix2X2.M22.set -> void Silk.NET.Maths.Matrix2X2.Matrix2X2() -> void Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Matrix2X4 value) -> void Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Matrix3X2 value) -> void @@ -161,28 +161,26 @@ Silk.NET.Maths.Matrix2X2.Matrix2X2(Silk.NET.Maths.Vector2D row1, Silk.NET. Silk.NET.Maths.Matrix2X2.Matrix2X2(T m11, T m12, T m21, T m22) -> void Silk.NET.Maths.Matrix2X2.Row1 -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix2X2.Row2 -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix2X2.this[int x, int y].get -> T -Silk.NET.Maths.Matrix2X2.this[int x].get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X2.this[int row, int column].get -> T +Silk.NET.Maths.Matrix2X2.this[int row].get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix2X2.Transpose() -> Silk.NET.Maths.Matrix2X2 Silk.NET.Maths.Matrix2X3 Silk.NET.Maths.Matrix2X3 Silk.NET.Maths.Matrix2X3.As() -> Silk.NET.Maths.Matrix2X3 +Silk.NET.Maths.Matrix2X3.AsChecked() -> Silk.NET.Maths.Matrix2X3 +Silk.NET.Maths.Matrix2X3.AsSaturating() -> Silk.NET.Maths.Matrix2X3 +Silk.NET.Maths.Matrix2X3.AsTruncating() -> Silk.NET.Maths.Matrix2X3 Silk.NET.Maths.Matrix2X3.Column1.get -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix2X3.Column2.get -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix2X3.Column3.get -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix2X3.Equals(Silk.NET.Maths.Matrix2X3 other) -> bool Silk.NET.Maths.Matrix2X3.IsIdentity.get -> bool Silk.NET.Maths.Matrix2X3.M11.get -> T -Silk.NET.Maths.Matrix2X3.M11.set -> void Silk.NET.Maths.Matrix2X3.M12.get -> T -Silk.NET.Maths.Matrix2X3.M12.set -> void Silk.NET.Maths.Matrix2X3.M13.get -> T -Silk.NET.Maths.Matrix2X3.M13.set -> void Silk.NET.Maths.Matrix2X3.M21.get -> T -Silk.NET.Maths.Matrix2X3.M21.set -> void Silk.NET.Maths.Matrix2X3.M22.get -> T -Silk.NET.Maths.Matrix2X3.M22.set -> void Silk.NET.Maths.Matrix2X3.M23.get -> T -Silk.NET.Maths.Matrix2X3.M23.set -> void Silk.NET.Maths.Matrix2X3.Matrix2X3() -> void Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Matrix2X4 value) -> void Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Matrix3X2 value) -> void @@ -193,11 +191,15 @@ Silk.NET.Maths.Matrix2X3.Matrix2X3(Silk.NET.Maths.Vector3D row1, Silk.NET. Silk.NET.Maths.Matrix2X3.Matrix2X3(T m11, T m12, T m13, T m21, T m22, T m23) -> void Silk.NET.Maths.Matrix2X3.Row1 -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix2X3.Row2 -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix2X3.this[int x, int y].get -> T -Silk.NET.Maths.Matrix2X3.this[int x].get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix2X3.this[int row, int column].get -> T +Silk.NET.Maths.Matrix2X3.this[int row].get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix2X3.Transpose() -> Silk.NET.Maths.Matrix3X2 Silk.NET.Maths.Matrix2X4 Silk.NET.Maths.Matrix2X4 Silk.NET.Maths.Matrix2X4.As() -> Silk.NET.Maths.Matrix2X4 +Silk.NET.Maths.Matrix2X4.AsChecked() -> Silk.NET.Maths.Matrix2X4 +Silk.NET.Maths.Matrix2X4.AsSaturating() -> Silk.NET.Maths.Matrix2X4 +Silk.NET.Maths.Matrix2X4.AsTruncating() -> Silk.NET.Maths.Matrix2X4 Silk.NET.Maths.Matrix2X4.Column1.get -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix2X4.Column2.get -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix2X4.Column3.get -> Silk.NET.Maths.Vector2D @@ -205,21 +207,13 @@ Silk.NET.Maths.Matrix2X4.Column4.get -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix2X4.Equals(Silk.NET.Maths.Matrix2X4 other) -> bool Silk.NET.Maths.Matrix2X4.IsIdentity.get -> bool Silk.NET.Maths.Matrix2X4.M11.get -> T -Silk.NET.Maths.Matrix2X4.M11.set -> void Silk.NET.Maths.Matrix2X4.M12.get -> T -Silk.NET.Maths.Matrix2X4.M12.set -> void Silk.NET.Maths.Matrix2X4.M13.get -> T -Silk.NET.Maths.Matrix2X4.M13.set -> void Silk.NET.Maths.Matrix2X4.M14.get -> T -Silk.NET.Maths.Matrix2X4.M14.set -> void Silk.NET.Maths.Matrix2X4.M21.get -> T -Silk.NET.Maths.Matrix2X4.M21.set -> void Silk.NET.Maths.Matrix2X4.M22.get -> T -Silk.NET.Maths.Matrix2X4.M22.set -> void Silk.NET.Maths.Matrix2X4.M23.get -> T -Silk.NET.Maths.Matrix2X4.M23.set -> void Silk.NET.Maths.Matrix2X4.M24.get -> T -Silk.NET.Maths.Matrix2X4.M24.set -> void Silk.NET.Maths.Matrix2X4.Matrix2X4() -> void Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Matrix3X2 value) -> void Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Matrix3X3 value) -> void @@ -230,28 +224,26 @@ Silk.NET.Maths.Matrix2X4.Matrix2X4(Silk.NET.Maths.Vector4D row1, Silk.NET. Silk.NET.Maths.Matrix2X4.Matrix2X4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24) -> void Silk.NET.Maths.Matrix2X4.Row1 -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix2X4.Row2 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix2X4.this[int x, int j].get -> T -Silk.NET.Maths.Matrix2X4.this[int x].get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix2X4.this[int row, int column].get -> T +Silk.NET.Maths.Matrix2X4.this[int row].get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix2X4.Transpose() -> Silk.NET.Maths.Matrix4X2 Silk.NET.Maths.Matrix3X2 Silk.NET.Maths.Matrix3X2 Silk.NET.Maths.Matrix3X2.As() -> Silk.NET.Maths.Matrix3X2 +Silk.NET.Maths.Matrix3X2.AsChecked() -> Silk.NET.Maths.Matrix3X2 +Silk.NET.Maths.Matrix3X2.AsSaturating() -> Silk.NET.Maths.Matrix3X2 +Silk.NET.Maths.Matrix3X2.AsTruncating() -> Silk.NET.Maths.Matrix3X2 Silk.NET.Maths.Matrix3X2.Column1.get -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix3X2.Column2.get -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix3X2.Equals(Silk.NET.Maths.Matrix3X2 other) -> bool Silk.NET.Maths.Matrix3X2.GetDeterminant() -> T Silk.NET.Maths.Matrix3X2.IsIdentity.get -> bool Silk.NET.Maths.Matrix3X2.M11.get -> T -Silk.NET.Maths.Matrix3X2.M11.set -> void Silk.NET.Maths.Matrix3X2.M12.get -> T -Silk.NET.Maths.Matrix3X2.M12.set -> void Silk.NET.Maths.Matrix3X2.M21.get -> T -Silk.NET.Maths.Matrix3X2.M21.set -> void Silk.NET.Maths.Matrix3X2.M22.get -> T -Silk.NET.Maths.Matrix3X2.M22.set -> void Silk.NET.Maths.Matrix3X2.M31.get -> T -Silk.NET.Maths.Matrix3X2.M31.set -> void Silk.NET.Maths.Matrix3X2.M32.get -> T -Silk.NET.Maths.Matrix3X2.M32.set -> void Silk.NET.Maths.Matrix3X2.Matrix3X2() -> void Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Matrix2X4 value) -> void Silk.NET.Maths.Matrix3X2.Matrix3X2(Silk.NET.Maths.Matrix3X3 value) -> void @@ -263,11 +255,15 @@ Silk.NET.Maths.Matrix3X2.Matrix3X2(T m11, T m12, T m21, T m22, T m31, T m32) Silk.NET.Maths.Matrix3X2.Row1 -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix3X2.Row2 -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix3X2.Row3 -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix3X2.this[int x, int y].get -> T -Silk.NET.Maths.Matrix3X2.this[int x].get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix3X2.this[int row, int column].get -> T +Silk.NET.Maths.Matrix3X2.this[int row].get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix3X2.Transpose() -> Silk.NET.Maths.Matrix2X3 Silk.NET.Maths.Matrix3X3 Silk.NET.Maths.Matrix3X3 Silk.NET.Maths.Matrix3X3.As() -> Silk.NET.Maths.Matrix3X3 +Silk.NET.Maths.Matrix3X3.AsChecked() -> Silk.NET.Maths.Matrix3X3 +Silk.NET.Maths.Matrix3X3.AsSaturating() -> Silk.NET.Maths.Matrix3X3 +Silk.NET.Maths.Matrix3X3.AsTruncating() -> Silk.NET.Maths.Matrix3X3 Silk.NET.Maths.Matrix3X3.Column1.get -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix3X3.Column2.get -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix3X3.Column3.get -> Silk.NET.Maths.Vector3D @@ -275,23 +271,14 @@ Silk.NET.Maths.Matrix3X3.Equals(Silk.NET.Maths.Matrix3X3 other) -> bool Silk.NET.Maths.Matrix3X3.GetDeterminant() -> T Silk.NET.Maths.Matrix3X3.IsIdentity.get -> bool Silk.NET.Maths.Matrix3X3.M11.get -> T -Silk.NET.Maths.Matrix3X3.M11.set -> void Silk.NET.Maths.Matrix3X3.M12.get -> T -Silk.NET.Maths.Matrix3X3.M12.set -> void Silk.NET.Maths.Matrix3X3.M13.get -> T -Silk.NET.Maths.Matrix3X3.M13.set -> void Silk.NET.Maths.Matrix3X3.M21.get -> T -Silk.NET.Maths.Matrix3X3.M21.set -> void Silk.NET.Maths.Matrix3X3.M22.get -> T -Silk.NET.Maths.Matrix3X3.M22.set -> void Silk.NET.Maths.Matrix3X3.M23.get -> T -Silk.NET.Maths.Matrix3X3.M23.set -> void Silk.NET.Maths.Matrix3X3.M31.get -> T -Silk.NET.Maths.Matrix3X3.M31.set -> void Silk.NET.Maths.Matrix3X3.M32.get -> T -Silk.NET.Maths.Matrix3X3.M32.set -> void Silk.NET.Maths.Matrix3X3.M33.get -> T -Silk.NET.Maths.Matrix3X3.M33.set -> void Silk.NET.Maths.Matrix3X3.Matrix3X3() -> void Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix2X4 value) -> void Silk.NET.Maths.Matrix3X3.Matrix3X3(Silk.NET.Maths.Matrix3X2 value) -> void @@ -305,11 +292,15 @@ Silk.NET.Maths.Matrix3X3.Matrix3X3(T m11, T m12, T m13, T m21, T m22, T m23, Silk.NET.Maths.Matrix3X3.Row1 -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix3X3.Row2 -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix3X3.Row3 -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix3X3.this[int x, int i].get -> T -Silk.NET.Maths.Matrix3X3.this[int x].get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X3.this[int row, int column].get -> T +Silk.NET.Maths.Matrix3X3.this[int row].get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix3X3.Transpose() -> Silk.NET.Maths.Matrix3X3 Silk.NET.Maths.Matrix3X4 Silk.NET.Maths.Matrix3X4 Silk.NET.Maths.Matrix3X4.As() -> Silk.NET.Maths.Matrix3X4 +Silk.NET.Maths.Matrix3X4.AsChecked() -> Silk.NET.Maths.Matrix3X4 +Silk.NET.Maths.Matrix3X4.AsSaturating() -> Silk.NET.Maths.Matrix3X4 +Silk.NET.Maths.Matrix3X4.AsTruncating() -> Silk.NET.Maths.Matrix3X4 Silk.NET.Maths.Matrix3X4.Column1.get -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix3X4.Column2.get -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix3X4.Column3.get -> Silk.NET.Maths.Vector3D @@ -317,29 +308,17 @@ Silk.NET.Maths.Matrix3X4.Column4.get -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix3X4.Equals(Silk.NET.Maths.Matrix3X4 other) -> bool Silk.NET.Maths.Matrix3X4.IsIdentity.get -> bool Silk.NET.Maths.Matrix3X4.M11.get -> T -Silk.NET.Maths.Matrix3X4.M11.set -> void Silk.NET.Maths.Matrix3X4.M12.get -> T -Silk.NET.Maths.Matrix3X4.M12.set -> void Silk.NET.Maths.Matrix3X4.M13.get -> T -Silk.NET.Maths.Matrix3X4.M13.set -> void Silk.NET.Maths.Matrix3X4.M14.get -> T -Silk.NET.Maths.Matrix3X4.M14.set -> void Silk.NET.Maths.Matrix3X4.M21.get -> T -Silk.NET.Maths.Matrix3X4.M21.set -> void Silk.NET.Maths.Matrix3X4.M22.get -> T -Silk.NET.Maths.Matrix3X4.M22.set -> void Silk.NET.Maths.Matrix3X4.M23.get -> T -Silk.NET.Maths.Matrix3X4.M23.set -> void Silk.NET.Maths.Matrix3X4.M24.get -> T -Silk.NET.Maths.Matrix3X4.M24.set -> void Silk.NET.Maths.Matrix3X4.M31.get -> T -Silk.NET.Maths.Matrix3X4.M31.set -> void Silk.NET.Maths.Matrix3X4.M32.get -> T -Silk.NET.Maths.Matrix3X4.M32.set -> void Silk.NET.Maths.Matrix3X4.M33.get -> T -Silk.NET.Maths.Matrix3X4.M33.set -> void Silk.NET.Maths.Matrix3X4.M34.get -> T -Silk.NET.Maths.Matrix3X4.M34.set -> void Silk.NET.Maths.Matrix3X4.Matrix3X4() -> void Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix2X4 value) -> void Silk.NET.Maths.Matrix3X4.Matrix3X4(Silk.NET.Maths.Matrix3X2 value) -> void @@ -352,31 +331,27 @@ Silk.NET.Maths.Matrix3X4.Matrix3X4(T m11, T m12, T m13, T m14, T m21, T m22, Silk.NET.Maths.Matrix3X4.Row1 -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix3X4.Row2 -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix3X4.Row3 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix3X4.this[int x, int y].get -> T -Silk.NET.Maths.Matrix3X4.this[int x].get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix3X4.this[int row, int column].get -> T +Silk.NET.Maths.Matrix3X4.this[int row].get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix3X4.Transpose() -> Silk.NET.Maths.Matrix4X3 Silk.NET.Maths.Matrix4X2 Silk.NET.Maths.Matrix4X2 Silk.NET.Maths.Matrix4X2.As() -> Silk.NET.Maths.Matrix4X2 +Silk.NET.Maths.Matrix4X2.AsChecked() -> Silk.NET.Maths.Matrix4X2 +Silk.NET.Maths.Matrix4X2.AsSaturating() -> Silk.NET.Maths.Matrix4X2 +Silk.NET.Maths.Matrix4X2.AsTruncating() -> Silk.NET.Maths.Matrix4X2 Silk.NET.Maths.Matrix4X2.Column1.get -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix4X2.Column2.get -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix4X2.Equals(Silk.NET.Maths.Matrix4X2 other) -> bool Silk.NET.Maths.Matrix4X2.IsIdentity.get -> bool Silk.NET.Maths.Matrix4X2.M11.get -> T -Silk.NET.Maths.Matrix4X2.M11.set -> void Silk.NET.Maths.Matrix4X2.M12.get -> T -Silk.NET.Maths.Matrix4X2.M12.set -> void Silk.NET.Maths.Matrix4X2.M21.get -> T -Silk.NET.Maths.Matrix4X2.M21.set -> void Silk.NET.Maths.Matrix4X2.M22.get -> T -Silk.NET.Maths.Matrix4X2.M22.set -> void Silk.NET.Maths.Matrix4X2.M31.get -> T -Silk.NET.Maths.Matrix4X2.M31.set -> void Silk.NET.Maths.Matrix4X2.M32.get -> T -Silk.NET.Maths.Matrix4X2.M32.set -> void Silk.NET.Maths.Matrix4X2.M41.get -> T -Silk.NET.Maths.Matrix4X2.M41.set -> void Silk.NET.Maths.Matrix4X2.M42.get -> T -Silk.NET.Maths.Matrix4X2.M42.set -> void Silk.NET.Maths.Matrix4X2.Matrix4X2() -> void Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Matrix2X4 value) -> void Silk.NET.Maths.Matrix4X2.Matrix4X2(Silk.NET.Maths.Matrix3X2 value) -> void @@ -389,40 +364,32 @@ Silk.NET.Maths.Matrix4X2.Row1 -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix4X2.Row2 -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix4X2.Row3 -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Matrix4X2.Row4 -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Matrix4X2.this[int x, int y].get -> T -Silk.NET.Maths.Matrix4X2.this[int x].get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix4X2.this[int row, int column].get -> T +Silk.NET.Maths.Matrix4X2.this[int row].get -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Matrix4X2.Transpose() -> Silk.NET.Maths.Matrix2X4 Silk.NET.Maths.Matrix4X3 Silk.NET.Maths.Matrix4X3 Silk.NET.Maths.Matrix4X3.As() -> Silk.NET.Maths.Matrix4X3 +Silk.NET.Maths.Matrix4X3.AsChecked() -> Silk.NET.Maths.Matrix4X3 +Silk.NET.Maths.Matrix4X3.AsSaturating() -> Silk.NET.Maths.Matrix4X3 +Silk.NET.Maths.Matrix4X3.AsTruncating() -> Silk.NET.Maths.Matrix4X3 Silk.NET.Maths.Matrix4X3.Column1.get -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix4X3.Column2.get -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix4X3.Column3.get -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix4X3.Equals(Silk.NET.Maths.Matrix4X3 other) -> bool Silk.NET.Maths.Matrix4X3.IsIdentity.get -> bool Silk.NET.Maths.Matrix4X3.M11.get -> T -Silk.NET.Maths.Matrix4X3.M11.set -> void Silk.NET.Maths.Matrix4X3.M12.get -> T -Silk.NET.Maths.Matrix4X3.M12.set -> void Silk.NET.Maths.Matrix4X3.M13.get -> T -Silk.NET.Maths.Matrix4X3.M13.set -> void Silk.NET.Maths.Matrix4X3.M21.get -> T -Silk.NET.Maths.Matrix4X3.M21.set -> void Silk.NET.Maths.Matrix4X3.M22.get -> T -Silk.NET.Maths.Matrix4X3.M22.set -> void Silk.NET.Maths.Matrix4X3.M23.get -> T -Silk.NET.Maths.Matrix4X3.M23.set -> void Silk.NET.Maths.Matrix4X3.M31.get -> T -Silk.NET.Maths.Matrix4X3.M31.set -> void Silk.NET.Maths.Matrix4X3.M32.get -> T -Silk.NET.Maths.Matrix4X3.M32.set -> void Silk.NET.Maths.Matrix4X3.M33.get -> T -Silk.NET.Maths.Matrix4X3.M33.set -> void Silk.NET.Maths.Matrix4X3.M41.get -> T -Silk.NET.Maths.Matrix4X3.M41.set -> void Silk.NET.Maths.Matrix4X3.M42.get -> T -Silk.NET.Maths.Matrix4X3.M42.set -> void Silk.NET.Maths.Matrix4X3.M43.get -> T -Silk.NET.Maths.Matrix4X3.M43.set -> void Silk.NET.Maths.Matrix4X3.Matrix4X3() -> void Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix2X4 value) -> void Silk.NET.Maths.Matrix4X3.Matrix4X3(Silk.NET.Maths.Matrix3X2 value) -> void @@ -437,11 +404,15 @@ Silk.NET.Maths.Matrix4X3.Row1 -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix4X3.Row2 -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix4X3.Row3 -> Silk.NET.Maths.Vector3D Silk.NET.Maths.Matrix4X3.Row4 -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Matrix4X3.this[int x, int i].get -> T -Silk.NET.Maths.Matrix4X3.this[int x].get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix4X3.this[int row, int column].get -> T +Silk.NET.Maths.Matrix4X3.this[int row].get -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Matrix4X3.Transpose() -> Silk.NET.Maths.Matrix3X4 Silk.NET.Maths.Matrix4X4 Silk.NET.Maths.Matrix4X4 Silk.NET.Maths.Matrix4X4.As() -> Silk.NET.Maths.Matrix4X4 +Silk.NET.Maths.Matrix4X4.AsChecked() -> Silk.NET.Maths.Matrix4X4 +Silk.NET.Maths.Matrix4X4.AsSaturating() -> Silk.NET.Maths.Matrix4X4 +Silk.NET.Maths.Matrix4X4.AsTruncating() -> Silk.NET.Maths.Matrix4X4 Silk.NET.Maths.Matrix4X4.Column1.get -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix4X4.Column2.get -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix4X4.Column3.get -> Silk.NET.Maths.Vector4D @@ -450,37 +421,21 @@ Silk.NET.Maths.Matrix4X4.Equals(Silk.NET.Maths.Matrix4X4 other) -> bool Silk.NET.Maths.Matrix4X4.GetDeterminant() -> T Silk.NET.Maths.Matrix4X4.IsIdentity.get -> bool Silk.NET.Maths.Matrix4X4.M11.get -> T -Silk.NET.Maths.Matrix4X4.M11.set -> void Silk.NET.Maths.Matrix4X4.M12.get -> T -Silk.NET.Maths.Matrix4X4.M12.set -> void Silk.NET.Maths.Matrix4X4.M13.get -> T -Silk.NET.Maths.Matrix4X4.M13.set -> void Silk.NET.Maths.Matrix4X4.M14.get -> T -Silk.NET.Maths.Matrix4X4.M14.set -> void Silk.NET.Maths.Matrix4X4.M21.get -> T -Silk.NET.Maths.Matrix4X4.M21.set -> void Silk.NET.Maths.Matrix4X4.M22.get -> T -Silk.NET.Maths.Matrix4X4.M22.set -> void Silk.NET.Maths.Matrix4X4.M23.get -> T -Silk.NET.Maths.Matrix4X4.M23.set -> void Silk.NET.Maths.Matrix4X4.M24.get -> T -Silk.NET.Maths.Matrix4X4.M24.set -> void Silk.NET.Maths.Matrix4X4.M31.get -> T -Silk.NET.Maths.Matrix4X4.M31.set -> void Silk.NET.Maths.Matrix4X4.M32.get -> T -Silk.NET.Maths.Matrix4X4.M32.set -> void Silk.NET.Maths.Matrix4X4.M33.get -> T -Silk.NET.Maths.Matrix4X4.M33.set -> void Silk.NET.Maths.Matrix4X4.M34.get -> T -Silk.NET.Maths.Matrix4X4.M34.set -> void Silk.NET.Maths.Matrix4X4.M41.get -> T -Silk.NET.Maths.Matrix4X4.M41.set -> void Silk.NET.Maths.Matrix4X4.M42.get -> T -Silk.NET.Maths.Matrix4X4.M42.set -> void Silk.NET.Maths.Matrix4X4.M43.get -> T -Silk.NET.Maths.Matrix4X4.M43.set -> void Silk.NET.Maths.Matrix4X4.M44.get -> T -Silk.NET.Maths.Matrix4X4.M44.set -> void Silk.NET.Maths.Matrix4X4.Matrix4X4() -> void Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix2X4 value) -> void Silk.NET.Maths.Matrix4X4.Matrix4X4(Silk.NET.Maths.Matrix3X2 value) -> void @@ -494,53 +449,37 @@ Silk.NET.Maths.Matrix4X4.Row1 -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix4X4.Row2 -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix4X4.Row3 -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix4X4.Row4 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix4X4.this[int x, int y].get -> T -Silk.NET.Maths.Matrix4X4.this[int x].get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X4.this[int row, int column].get -> T +Silk.NET.Maths.Matrix4X4.this[int row].get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix4X4.Transpose() -> Silk.NET.Maths.Matrix4X4 Silk.NET.Maths.Matrix5X4 Silk.NET.Maths.Matrix5X4 Silk.NET.Maths.Matrix5X4.As() -> Silk.NET.Maths.Matrix5X4 +Silk.NET.Maths.Matrix5X4.AsChecked() -> Silk.NET.Maths.Matrix5X4 +Silk.NET.Maths.Matrix5X4.AsSaturating() -> Silk.NET.Maths.Matrix5X4 +Silk.NET.Maths.Matrix5X4.AsTruncating() -> Silk.NET.Maths.Matrix5X4 Silk.NET.Maths.Matrix5X4.Equals(Silk.NET.Maths.Matrix5X4 other) -> bool Silk.NET.Maths.Matrix5X4.IsIdentity.get -> bool Silk.NET.Maths.Matrix5X4.M11.get -> T -Silk.NET.Maths.Matrix5X4.M11.set -> void Silk.NET.Maths.Matrix5X4.M12.get -> T -Silk.NET.Maths.Matrix5X4.M12.set -> void Silk.NET.Maths.Matrix5X4.M13.get -> T -Silk.NET.Maths.Matrix5X4.M13.set -> void Silk.NET.Maths.Matrix5X4.M14.get -> T -Silk.NET.Maths.Matrix5X4.M14.set -> void Silk.NET.Maths.Matrix5X4.M21.get -> T -Silk.NET.Maths.Matrix5X4.M21.set -> void Silk.NET.Maths.Matrix5X4.M22.get -> T -Silk.NET.Maths.Matrix5X4.M22.set -> void Silk.NET.Maths.Matrix5X4.M23.get -> T -Silk.NET.Maths.Matrix5X4.M23.set -> void Silk.NET.Maths.Matrix5X4.M24.get -> T -Silk.NET.Maths.Matrix5X4.M24.set -> void Silk.NET.Maths.Matrix5X4.M31.get -> T -Silk.NET.Maths.Matrix5X4.M31.set -> void Silk.NET.Maths.Matrix5X4.M32.get -> T -Silk.NET.Maths.Matrix5X4.M32.set -> void Silk.NET.Maths.Matrix5X4.M33.get -> T -Silk.NET.Maths.Matrix5X4.M33.set -> void Silk.NET.Maths.Matrix5X4.M34.get -> T -Silk.NET.Maths.Matrix5X4.M34.set -> void Silk.NET.Maths.Matrix5X4.M41.get -> T -Silk.NET.Maths.Matrix5X4.M41.set -> void Silk.NET.Maths.Matrix5X4.M42.get -> T -Silk.NET.Maths.Matrix5X4.M42.set -> void Silk.NET.Maths.Matrix5X4.M43.get -> T -Silk.NET.Maths.Matrix5X4.M43.set -> void Silk.NET.Maths.Matrix5X4.M44.get -> T -Silk.NET.Maths.Matrix5X4.M44.set -> void Silk.NET.Maths.Matrix5X4.M51.get -> T -Silk.NET.Maths.Matrix5X4.M51.set -> void Silk.NET.Maths.Matrix5X4.M52.get -> T -Silk.NET.Maths.Matrix5X4.M52.set -> void Silk.NET.Maths.Matrix5X4.M53.get -> T -Silk.NET.Maths.Matrix5X4.M53.set -> void Silk.NET.Maths.Matrix5X4.M54.get -> T -Silk.NET.Maths.Matrix5X4.M54.set -> void Silk.NET.Maths.Matrix5X4.Matrix5X4() -> void Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix2X4 value) -> void Silk.NET.Maths.Matrix5X4.Matrix5X4(Silk.NET.Maths.Matrix3X2 value) -> void @@ -556,8 +495,8 @@ Silk.NET.Maths.Matrix5X4.Row2 -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix5X4.Row3 -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix5X4.Row4 -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Matrix5X4.Row5 -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Matrix5X4.this[int x, int y].get -> T -Silk.NET.Maths.Matrix5X4.this[int x].get -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Matrix5X4.this[int row, int column].get -> T +Silk.NET.Maths.Matrix5X4.this[int row].get -> Silk.NET.Maths.Vector4D Silk.NET.Maths.Plane Silk.NET.Maths.Plane Silk.NET.Maths.Plane.As() -> Silk.NET.Maths.Plane @@ -569,6 +508,7 @@ Silk.NET.Maths.Plane.Plane(Silk.NET.Maths.Vector3D normal, T distance) -> Silk.NET.Maths.Plane.Plane(Silk.NET.Maths.Vector4D value) -> void Silk.NET.Maths.Plane.Plane(T x, T y, T z, T distance) -> void Silk.NET.Maths.Quaternion +Silk.NET.Maths.Quaternion.Angle.get -> T Silk.NET.Maths.Quaternion.As() -> Silk.NET.Maths.Quaternion Silk.NET.Maths.Quaternion.Equals(Silk.NET.Maths.Quaternion other) -> bool Silk.NET.Maths.Quaternion.IsIdentity.get -> bool @@ -577,6 +517,7 @@ Silk.NET.Maths.Quaternion.LengthSquared() -> T Silk.NET.Maths.Quaternion.Quaternion() -> void Silk.NET.Maths.Quaternion.Quaternion(Silk.NET.Maths.Vector3D vectorPart, T scalarPart) -> void Silk.NET.Maths.Quaternion.Quaternion(T x, T y, T z, T w) -> void +Silk.NET.Maths.Quaternion.this[int index].get -> T Silk.NET.Maths.Quaternion.W -> T Silk.NET.Maths.Quaternion.X -> T Silk.NET.Maths.Quaternion.Y -> T @@ -610,7 +551,6 @@ Silk.NET.Maths.Rectangle.Center.get -> Silk.NET.Maths.Vector2D Silk.NET.Maths.Rectangle.Contains(Silk.NET.Maths.Rectangle other) -> bool Silk.NET.Maths.Rectangle.Contains(Silk.NET.Maths.Vector2D point) -> bool Silk.NET.Maths.Rectangle.Equals(Silk.NET.Maths.Rectangle other) -> bool -Silk.NET.Maths.Rectangle.GetDistanceToNearestEdge(Silk.NET.Maths.Vector2D point) -> T Silk.NET.Maths.Rectangle.GetInflated(Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Rectangle Silk.NET.Maths.Rectangle.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Rectangle Silk.NET.Maths.Rectangle.GetScaled(Silk.NET.Maths.Vector2D scale, Silk.NET.Maths.Vector2D anchor) -> Silk.NET.Maths.Rectangle @@ -624,18 +564,14 @@ Silk.NET.Maths.Rectangle.Rectangle(Silk.NET.Maths.Vector2D origin, T sizeX Silk.NET.Maths.Rectangle.Rectangle(T originX, T originY, Silk.NET.Maths.Vector2D size) -> void Silk.NET.Maths.Rectangle.Rectangle(T originX, T originY, T sizeX, T sizeY) -> void Silk.NET.Maths.Rectangle.Size -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Scalar -Silk.NET.Maths.Scalar +Silk.NET.Maths.Sphere Silk.NET.Maths.Sphere Silk.NET.Maths.Sphere.As() -> Silk.NET.Maths.Sphere Silk.NET.Maths.Sphere.Center -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Sphere.Contains(Silk.NET.Maths.Sphere other) -> bool -Silk.NET.Maths.Sphere.Contains(Silk.NET.Maths.Vector3D point) -> bool Silk.NET.Maths.Sphere.Diameter.get -> T Silk.NET.Maths.Sphere.Equals(Silk.NET.Maths.Sphere other) -> bool Silk.NET.Maths.Sphere.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D point) -> T Silk.NET.Maths.Sphere.GetDistanceToNearestEdgeSquared(Silk.NET.Maths.Vector3D point) -> T -Silk.NET.Maths.Sphere.GetInflated(Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Sphere Silk.NET.Maths.Sphere.GetTranslated(Silk.NET.Maths.Vector3D distance) -> Silk.NET.Maths.Sphere Silk.NET.Maths.Sphere.Radius -> T Silk.NET.Maths.Sphere.Sphere() -> void @@ -644,93 +580,134 @@ Silk.NET.Maths.Sphere.Sphere(T centerX, T centerY, T centerZ, T radius) -> vo Silk.NET.Maths.Sphere.SquaredRadius.get -> T Silk.NET.Maths.SystemNumericsExtensions Silk.NET.Maths.Vector2D +Silk.NET.Maths.Vector2D.extension(Silk.NET.Maths.Vector2D) +Silk.NET.Maths.Vector2D.extension(Silk.NET.Maths.Vector2D).Length.get -> T +Silk.NET.Maths.Vector2D.extension(Silk.NET.Maths.Vector2D).LengthSquared.get -> T Silk.NET.Maths.Vector2D Silk.NET.Maths.Vector2D.As() -> Silk.NET.Maths.Vector2D -Silk.NET.Maths.Vector2D.CopyTo(T[]? array) -> void -Silk.NET.Maths.Vector2D.CopyTo(T[]? array, int index) -> void +Silk.NET.Maths.Vector2D.AsChecked() -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Vector2D.AsSaturating() -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Vector2D.AsSpan() -> System.Span +Silk.NET.Maths.Vector2D.AsTruncating() -> Silk.NET.Maths.Vector2D +Silk.NET.Maths.Vector2D.CopyTo(System.Span span) -> void +Silk.NET.Maths.Vector2D.CopyTo(System.Span span, int startIndex) -> void +Silk.NET.Maths.Vector2D.CopyTo(T[]! array) -> void +Silk.NET.Maths.Vector2D.CopyTo(T[]! array, int startIndex) -> void +Silk.NET.Maths.Vector2D.Count.get -> int Silk.NET.Maths.Vector2D.Equals(Silk.NET.Maths.Vector2D other) -> bool -Silk.NET.Maths.Vector2D.Length.get -> T -Silk.NET.Maths.Vector2D.LengthSquared.get -> T -Silk.NET.Maths.Vector2D.this[int i].get -> T -Silk.NET.Maths.Vector2D.ToString(string? format) -> string! +Silk.NET.Maths.Vector2D.GetEnumerator() -> System.Collections.Generic.IEnumerator! +Silk.NET.Maths.Vector2D.this[int index].get -> T Silk.NET.Maths.Vector2D.ToString(string? format, System.IFormatProvider? formatProvider) -> string! +Silk.NET.Maths.Vector2D.TryFormat(System.Span utf8Destination, out int bytesWritten, System.ReadOnlySpan format, System.IFormatProvider? provider) -> bool +Silk.NET.Maths.Vector2D.TryFormat(System.Span destination, out int charsWritten, System.ReadOnlySpan format, System.IFormatProvider? provider) -> bool Silk.NET.Maths.Vector2D.Vector2D() -> void +Silk.NET.Maths.Vector2D.Vector2D(System.ReadOnlySpan values) -> void Silk.NET.Maths.Vector2D.Vector2D(T value) -> void Silk.NET.Maths.Vector2D.Vector2D(T x, T y) -> void Silk.NET.Maths.Vector2D.X -> T Silk.NET.Maths.Vector2D.Y -> T Silk.NET.Maths.Vector3D +Silk.NET.Maths.Vector3D.extension(Silk.NET.Maths.Vector3D) +Silk.NET.Maths.Vector3D.extension(Silk.NET.Maths.Vector3D).Length.get -> T +Silk.NET.Maths.Vector3D.extension(Silk.NET.Maths.Vector3D).LengthSquared.get -> T Silk.NET.Maths.Vector3D Silk.NET.Maths.Vector3D.As() -> Silk.NET.Maths.Vector3D -Silk.NET.Maths.Vector3D.CopyTo(T[]? array) -> void -Silk.NET.Maths.Vector3D.CopyTo(T[]? array, int index) -> void +Silk.NET.Maths.Vector3D.AsChecked() -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Vector3D.AsSaturating() -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Vector3D.AsSpan() -> System.Span +Silk.NET.Maths.Vector3D.AsTruncating() -> Silk.NET.Maths.Vector3D +Silk.NET.Maths.Vector3D.CopyTo(System.Span span) -> void +Silk.NET.Maths.Vector3D.CopyTo(System.Span span, int startIndex) -> void +Silk.NET.Maths.Vector3D.CopyTo(T[]! array) -> void +Silk.NET.Maths.Vector3D.CopyTo(T[]! array, int startIndex) -> void +Silk.NET.Maths.Vector3D.Count.get -> int Silk.NET.Maths.Vector3D.Equals(Silk.NET.Maths.Vector3D other) -> bool -Silk.NET.Maths.Vector3D.Length.get -> T -Silk.NET.Maths.Vector3D.LengthSquared.get -> T -Silk.NET.Maths.Vector3D.this[int i].get -> T -Silk.NET.Maths.Vector3D.ToString(string? format) -> string! +Silk.NET.Maths.Vector3D.GetEnumerator() -> System.Collections.Generic.IEnumerator! +Silk.NET.Maths.Vector3D.this[int index].get -> T Silk.NET.Maths.Vector3D.ToString(string? format, System.IFormatProvider? formatProvider) -> string! +Silk.NET.Maths.Vector3D.TryFormat(System.Span utf8Destination, out int bytesWritten, System.ReadOnlySpan format, System.IFormatProvider? provider) -> bool +Silk.NET.Maths.Vector3D.TryFormat(System.Span destination, out int charsWritten, System.ReadOnlySpan format, System.IFormatProvider? provider) -> bool Silk.NET.Maths.Vector3D.Vector3D() -> void -Silk.NET.Maths.Vector3D.Vector3D(Silk.NET.Maths.Vector2D value, T z) -> void +Silk.NET.Maths.Vector3D.Vector3D(Silk.NET.Maths.Vector2D other, T z) -> void +Silk.NET.Maths.Vector3D.Vector3D(System.ReadOnlySpan values) -> void Silk.NET.Maths.Vector3D.Vector3D(T value) -> void Silk.NET.Maths.Vector3D.Vector3D(T x, T y, T z) -> void Silk.NET.Maths.Vector3D.X -> T Silk.NET.Maths.Vector3D.Y -> T Silk.NET.Maths.Vector3D.Z -> T Silk.NET.Maths.Vector4D +Silk.NET.Maths.Vector4D.extension(Silk.NET.Maths.Vector4D) +Silk.NET.Maths.Vector4D.extension(Silk.NET.Maths.Vector4D).Length.get -> T +Silk.NET.Maths.Vector4D.extension(Silk.NET.Maths.Vector4D).LengthSquared.get -> T Silk.NET.Maths.Vector4D Silk.NET.Maths.Vector4D.As() -> Silk.NET.Maths.Vector4D -Silk.NET.Maths.Vector4D.CopyTo(T[]? array) -> void -Silk.NET.Maths.Vector4D.CopyTo(T[]? array, int index) -> void +Silk.NET.Maths.Vector4D.AsChecked() -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Vector4D.AsSaturating() -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Vector4D.AsSpan() -> System.Span +Silk.NET.Maths.Vector4D.AsTruncating() -> Silk.NET.Maths.Vector4D +Silk.NET.Maths.Vector4D.CopyTo(System.Span span) -> void +Silk.NET.Maths.Vector4D.CopyTo(System.Span span, int startIndex) -> void +Silk.NET.Maths.Vector4D.CopyTo(T[]! array) -> void +Silk.NET.Maths.Vector4D.CopyTo(T[]! array, int startIndex) -> void +Silk.NET.Maths.Vector4D.Count.get -> int Silk.NET.Maths.Vector4D.Equals(Silk.NET.Maths.Vector4D other) -> bool -Silk.NET.Maths.Vector4D.Length.get -> T -Silk.NET.Maths.Vector4D.LengthSquared.get -> T -Silk.NET.Maths.Vector4D.this[int i].get -> T -Silk.NET.Maths.Vector4D.ToString(string? format) -> string! +Silk.NET.Maths.Vector4D.GetEnumerator() -> System.Collections.Generic.IEnumerator! +Silk.NET.Maths.Vector4D.this[int index].get -> T Silk.NET.Maths.Vector4D.ToString(string? format, System.IFormatProvider? formatProvider) -> string! +Silk.NET.Maths.Vector4D.TryFormat(System.Span utf8Destination, out int bytesWritten, System.ReadOnlySpan format, System.IFormatProvider? provider) -> bool +Silk.NET.Maths.Vector4D.TryFormat(System.Span destination, out int charsWritten, System.ReadOnlySpan format, System.IFormatProvider? provider) -> bool Silk.NET.Maths.Vector4D.Vector4D() -> void -Silk.NET.Maths.Vector4D.Vector4D(Silk.NET.Maths.Vector2D value, T z, T w) -> void -Silk.NET.Maths.Vector4D.Vector4D(Silk.NET.Maths.Vector3D value, T w) -> void +Silk.NET.Maths.Vector4D.Vector4D(Silk.NET.Maths.Vector2D other, T z, T w) -> void +Silk.NET.Maths.Vector4D.Vector4D(Silk.NET.Maths.Vector3D other, T w) -> void +Silk.NET.Maths.Vector4D.Vector4D(System.ReadOnlySpan values) -> void Silk.NET.Maths.Vector4D.Vector4D(T value) -> void Silk.NET.Maths.Vector4D.Vector4D(T x, T y, T z, T w) -> void Silk.NET.Maths.Vector4D.W -> T Silk.NET.Maths.Vector4D.X -> T Silk.NET.Maths.Vector4D.Y -> T Silk.NET.Maths.Vector4D.Z -> T -static readonly Silk.NET.Maths.Scalar.DegreesPerRadian -> T -static readonly Silk.NET.Maths.Scalar.E -> T -static readonly Silk.NET.Maths.Scalar.Epsilon -> T -static readonly Silk.NET.Maths.Scalar.MaxValue -> T -static readonly Silk.NET.Maths.Scalar.MinusOne -> T -static readonly Silk.NET.Maths.Scalar.MinusTwo -> T -static readonly Silk.NET.Maths.Scalar.MinValue -> T -static readonly Silk.NET.Maths.Scalar.NaN -> T -static readonly Silk.NET.Maths.Scalar.NegativeInfinity -> T -static readonly Silk.NET.Maths.Scalar.One -> T -static readonly Silk.NET.Maths.Scalar.Pi -> T -static readonly Silk.NET.Maths.Scalar.PiOver2 -> T -static readonly Silk.NET.Maths.Scalar.PositiveInfinity -> T -static readonly Silk.NET.Maths.Scalar.RadiansPerDegree -> T -static readonly Silk.NET.Maths.Scalar.Tau -> T -static readonly Silk.NET.Maths.Scalar.Two -> T -static readonly Silk.NET.Maths.Scalar.Zero -> T +static Silk.NET.Maths.Box2D.GetDistanceToNearestEdge(this Silk.NET.Maths.Box2D box, Silk.NET.Maths.Vector2D point) -> T static Silk.NET.Maths.Box2D.operator !=(Silk.NET.Maths.Box2D value1, Silk.NET.Maths.Box2D value2) -> bool static Silk.NET.Maths.Box2D.operator ==(Silk.NET.Maths.Box2D value1, Silk.NET.Maths.Box2D value2) -> bool +static Silk.NET.Maths.Box3D.GetDistanceToNearestEdge(this Silk.NET.Maths.Box3D box, Silk.NET.Maths.Vector3D point) -> T static Silk.NET.Maths.Box3D.operator !=(Silk.NET.Maths.Box3D value1, Silk.NET.Maths.Box3D value2) -> bool static Silk.NET.Maths.Box3D.operator ==(Silk.NET.Maths.Box3D value1, Silk.NET.Maths.Box3D value2) -> bool +static Silk.NET.Maths.Circle.Contains(this Silk.NET.Maths.Circle circle, Silk.NET.Maths.Circle other) -> bool +static Silk.NET.Maths.Circle.Contains(this Silk.NET.Maths.Circle circle, Silk.NET.Maths.Vector2D point) -> bool +static Silk.NET.Maths.Circle.GetInflated(this Silk.NET.Maths.Circle circle, Silk.NET.Maths.Vector2D point) -> Silk.NET.Maths.Circle static Silk.NET.Maths.Circle.operator !=(Silk.NET.Maths.Circle value1, Silk.NET.Maths.Circle value2) -> bool static Silk.NET.Maths.Circle.operator ==(Silk.NET.Maths.Circle value1, Silk.NET.Maths.Circle value2) -> bool +static Silk.NET.Maths.Cube.GetDistanceToNearestEdge(Silk.NET.Maths.Cube cube, Silk.NET.Maths.Vector3D point) -> T static Silk.NET.Maths.Cube.operator !=(Silk.NET.Maths.Cube value1, Silk.NET.Maths.Cube value2) -> bool static Silk.NET.Maths.Cube.operator ==(Silk.NET.Maths.Cube value1, Silk.NET.Maths.Cube value2) -> bool -static Silk.NET.Maths.Matrix2X2.Add(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.Lerp(Silk.NET.Maths.Matrix2X2 matrix1, Silk.NET.Maths.Matrix2X2 matrix2, T amount) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 value1, T value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X2.Add(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.Lerp(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2, T amount) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 left, T right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix2X2 matrix, Silk.NET.Maths.Vector2D columnVector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix2X2.Multiply(Silk.NET.Maths.Vector2D rowVector, Silk.NET.Maths.Matrix2X2 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X2.Multiply(T left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 static Silk.NET.Maths.Matrix2X2.Negate(Silk.NET.Maths.Matrix2X2 value) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.Subtract(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.Subtract(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.CreateChecked(Silk.NET.Maths.Matrix2X2 other) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.CreateSaturating(Silk.NET.Maths.Matrix2X2 other) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.CreateTruncating(Silk.NET.Maths.Matrix2X2 other) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.explicit operator checked Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 @@ -744,28 +721,50 @@ static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 static Silk.NET.Maths.Matrix2X2.explicit operator Silk.NET.Maths.Matrix2X2(Silk.NET.Maths.Matrix2X2 from) -> Silk.NET.Maths.Matrix2X2 static Silk.NET.Maths.Matrix2X2.Identity.get -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.operator !=(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> bool -static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Matrix2X2 value1, T value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Matrix2X2.operator +(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.operator !=(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> bool +static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Matrix2X2 left, T right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Matrix2X2 matrix, Silk.NET.Maths.Vector2D columnVector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X2.operator *(Silk.NET.Maths.Vector2D rowVector, Silk.NET.Maths.Matrix2X2 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X2.operator *(T left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.operator +(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X2.operator -(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix2X2 static Silk.NET.Maths.Matrix2X2.operator -(Silk.NET.Maths.Matrix2X2 value) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.operator -(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X2.operator ==(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> bool -static Silk.NET.Maths.Matrix2X3.Add(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X2.operator ==(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X2 right) -> bool +static Silk.NET.Maths.Matrix2X3.Add(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 static Silk.NET.Maths.Matrix2X3.CreateBillboard(Silk.NET.Maths.Vector3D objectPosition, Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D cameraUpVector, Silk.NET.Maths.Vector3D cameraForwardVector) -> Silk.NET.Maths.Matrix2X3 static Silk.NET.Maths.Matrix2X3.CreateFromAxisAngle(Silk.NET.Maths.Vector3D axis, T angle) -> Silk.NET.Maths.Matrix2X3 static Silk.NET.Maths.Matrix2X3.CreateFromQuaternion(Silk.NET.Maths.Quaternion quaternion) -> Silk.NET.Maths.Matrix2X3 static Silk.NET.Maths.Matrix2X3.CreateFromYawPitchRoll(T yaw, T pitch, T roll) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Lerp(Silk.NET.Maths.Matrix2X3 matrix1, Silk.NET.Maths.Matrix2X3 matrix2, T amount) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 value1, T value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix2X3.Lerp(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2, T amount) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 left, T right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix2X3 matrix, Silk.NET.Maths.Vector3D columnVector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix2X3.Multiply(Silk.NET.Maths.Vector2D rowVector, Silk.NET.Maths.Matrix2X3 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix2X3.Multiply(T left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 static Silk.NET.Maths.Matrix2X3.Negate(Silk.NET.Maths.Matrix2X3 value) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.Subtract(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.Subtract(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 static Silk.NET.Maths.Matrix2X3.Transform(Silk.NET.Maths.Matrix2X3 value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.CreateChecked(Silk.NET.Maths.Matrix2X3 other) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.CreateSaturating(Silk.NET.Maths.Matrix2X3 other) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.CreateTruncating(Silk.NET.Maths.Matrix2X3 other) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.explicit operator checked Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 @@ -779,25 +778,46 @@ static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 static Silk.NET.Maths.Matrix2X3.explicit operator Silk.NET.Maths.Matrix2X3(Silk.NET.Maths.Matrix2X3 from) -> Silk.NET.Maths.Matrix2X3 static Silk.NET.Maths.Matrix2X3.Identity.get -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator !=(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2) -> bool -static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X3 value1, T value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Matrix2X3.operator +(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.operator !=(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix2X3 right) -> bool +static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X3 left, T right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Matrix2X3 matrix, Silk.NET.Maths.Vector3D columnVector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X3.operator *(Silk.NET.Maths.Vector2D rowVector, Silk.NET.Maths.Matrix2X3 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix2X3.operator *(T left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.operator +(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X3.operator -(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix2X3 static Silk.NET.Maths.Matrix2X3.operator -(Silk.NET.Maths.Matrix2X3 value) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator -(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X3.operator ==(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix2X3 value2) -> bool -static Silk.NET.Maths.Matrix2X4.Add(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.Lerp(Silk.NET.Maths.Matrix2X4 matrix1, Silk.NET.Maths.Matrix2X4 matrix2, T amount) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix2X3.operator ==(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix2X3 right) -> bool +static Silk.NET.Maths.Matrix2X4.Add(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Lerp(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix2X4 value2, T amount) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 left, T right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix2X4 matrix, Silk.NET.Maths.Vector4D columnVector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix2X4.Multiply(Silk.NET.Maths.Vector2D rowVector, Silk.NET.Maths.Matrix2X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix2X4.Multiply(T left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Negate(Silk.NET.Maths.Matrix2X4 value) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.Subtract(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.CreateChecked(Silk.NET.Maths.Matrix2X4 other) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.CreateSaturating(Silk.NET.Maths.Matrix2X4 other) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.CreateTruncating(Silk.NET.Maths.Matrix2X4 other) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.explicit operator checked Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 @@ -811,18 +831,19 @@ static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 static Silk.NET.Maths.Matrix2X4.explicit operator Silk.NET.Maths.Matrix2X4(Silk.NET.Maths.Matrix2X4 from) -> Silk.NET.Maths.Matrix2X4 static Silk.NET.Maths.Matrix2X4.Identity.get -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator !=(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix2X4 value2) -> bool -static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X4 value1, T value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Matrix2X4.operator +(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.operator !=(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix2X4 right) -> bool +static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X4 left, T right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix2X4 matrix, Silk.NET.Maths.Vector4D columnVector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix2X4.operator *(Silk.NET.Maths.Vector2D rowVector, Silk.NET.Maths.Matrix2X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix2X4.operator *(T left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.operator +(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix2X4.operator -(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix2X4 static Silk.NET.Maths.Matrix2X4.operator -(Silk.NET.Maths.Matrix2X4 value) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator -(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix2X4.operator ==(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix2X4 value2) -> bool -static Silk.NET.Maths.Matrix3X2.Add(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix2X4.operator ==(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix2X4 right) -> bool +static Silk.NET.Maths.Matrix3X2.Add(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.CreateRotation(T radians) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.CreateRotation(T radians, Silk.NET.Maths.Vector2D centerPoint) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.CreateScale(Silk.NET.Maths.Vector2D scales) -> Silk.NET.Maths.Matrix3X2 @@ -836,15 +857,36 @@ static Silk.NET.Maths.Matrix3X2.CreateSkew(T radiansX, T radiansY, Silk.NET.M static Silk.NET.Maths.Matrix3X2.CreateTranslation(Silk.NET.Maths.Vector2D position) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.CreateTranslation(T xPosition, T yPosition) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.Invert(Silk.NET.Maths.Matrix3X2 matrix, out Silk.NET.Maths.Matrix3X2 result) -> bool -static Silk.NET.Maths.Matrix3X2.Lerp(Silk.NET.Maths.Matrix3X2 matrix1, Silk.NET.Maths.Matrix3X2 matrix2, T amount) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 value1, T value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix3X2.Lerp(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2, T amount) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 left, T right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X2 matrix, Silk.NET.Maths.Vector2D columnVector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix3X2.Multiply(Silk.NET.Maths.Vector3D rowVector, Silk.NET.Maths.Matrix3X2 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix3X2.Multiply(T left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.Negate(Silk.NET.Maths.Matrix3X2 value) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.Subtract(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.Subtract(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateChecked(Silk.NET.Maths.Matrix3X2 other) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateSaturating(Silk.NET.Maths.Matrix3X2 other) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.CreateTruncating(Silk.NET.Maths.Matrix3X2 other) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(System.Numerics.Matrix3x2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator checked System.Numerics.Matrix3x2(Silk.NET.Maths.Matrix3X2 from) -> System.Numerics.Matrix3x2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 @@ -854,22 +896,24 @@ static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(System.Numerics.Matrix3x2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator Silk.NET.Maths.Matrix3X2(Silk.NET.Maths.Matrix3X2 from) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.explicit operator System.Numerics.Matrix3x2(Silk.NET.Maths.Matrix3X2 from) -> System.Numerics.Matrix3x2 static Silk.NET.Maths.Matrix3X2.Identity.get -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator !=(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2) -> bool -static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 value1, T value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Matrix3X2.operator +(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.operator !=(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix3X2 right) -> bool +static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 left, T right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Matrix3X2 matrix, Silk.NET.Maths.Vector2D columnVector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X2.operator *(Silk.NET.Maths.Vector3D rowVector, Silk.NET.Maths.Matrix3X2 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix3X2.operator *(T left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.operator +(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X2.operator -(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 static Silk.NET.Maths.Matrix3X2.operator -(Silk.NET.Maths.Matrix3X2 value) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator -(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X2.operator ==(Silk.NET.Maths.Matrix3X2 value1, Silk.NET.Maths.Matrix3X2 value2) -> bool -static Silk.NET.Maths.Matrix3X3.Add(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X2.operator ==(Silk.NET.Maths.Matrix3X2 left, Silk.NET.Maths.Matrix3X2 right) -> bool +static Silk.NET.Maths.Matrix3X3.Add(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.CreateBillboard(Silk.NET.Maths.Vector3D objectPosition, Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D cameraUpVector, Silk.NET.Maths.Vector3D cameraForwardVector) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.CreateFromAxisAngle(Silk.NET.Maths.Vector3D axis, T angle) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.CreateFromQuaternion(Silk.NET.Maths.Quaternion quaternion) -> Silk.NET.Maths.Matrix3X3 @@ -880,19 +924,35 @@ static Silk.NET.Maths.Matrix3X3.CreateRotationZ(T radians) -> Silk.NET.Maths. static Silk.NET.Maths.Matrix3X3.CreateScale(Silk.NET.Maths.Vector3D scales) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.CreateScale(T scale) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.CreateScale(T xScale, T yScale, T zScale) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Decompose(Silk.NET.Maths.Matrix3X3 matrix, out Silk.NET.Maths.Vector3D scale, out Silk.NET.Maths.Quaternion rotation) -> bool -static Silk.NET.Maths.Matrix3X3.Lerp(Silk.NET.Maths.Matrix3X3 matrix1, Silk.NET.Maths.Matrix3X3 matrix2, T amount) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix2X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix2X3 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 value1, T value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X3.Lerp(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2, T amount) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 left, T right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix3X3 matrix, Silk.NET.Maths.Vector3D columnVector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix3X3.Multiply(Silk.NET.Maths.Vector3D rowVector, Silk.NET.Maths.Matrix3X3 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X3.Multiply(T left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.Negate(Silk.NET.Maths.Matrix3X3 value) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.Subtract(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.Subtract(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.Transform(Silk.NET.Maths.Matrix3X3 value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.Transpose(Silk.NET.Maths.Matrix3X3 matrix) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateChecked(Silk.NET.Maths.Matrix3X3 other) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateSaturating(Silk.NET.Maths.Matrix3X3 other) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.CreateTruncating(Silk.NET.Maths.Matrix3X3 other) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.explicit operator checked Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 @@ -906,24 +966,47 @@ static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.explicit operator Silk.NET.Maths.Matrix3X3(Silk.NET.Maths.Matrix3X3 from) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.Identity.get -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.operator !=(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> bool -static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix3X3 value1, T value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Matrix3X3.operator +(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.operator !=(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> bool +static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix3X3 left, T right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Matrix3X3 matrix, Silk.NET.Maths.Vector3D columnVector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X3.operator *(Silk.NET.Maths.Vector3D rowVector, Silk.NET.Maths.Matrix3X3 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X3.operator *(T left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.operator +(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X3.operator -(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix3X3 static Silk.NET.Maths.Matrix3X3.operator -(Silk.NET.Maths.Matrix3X3 value) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.operator -(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X3.operator ==(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> bool -static Silk.NET.Maths.Matrix3X4.Add(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Lerp(Silk.NET.Maths.Matrix3X4 matrix1, Silk.NET.Maths.Matrix3X4 matrix2, T amount) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 value1, T value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix3X3.operator ==(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X3 right) -> bool +static Silk.NET.Maths.Matrix3X4.Add(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Lerp(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2, T amount) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 left, T right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix3X4 matrix, Silk.NET.Maths.Vector4D columnVector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix3X4.Multiply(Silk.NET.Maths.Vector3D rowVector, Silk.NET.Maths.Matrix3X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix3X4.Multiply(T left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 static Silk.NET.Maths.Matrix3X4.Negate(Silk.NET.Maths.Matrix3X4 value) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.Subtract(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.Subtract(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.CreateChecked(Silk.NET.Maths.Matrix3X4 other) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.CreateSaturating(Silk.NET.Maths.Matrix3X4 other) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.CreateTruncating(Silk.NET.Maths.Matrix3X4 other) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.explicit operator checked Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 @@ -937,26 +1020,48 @@ static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 static Silk.NET.Maths.Matrix3X4.explicit operator Silk.NET.Maths.Matrix3X4(Silk.NET.Maths.Matrix3X4 from) -> Silk.NET.Maths.Matrix3X4 static Silk.NET.Maths.Matrix3X4.Identity.get -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.operator !=(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2) -> bool -static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X3 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X4 value1, T value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Matrix3X4.operator +(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.operator !=(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix3X4 right) -> bool +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix2X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X4 left, T right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Matrix3X4 matrix, Silk.NET.Maths.Vector4D columnVector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix3X4.operator *(Silk.NET.Maths.Vector3D rowVector, Silk.NET.Maths.Matrix3X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix3X4.operator *(T left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.operator +(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix3X4.operator -(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix3X4 static Silk.NET.Maths.Matrix3X4.operator -(Silk.NET.Maths.Matrix3X4 value) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.operator -(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix3X4.operator ==(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix3X4 value2) -> bool -static Silk.NET.Maths.Matrix4X2.Add(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.Lerp(Silk.NET.Maths.Matrix4X2 matrix1, Silk.NET.Maths.Matrix4X2 matrix2, T amount) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix3X4.operator ==(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix3X4 right) -> bool +static Silk.NET.Maths.Matrix4X2.Add(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Lerp(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2, T amount) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix2X2 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix3X2 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 left, T right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X2 matrix, Silk.NET.Maths.Vector2D columnVector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Multiply(Silk.NET.Maths.Vector4D rowVector, Silk.NET.Maths.Matrix4X2 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix4X2.Multiply(T left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 static Silk.NET.Maths.Matrix4X2.Negate(Silk.NET.Maths.Matrix4X2 value) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.Subtract(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.Subtract(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.CreateChecked(Silk.NET.Maths.Matrix4X2 other) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.CreateSaturating(Silk.NET.Maths.Matrix4X2 other) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.CreateTruncating(Silk.NET.Maths.Matrix4X2 other) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.explicit operator checked Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 @@ -970,29 +1075,47 @@ static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 static Silk.NET.Maths.Matrix4X2.explicit operator Silk.NET.Maths.Matrix4X2(Silk.NET.Maths.Matrix4X2 from) -> Silk.NET.Maths.Matrix4X2 static Silk.NET.Maths.Matrix4X2.Identity.get -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator !=(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2) -> bool -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix2X2 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix3X2 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 value1, T value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Matrix4X2.operator +(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.operator !=(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix4X2 right) -> bool +static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix2X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 left, T right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Matrix4X2 matrix, Silk.NET.Maths.Vector2D columnVector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X2.operator *(Silk.NET.Maths.Vector4D rowVector, Silk.NET.Maths.Matrix4X2 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Matrix4X2.operator *(T left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.operator +(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X2.operator -(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 static Silk.NET.Maths.Matrix4X2.operator -(Silk.NET.Maths.Matrix4X2 value) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator -(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X2.operator ==(Silk.NET.Maths.Matrix4X2 value1, Silk.NET.Maths.Matrix4X2 value2) -> bool -static Silk.NET.Maths.Matrix4X3.Add(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Lerp(Silk.NET.Maths.Matrix4X3 matrix1, Silk.NET.Maths.Matrix4X3 matrix2, T amount) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix3X3 -static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 value1, T value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix4X2.operator ==(Silk.NET.Maths.Matrix4X2 left, Silk.NET.Maths.Matrix4X2 right) -> bool +static Silk.NET.Maths.Matrix4X3.Add(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Lerp(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2, T amount) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix3X3 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 left, T right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X3 matrix, Silk.NET.Maths.Vector3D columnVector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Multiply(Silk.NET.Maths.Vector4D rowVector, Silk.NET.Maths.Matrix4X3 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix4X3.Multiply(T left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 static Silk.NET.Maths.Matrix4X3.Negate(Silk.NET.Maths.Matrix4X3 value) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.Subtract(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.Subtract(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.CreateChecked(Silk.NET.Maths.Matrix4X3 other) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.CreateSaturating(Silk.NET.Maths.Matrix4X3 other) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.CreateTruncating(Silk.NET.Maths.Matrix4X3 other) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.explicit operator checked Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 @@ -1006,16 +1129,20 @@ static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 static Silk.NET.Maths.Matrix4X3.explicit operator Silk.NET.Maths.Matrix4X3(Silk.NET.Maths.Matrix4X3 from) -> Silk.NET.Maths.Matrix4X3 static Silk.NET.Maths.Matrix4X3.Identity.get -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.operator !=(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2) -> bool -static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 value1, T value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Matrix4X3.operator +(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.operator !=(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix4X3 right) -> bool +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix2X3 +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix3X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 left, T right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Matrix4X3 matrix, Silk.NET.Maths.Vector3D columnVector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X3.operator *(Silk.NET.Maths.Vector4D rowVector, Silk.NET.Maths.Matrix4X3 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Matrix4X3.operator *(T left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.operator +(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X3.operator -(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 static Silk.NET.Maths.Matrix4X3.operator -(Silk.NET.Maths.Matrix4X3 value) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.operator -(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X3.operator ==(Silk.NET.Maths.Matrix4X3 value1, Silk.NET.Maths.Matrix4X3 value2) -> bool -static Silk.NET.Maths.Matrix4X4.Add(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X3.operator ==(Silk.NET.Maths.Matrix4X3 left, Silk.NET.Maths.Matrix4X3 right) -> bool +static Silk.NET.Maths.Matrix4X4.Add(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.CreateBillboard(Silk.NET.Maths.Vector3D objectPosition, Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D cameraUpVector, Silk.NET.Maths.Vector3D cameraForwardVector) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.CreateConstrainedBillboard(Silk.NET.Maths.Vector3D objectPosition, Silk.NET.Maths.Vector3D cameraPosition, Silk.NET.Maths.Vector3D rotateAxis, Silk.NET.Maths.Vector3D cameraForwardVector, Silk.NET.Maths.Vector3D objectForwardVector) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.CreateFromAxisAngle(Silk.NET.Maths.Vector3D axis, T angle) -> Silk.NET.Maths.Matrix4X4 @@ -1044,18 +1171,39 @@ static Silk.NET.Maths.Matrix4X4.CreateShadow(Silk.NET.Maths.Vector3D light static Silk.NET.Maths.Matrix4X4.CreateTranslation(Silk.NET.Maths.Vector3D position) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.CreateTranslation(T xPosition, T yPosition, T zPosition) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.CreateWorld(Silk.NET.Maths.Vector3D position, Silk.NET.Maths.Vector3D forward, Silk.NET.Maths.Vector3D up) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Decompose(Silk.NET.Maths.Matrix4X4 matrix, out Silk.NET.Maths.Vector3D scale, out Silk.NET.Maths.Quaternion rotation, out Silk.NET.Maths.Vector3D translation) -> bool static Silk.NET.Maths.Matrix4X4.Invert(Silk.NET.Maths.Matrix4X4 matrix, out Silk.NET.Maths.Matrix4X4 result) -> bool -static Silk.NET.Maths.Matrix4X4.Lerp(Silk.NET.Maths.Matrix4X4 matrix1, Silk.NET.Maths.Matrix4X4 matrix2, T amount) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix2X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix2X4 -static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Matrix4X2 -static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 value1, T value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X4.Lerp(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2, T amount) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 left, T right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix4X4 matrix, Silk.NET.Maths.Vector4D columnVector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix4X4.Multiply(Silk.NET.Maths.Vector4D rowVector, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X4.Multiply(T left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.Negate(Silk.NET.Maths.Matrix4X4 value) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.Subtract(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.Subtract(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.Transform(Silk.NET.Maths.Matrix4X4 value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.Transpose(Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateChecked(Silk.NET.Maths.Matrix4X4 other) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateSaturating(Silk.NET.Maths.Matrix4X4 other) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.CreateTruncating(Silk.NET.Maths.Matrix4X4 other) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(System.Numerics.Matrix4x4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator checked System.Numerics.Matrix4x4(Silk.NET.Maths.Matrix4X4 from) -> System.Numerics.Matrix4x4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 @@ -1065,26 +1213,49 @@ static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(System.Numerics.Matrix4x4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.explicit operator Silk.NET.Maths.Matrix4X4(Silk.NET.Maths.Matrix4X4 from) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.explicit operator System.Numerics.Matrix4x4(Silk.NET.Maths.Matrix4X4 from) -> System.Numerics.Matrix4x4 static Silk.NET.Maths.Matrix4X4.Identity.get -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.operator !=(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> bool -static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix3X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix3X4 -static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Matrix4X3 -static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 value1, T value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Matrix4X4.operator +(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.operator !=(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> bool +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix2X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix2X4 +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix3X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix3X4 +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X2 right) -> Silk.NET.Maths.Matrix4X2 +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X3 right) -> Silk.NET.Maths.Matrix4X3 +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 left, T right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Matrix4X4 matrix, Silk.NET.Maths.Vector4D columnVector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X4.operator *(Silk.NET.Maths.Vector4D rowVector, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix4X4.operator *(T left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.operator +(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 +static Silk.NET.Maths.Matrix4X4.operator -(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix4X4 static Silk.NET.Maths.Matrix4X4.operator -(Silk.NET.Maths.Matrix4X4 value) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.operator -(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Matrix4X4 -static Silk.NET.Maths.Matrix4X4.operator ==(Silk.NET.Maths.Matrix4X4 value1, Silk.NET.Maths.Matrix4X4 value2) -> bool -static Silk.NET.Maths.Matrix5X4.Add(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.Lerp(Silk.NET.Maths.Matrix5X4 matrix1, Silk.NET.Maths.Matrix5X4 matrix2, T amount) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.Multiply(Silk.NET.Maths.Matrix5X4 value1, T value2) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix4X4.operator ==(Silk.NET.Maths.Matrix4X4 left, Silk.NET.Maths.Matrix4X4 right) -> bool +static Silk.NET.Maths.Matrix5X4.Add(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix5X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.Lerp(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2, T amount) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.Multiply(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.Multiply(Silk.NET.Maths.Matrix5X4 left, T right) -> Silk.NET.Maths.Matrix5X4 static Silk.NET.Maths.Matrix5X4.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Matrix5X4.Multiply(T left, Silk.NET.Maths.Matrix5X4 right) -> Silk.NET.Maths.Matrix5X4 static Silk.NET.Maths.Matrix5X4.Negate(Silk.NET.Maths.Matrix5X4 value) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.Subtract(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.Subtract(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix5X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.CreateChecked(Silk.NET.Maths.Matrix5X4 other) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.CreateSaturating(Silk.NET.Maths.Matrix5X4 other) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.CreateTruncating(Silk.NET.Maths.Matrix5X4 other) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.explicit operator checked Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 @@ -1098,13 +1269,15 @@ static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 static Silk.NET.Maths.Matrix5X4.explicit operator Silk.NET.Maths.Matrix5X4(Silk.NET.Maths.Matrix5X4 from) -> Silk.NET.Maths.Matrix5X4 static Silk.NET.Maths.Matrix5X4.Identity.get -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.operator !=(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2) -> bool -static Silk.NET.Maths.Matrix5X4.operator *(Silk.NET.Maths.Matrix5X4 value1, T value2) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.operator !=(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix5X4 right) -> bool +static Silk.NET.Maths.Matrix5X4.operator *(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix4X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.operator *(Silk.NET.Maths.Matrix5X4 left, T right) -> Silk.NET.Maths.Matrix5X4 static Silk.NET.Maths.Matrix5X4.operator *(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Matrix5X4.operator +(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.operator *(T left, Silk.NET.Maths.Matrix5X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.operator +(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix5X4 right) -> Silk.NET.Maths.Matrix5X4 +static Silk.NET.Maths.Matrix5X4.operator -(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix5X4 right) -> Silk.NET.Maths.Matrix5X4 static Silk.NET.Maths.Matrix5X4.operator -(Silk.NET.Maths.Matrix5X4 value) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.operator -(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2) -> Silk.NET.Maths.Matrix5X4 -static Silk.NET.Maths.Matrix5X4.operator ==(Silk.NET.Maths.Matrix5X4 value1, Silk.NET.Maths.Matrix5X4 value2) -> bool +static Silk.NET.Maths.Matrix5X4.operator ==(Silk.NET.Maths.Matrix5X4 left, Silk.NET.Maths.Matrix5X4 right) -> bool static Silk.NET.Maths.Plane.CreateFromVertices(Silk.NET.Maths.Vector3D point1, Silk.NET.Maths.Vector3D point2, Silk.NET.Maths.Vector3D point3) -> Silk.NET.Maths.Plane static Silk.NET.Maths.Plane.Dot(Silk.NET.Maths.Plane plane, Silk.NET.Maths.Vector4D value) -> T static Silk.NET.Maths.Plane.DotCoordinate(Silk.NET.Maths.Plane plane, Silk.NET.Maths.Vector3D value) -> T @@ -1136,18 +1309,9 @@ static Silk.NET.Maths.Quaternion.CreateFromRotationMatrix(Silk.NET.Maths.Matr static Silk.NET.Maths.Quaternion.CreateFromYawPitchRoll(T yaw, T pitch, T roll) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.Divide(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.Dot(Silk.NET.Maths.Quaternion quaternion1, Silk.NET.Maths.Quaternion quaternion2) -> T -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.explicit operator Silk.NET.Maths.Quaternion(Silk.NET.Maths.Quaternion from) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.explicit operator System.Numerics.Quaternion(Silk.NET.Maths.Quaternion from) -> System.Numerics.Quaternion static Silk.NET.Maths.Quaternion.Identity.get -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.Inverse(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion @@ -1156,14 +1320,14 @@ static Silk.NET.Maths.Quaternion.Multiply(Silk.NET.Maths.Quaternion value1 static Silk.NET.Maths.Quaternion.Multiply(Silk.NET.Maths.Quaternion value1, T value2) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.Negate(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.Normalize(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.operator !=(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> bool +static Silk.NET.Maths.Quaternion.operator !=(Silk.NET.Maths.Quaternion left, Silk.NET.Maths.Quaternion right) -> bool static Silk.NET.Maths.Quaternion.operator *(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.operator *(Silk.NET.Maths.Quaternion value1, T value2) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.operator +(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.operator -(Silk.NET.Maths.Quaternion value) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.operator -(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.operator /(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion -static Silk.NET.Maths.Quaternion.operator ==(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> bool +static Silk.NET.Maths.Quaternion.operator ==(Silk.NET.Maths.Quaternion left, Silk.NET.Maths.Quaternion right) -> bool static Silk.NET.Maths.Quaternion.Slerp(Silk.NET.Maths.Quaternion quaternion1, Silk.NET.Maths.Quaternion quaternion2, T amount) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Quaternion.Subtract(Silk.NET.Maths.Quaternion value1, Silk.NET.Maths.Quaternion value2) -> Silk.NET.Maths.Quaternion static Silk.NET.Maths.Ray2D.operator !=(Silk.NET.Maths.Ray2D value1, Silk.NET.Maths.Ray2D value2) -> bool @@ -1171,72 +1335,12 @@ static Silk.NET.Maths.Ray2D.operator ==(Silk.NET.Maths.Ray2D value1, Silk. static Silk.NET.Maths.Ray3D.operator !=(Silk.NET.Maths.Ray3D value1, Silk.NET.Maths.Ray3D value2) -> bool static Silk.NET.Maths.Ray3D.operator ==(Silk.NET.Maths.Ray3D value1, Silk.NET.Maths.Ray3D value2) -> bool static Silk.NET.Maths.Rectangle.FromLTRB(T left, T top, T right, T bottom) -> Silk.NET.Maths.Rectangle +static Silk.NET.Maths.Rectangle.GetDistanceToNearestEdge(this Silk.NET.Maths.Rectangle rectangle, Silk.NET.Maths.Vector2D point) -> T static Silk.NET.Maths.Rectangle.operator !=(Silk.NET.Maths.Rectangle value1, Silk.NET.Maths.Rectangle value2) -> bool static Silk.NET.Maths.Rectangle.operator ==(Silk.NET.Maths.Rectangle value1, Silk.NET.Maths.Rectangle value2) -> bool -static Silk.NET.Maths.Scalar.Abs(T x) -> T -static Silk.NET.Maths.Scalar.Acos(T x) -> T -static Silk.NET.Maths.Scalar.Acosh(T x) -> T -static Silk.NET.Maths.Scalar.Add(T left, T right) -> T -static Silk.NET.Maths.Scalar.And(T left, T right) -> T -static Silk.NET.Maths.Scalar.As(TFrom val) -> TTo -static Silk.NET.Maths.Scalar.Asin(T x) -> T -static Silk.NET.Maths.Scalar.Asinh(T x) -> T -static Silk.NET.Maths.Scalar.Atan2(T y, T x) -> T -static Silk.NET.Maths.Scalar.Atan(T x) -> T -static Silk.NET.Maths.Scalar.Atanh(T x) -> T -static Silk.NET.Maths.Scalar.Cbrt(T x) -> T -static Silk.NET.Maths.Scalar.Ceiling(T x) -> T -static Silk.NET.Maths.Scalar.Cos(T x) -> T -static Silk.NET.Maths.Scalar.Cosh(T x) -> T -static Silk.NET.Maths.Scalar.DegreesToRadians(T degrees) -> T -static Silk.NET.Maths.Scalar.Divide(T left, T right) -> T -static Silk.NET.Maths.Scalar.Equal(T left, T right) -> bool -static Silk.NET.Maths.Scalar.Exp(T x) -> T -static Silk.NET.Maths.Scalar.Floor(T x) -> T -static Silk.NET.Maths.Scalar.GreaterThan(T left, T right) -> bool -static Silk.NET.Maths.Scalar.GreaterThanOrEqual(T left, T right) -> bool -static Silk.NET.Maths.Scalar.IEEERemainder(T x, T y) -> T -static Silk.NET.Maths.Scalar.IsFinite(T f) -> bool -static Silk.NET.Maths.Scalar.IsHardwareAccelerated.get -> bool -static Silk.NET.Maths.Scalar.IsInfinity(T f) -> bool -static Silk.NET.Maths.Scalar.IsNaN(T f) -> bool -static Silk.NET.Maths.Scalar.IsNegative(T f) -> bool -static Silk.NET.Maths.Scalar.IsNegativeInfinity(T f) -> bool -static Silk.NET.Maths.Scalar.IsNormal(T f) -> bool -static Silk.NET.Maths.Scalar.IsPositiveInfinity(T f) -> bool -static Silk.NET.Maths.Scalar.IsSubnormal(T f) -> bool -static Silk.NET.Maths.Scalar.LessThan(T left, T right) -> bool -static Silk.NET.Maths.Scalar.LessThanOrEqual(T left, T right) -> bool -static Silk.NET.Maths.Scalar.Log10(T x) -> T -static Silk.NET.Maths.Scalar.Log(T x) -> T -static Silk.NET.Maths.Scalar.Log(T x, T y) -> T -static Silk.NET.Maths.Scalar.Max(T x, T y) -> T -static Silk.NET.Maths.Scalar.Min(T x, T y) -> T -static Silk.NET.Maths.Scalar.Multiply(T left, T right) -> T -static Silk.NET.Maths.Scalar.Negate(T x) -> T -static Silk.NET.Maths.Scalar.Not(T value) -> T -static Silk.NET.Maths.Scalar.NotEqual(T left, T right) -> bool -static Silk.NET.Maths.Scalar.Or(T left, T right) -> T -static Silk.NET.Maths.Scalar.Pow(T x, T y) -> T -static Silk.NET.Maths.Scalar.RadiansToDegrees(T radians) -> T -static Silk.NET.Maths.Scalar.Reciprocal(T x) -> T -static Silk.NET.Maths.Scalar.RotateLeft(T value, int offset) -> T -static Silk.NET.Maths.Scalar.RotateRight(T value, int offset) -> T -static Silk.NET.Maths.Scalar.Round(T x) -> T -static Silk.NET.Maths.Scalar.Round(T x, int digits) -> T -static Silk.NET.Maths.Scalar.Round(T x, int digits, System.MidpointRounding mode) -> T -static Silk.NET.Maths.Scalar.Round(T x, System.MidpointRounding mode) -> T -static Silk.NET.Maths.Scalar.ShiftLeft(T value, int offset) -> T -static Silk.NET.Maths.Scalar.ShiftRight(T value, int offset) -> T -static Silk.NET.Maths.Scalar.Sign(T x) -> int -static Silk.NET.Maths.Scalar.Sin(T x) -> T -static Silk.NET.Maths.Scalar.Sinh(T x) -> T -static Silk.NET.Maths.Scalar.Sqrt(T x) -> T -static Silk.NET.Maths.Scalar.Subtract(T left, T right) -> T -static Silk.NET.Maths.Scalar.Tan(T x) -> T -static Silk.NET.Maths.Scalar.Tanh(T x) -> T -static Silk.NET.Maths.Scalar.Truncate(T x) -> T -static Silk.NET.Maths.Scalar.Xor(T left, T right) -> T +static Silk.NET.Maths.Sphere.Contains(this Silk.NET.Maths.Sphere sphere, Silk.NET.Maths.Sphere other) -> bool +static Silk.NET.Maths.Sphere.Contains(this Silk.NET.Maths.Sphere sphere, Silk.NET.Maths.Vector3D point) -> bool +static Silk.NET.Maths.Sphere.GetInflated(this Silk.NET.Maths.Sphere sphere, Silk.NET.Maths.Vector3D point) -> Silk.NET.Maths.Sphere static Silk.NET.Maths.Sphere.operator !=(Silk.NET.Maths.Sphere value1, Silk.NET.Maths.Sphere value2) -> bool static Silk.NET.Maths.Sphere.operator ==(Silk.NET.Maths.Sphere value1, Silk.NET.Maths.Sphere value2) -> bool static Silk.NET.Maths.SystemNumericsExtensions.ToGeneric(this System.Numerics.Matrix3x2 value) -> Silk.NET.Maths.Matrix3X2 @@ -1253,33 +1357,128 @@ static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Quat static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Vector2D value) -> System.Numerics.Vector2 static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Vector3D value) -> System.Numerics.Vector3 static Silk.NET.Maths.SystemNumericsExtensions.ToSystem(this Silk.NET.Maths.Vector4D value) -> System.Numerics.Vector4 -static Silk.NET.Maths.Vector2D.Abs(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Add(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Clamp(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D min, Silk.NET.Maths.Vector2D max) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Abs(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Acos(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Acosh(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.AcosPi(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Asin(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Asinh(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.AsinPi(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Atan2(Silk.NET.Maths.Vector2D y, Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Atan2Pi(Silk.NET.Maths.Vector2D y, Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Atan(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Atanh(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.AtanPi(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.BitDecrement(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.BitIncrement(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Cbrt(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Ceiling(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Clamp(Silk.NET.Maths.Vector2D value, Silk.NET.Maths.Vector2D min, Silk.NET.Maths.Vector2D max) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Clamp(Silk.NET.Maths.Vector2D value, TSelf min, TSelf max) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.CopySign(Silk.NET.Maths.Vector2D value, Silk.NET.Maths.Vector2D sign) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.CopySign(Silk.NET.Maths.Vector2D value, TSelf sign) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Cos(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Cosh(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.CosPi(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Cross(this Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> T +static Silk.NET.Maths.Vector2D.Deconstruct(this Silk.NET.Maths.Vector2D vector, out T x, out T y) -> void +static Silk.NET.Maths.Vector2D.DegreesToRadians(Silk.NET.Maths.Vector2D degrees) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Distance(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2) -> T static Silk.NET.Maths.Vector2D.DistanceSquared(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2) -> T -static Silk.NET.Maths.Vector2D.Divide(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Divide(Silk.NET.Maths.Vector2D left, T divisor) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Dot(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2) -> T -static Silk.NET.Maths.Vector2D.Lerp(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2, T amount) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Max(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Min(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Multiply(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.DivRem(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> (Silk.NET.Maths.Vector2D Quotient, Silk.NET.Maths.Vector2D Remainder) +static Silk.NET.Maths.Vector2D.Dot(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> T +static Silk.NET.Maths.Vector2D.Exp10(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Exp10M1(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Exp2(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Exp2M1(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Exp(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.ExpM1(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Floor(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.FusedMultiplyAdd(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right, Silk.NET.Maths.Vector2D addend) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.FusedMultiplyAdd(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right, TSelf addend) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.FusedMultiplyAdd(Silk.NET.Maths.Vector2D left, TSelf right, Silk.NET.Maths.Vector2D addend) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.FusedMultiplyAdd(Silk.NET.Maths.Vector2D left, TSelf right, TSelf addend) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.get_Length(Silk.NET.Maths.Vector2D vector) -> T +static Silk.NET.Maths.Vector2D.get_LengthSquared(Silk.NET.Maths.Vector2D vector) -> T +static Silk.NET.Maths.Vector2D.Hypot(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Hypot(Silk.NET.Maths.Vector2D x, TSelf y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Ieee754Remainder(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Ieee754Remainder(Silk.NET.Maths.Vector2D left, TSelf right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.ILogB(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Lerp(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Vector2D value2, TSelf amount) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.LerpClamped(Silk.NET.Maths.Vector2D a, Silk.NET.Maths.Vector2D b, Silk.NET.Maths.Vector2D amount) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.LerpClamped(Silk.NET.Maths.Vector2D a, Silk.NET.Maths.Vector2D b, T amount) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log10(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log10P1(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log2(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log2P1(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D newBase) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Log(Silk.NET.Maths.Vector2D x, TSelf newBase) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.LogP1(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Max(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Max(Silk.NET.Maths.Vector2D x, TSelf y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MaxMagnitude(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MaxMagnitudeNumber(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MaxNumber(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MaxNumber(Silk.NET.Maths.Vector2D x, TSelf y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Min(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Min(Silk.NET.Maths.Vector2D x, TSelf y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MinMagnitude(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MinMagnitudeNumber(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MinNumber(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MinNumber(Silk.NET.Maths.Vector2D x, TSelf y) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Multiply(Silk.NET.Maths.Vector2D left, T right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Multiply(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Multiply(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector2D.Multiply(Silk.NET.Maths.Vector2D value1, Silk.NET.Maths.Matrix2X4 value2) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector2D.Multiply(T left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Negate(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Normalize(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MultiplyAddEstimate(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right, Silk.NET.Maths.Vector2D addend) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MultiplyAddEstimate(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right, TSelf addend) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MultiplyAddEstimate(Silk.NET.Maths.Vector2D left, TSelf right, Silk.NET.Maths.Vector2D addend) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.MultiplyAddEstimate(Silk.NET.Maths.Vector2D left, TSelf right, TSelf addend) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Normalize(this Silk.NET.Maths.Vector2D vector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.PopCount(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Pow(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Pow(Silk.NET.Maths.Vector2D x, TSelf y) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.RadiansToDegrees(Silk.NET.Maths.Vector2D radians) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.ReciprocalEstimate(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.ReciprocalSqrtEstimate(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Reflect(Silk.NET.Maths.Vector2D vector, Silk.NET.Maths.Vector2D normal) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.SquareRoot(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Subtract(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Transform(Silk.NET.Maths.Vector2D position, Silk.NET.Maths.Matrix3X2 matrix) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Transform(Silk.NET.Maths.Vector2D position, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.Transform(Silk.NET.Maths.Vector2D value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.TransformNormal(Silk.NET.Maths.Vector2D normal, Silk.NET.Maths.Matrix3X2 matrix) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.TransformNormal(Silk.NET.Maths.Vector2D normal, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.RootN(Silk.NET.Maths.Vector2D x, int n) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.RootN(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D n) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Round(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Round(Silk.NET.Maths.Vector2D x, int digits) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Round(Silk.NET.Maths.Vector2D x, int digits, System.MidpointRounding mode) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Round(Silk.NET.Maths.Vector2D x, System.MidpointRounding mode) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.ScaleB(Silk.NET.Maths.Vector2D x, int n) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.ScaleB(Silk.NET.Maths.Vector2D x, Silk.NET.Maths.Vector2D n) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Sign(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Sin(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.SinCos(Silk.NET.Maths.Vector2D x) -> (Silk.NET.Maths.Vector2D Sin, Silk.NET.Maths.Vector2D Cos) +static Silk.NET.Maths.Vector2D.SinCosPi(Silk.NET.Maths.Vector2D x) -> (Silk.NET.Maths.Vector2D SinPi, Silk.NET.Maths.Vector2D CosPi) +static Silk.NET.Maths.Vector2D.Sinh(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.SinPi(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Sqrt(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Tan(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Tanh(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.TanPi(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.TrailingZeroCount(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Truncate(Silk.NET.Maths.Vector2D x) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.CreateChecked(Silk.NET.Maths.Vector2D source) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.CreateSaturating(Silk.NET.Maths.Vector2D source) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.CreateTruncating(Silk.NET.Maths.Vector2D source) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(System.Numerics.Vector2 from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator checked System.Numerics.Vector2(Silk.NET.Maths.Vector2D from) -> System.Numerics.Vector2 static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D @@ -1289,50 +1488,158 @@ static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(System.Numerics.Vector2 from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator Silk.NET.Maths.Vector2D(Silk.NET.Maths.Vector2D from) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.explicit operator System.Numerics.Vector2(Silk.NET.Maths.Vector2D from) -> System.Numerics.Vector2 +static Silk.NET.Maths.Vector2D.implicit operator (T X, T Y)(Silk.NET.Maths.Vector2D v) -> (T X, T Y) +static Silk.NET.Maths.Vector2D.implicit operator Silk.NET.Maths.Vector2D((T X, T Y) v) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.One.get -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.operator !=(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> bool static Silk.NET.Maths.Vector2D.operator *(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator *(Silk.NET.Maths.Vector2D left, T right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator *(T left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator *(Silk.NET.Maths.Vector2D vector, T scalar) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator *(T scalar, Silk.NET.Maths.Vector2D vector) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.operator +(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator +(Silk.NET.Maths.Vector2D vector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator +(Silk.NET.Maths.Vector2D vector, T scalar) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.operator -(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator -(Silk.NET.Maths.Vector2D value) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator -(Silk.NET.Maths.Vector2D vector) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator -(Silk.NET.Maths.Vector2D vector, T scalar) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.operator /(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector2D.operator /(Silk.NET.Maths.Vector2D value1, T value2) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.operator /(Silk.NET.Maths.Vector2D vector, T scalar) -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.operator ==(Silk.NET.Maths.Vector2D left, Silk.NET.Maths.Vector2D right) -> bool +static Silk.NET.Maths.Vector2D.Parse(string! s, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Parse(System.ReadOnlySpan utf8Text, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.Parse(System.ReadOnlySpan s, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector2D +static Silk.NET.Maths.Vector2D.TryParse(string? s, System.IFormatProvider? provider, out Silk.NET.Maths.Vector2D result) -> bool +static Silk.NET.Maths.Vector2D.TryParse(System.ReadOnlySpan utf8Text, System.IFormatProvider? provider, out Silk.NET.Maths.Vector2D result) -> bool +static Silk.NET.Maths.Vector2D.TryParse(System.ReadOnlySpan s, System.IFormatProvider? provider, out Silk.NET.Maths.Vector2D result) -> bool static Silk.NET.Maths.Vector2D.UnitX.get -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.UnitY.get -> Silk.NET.Maths.Vector2D static Silk.NET.Maths.Vector2D.Zero.get -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector3D.Abs(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Add(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Clamp(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D min, Silk.NET.Maths.Vector3D max) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Cross(Silk.NET.Maths.Vector3D vector1, Silk.NET.Maths.Vector3D vector2) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Abs(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Acos(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Acosh(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.AcosPi(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Asin(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Asinh(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.AsinPi(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Atan2(Silk.NET.Maths.Vector3D y, Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Atan2Pi(Silk.NET.Maths.Vector3D y, Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Atan(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Atanh(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.AtanPi(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.BitDecrement(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.BitIncrement(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Cbrt(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Ceiling(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Clamp(Silk.NET.Maths.Vector3D value, Silk.NET.Maths.Vector3D min, Silk.NET.Maths.Vector3D max) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Clamp(Silk.NET.Maths.Vector3D value, TSelf min, TSelf max) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.CopySign(Silk.NET.Maths.Vector3D value, Silk.NET.Maths.Vector3D sign) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.CopySign(Silk.NET.Maths.Vector3D value, TSelf sign) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Cos(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Cosh(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.CosPi(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Cross(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Deconstruct(this Silk.NET.Maths.Vector3D vector, out T x, out T y, out T z) -> void +static Silk.NET.Maths.Vector3D.DegreesToRadians(Silk.NET.Maths.Vector3D degrees) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Distance(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2) -> T static Silk.NET.Maths.Vector3D.DistanceSquared(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2) -> T -static Silk.NET.Maths.Vector3D.Divide(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Divide(Silk.NET.Maths.Vector3D left, T divisor) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Dot(Silk.NET.Maths.Vector3D vector1, Silk.NET.Maths.Vector3D vector2) -> T -static Silk.NET.Maths.Vector3D.Lerp(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2, T amount) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Max(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Min(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Multiply(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.DivRem(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> (Silk.NET.Maths.Vector3D Quotient, Silk.NET.Maths.Vector3D Remainder) +static Silk.NET.Maths.Vector3D.Dot(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> T +static Silk.NET.Maths.Vector3D.Exp10(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Exp10M1(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Exp2(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Exp2M1(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Exp(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.ExpM1(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Floor(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.FusedMultiplyAdd(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right, Silk.NET.Maths.Vector3D addend) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.FusedMultiplyAdd(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right, TSelf addend) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.FusedMultiplyAdd(Silk.NET.Maths.Vector3D left, TSelf right, Silk.NET.Maths.Vector3D addend) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.FusedMultiplyAdd(Silk.NET.Maths.Vector3D left, TSelf right, TSelf addend) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.get_Length(Silk.NET.Maths.Vector3D vector) -> T +static Silk.NET.Maths.Vector3D.get_LengthSquared(Silk.NET.Maths.Vector3D vector) -> T +static Silk.NET.Maths.Vector3D.Hypot(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Hypot(Silk.NET.Maths.Vector3D x, TSelf y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Ieee754Remainder(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Ieee754Remainder(Silk.NET.Maths.Vector3D left, TSelf right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.ILogB(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Lerp(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Vector3D value2, TSelf amount) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.LerpClamped(Silk.NET.Maths.Vector3D a, Silk.NET.Maths.Vector3D b, Silk.NET.Maths.Vector3D amount) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.LerpClamped(Silk.NET.Maths.Vector3D a, Silk.NET.Maths.Vector3D b, T amount) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log10(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log10P1(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log2(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log2P1(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D newBase) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Log(Silk.NET.Maths.Vector3D x, TSelf newBase) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.LogP1(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Max(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Max(Silk.NET.Maths.Vector3D x, TSelf y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MaxMagnitude(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MaxMagnitudeNumber(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MaxNumber(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MaxNumber(Silk.NET.Maths.Vector3D x, TSelf y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Min(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Min(Silk.NET.Maths.Vector3D x, TSelf y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MinMagnitude(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MinMagnitudeNumber(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MinNumber(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MinNumber(Silk.NET.Maths.Vector3D x, TSelf y) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Multiply(Silk.NET.Maths.Vector3D left, T right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Multiply(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector3D.Multiply(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Multiply(Silk.NET.Maths.Vector3D value1, Silk.NET.Maths.Matrix3X4 value2) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector3D.Multiply(T left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Negate(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Normalize(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MultiplyAddEstimate(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right, Silk.NET.Maths.Vector3D addend) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MultiplyAddEstimate(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right, TSelf addend) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MultiplyAddEstimate(Silk.NET.Maths.Vector3D left, TSelf right, Silk.NET.Maths.Vector3D addend) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.MultiplyAddEstimate(Silk.NET.Maths.Vector3D left, TSelf right, TSelf addend) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Normalize(this Silk.NET.Maths.Vector3D vector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.PopCount(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Pow(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Pow(Silk.NET.Maths.Vector3D x, TSelf y) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.RadiansToDegrees(Silk.NET.Maths.Vector3D radians) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.ReciprocalEstimate(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.ReciprocalSqrtEstimate(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Reflect(Silk.NET.Maths.Vector3D vector, Silk.NET.Maths.Vector3D normal) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.SquareRoot(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Subtract(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Transform(Silk.NET.Maths.Vector3D position, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.Transform(Silk.NET.Maths.Vector3D value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.TransformNormal(Silk.NET.Maths.Vector3D normal, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.RootN(Silk.NET.Maths.Vector3D x, int n) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.RootN(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D n) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Round(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Round(Silk.NET.Maths.Vector3D x, int digits) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Round(Silk.NET.Maths.Vector3D x, int digits, System.MidpointRounding mode) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Round(Silk.NET.Maths.Vector3D x, System.MidpointRounding mode) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.ScaleB(Silk.NET.Maths.Vector3D x, int n) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.ScaleB(Silk.NET.Maths.Vector3D x, Silk.NET.Maths.Vector3D n) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Sign(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Sin(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.SinCos(Silk.NET.Maths.Vector3D x) -> (Silk.NET.Maths.Vector3D Sin, Silk.NET.Maths.Vector3D Cos) +static Silk.NET.Maths.Vector3D.SinCosPi(Silk.NET.Maths.Vector3D x) -> (Silk.NET.Maths.Vector3D SinPi, Silk.NET.Maths.Vector3D CosPi) +static Silk.NET.Maths.Vector3D.Sinh(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.SinPi(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Sqrt(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Tan(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Tanh(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.TanPi(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.TrailingZeroCount(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Truncate(Silk.NET.Maths.Vector3D x) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.CreateChecked(Silk.NET.Maths.Vector3D source) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.CreateSaturating(Silk.NET.Maths.Vector3D source) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.CreateTruncating(Silk.NET.Maths.Vector3D source) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(System.Numerics.Vector3 from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator checked System.Numerics.Vector3(Silk.NET.Maths.Vector3D from) -> System.Numerics.Vector3 static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D @@ -1342,52 +1649,158 @@ static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(System.Numerics.Vector3 from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator Silk.NET.Maths.Vector3D(Silk.NET.Maths.Vector3D from) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.explicit operator System.Numerics.Vector3(Silk.NET.Maths.Vector3D from) -> System.Numerics.Vector3 +static Silk.NET.Maths.Vector3D.implicit operator (T X, T Y, T Z)(Silk.NET.Maths.Vector3D v) -> (T X, T Y, T Z) +static Silk.NET.Maths.Vector3D.implicit operator Silk.NET.Maths.Vector3D((T X, T Y, T Z) v) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.One.get -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.operator !=(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> bool static Silk.NET.Maths.Vector3D.operator *(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator *(Silk.NET.Maths.Vector3D left, T right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator *(T left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator *(Silk.NET.Maths.Vector3D vector, T scalar) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator *(T scalar, Silk.NET.Maths.Vector3D vector) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.operator +(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator +(Silk.NET.Maths.Vector3D vector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator +(Silk.NET.Maths.Vector3D vector, T scalar) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.operator -(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator -(Silk.NET.Maths.Vector3D value) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator -(Silk.NET.Maths.Vector3D vector) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator -(Silk.NET.Maths.Vector3D vector, T scalar) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.operator /(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector3D.operator /(Silk.NET.Maths.Vector3D value1, T value2) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.operator /(Silk.NET.Maths.Vector3D vector, T scalar) -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.operator ==(Silk.NET.Maths.Vector3D left, Silk.NET.Maths.Vector3D right) -> bool +static Silk.NET.Maths.Vector3D.Parse(string! s, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Parse(System.ReadOnlySpan utf8Text, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.Parse(System.ReadOnlySpan s, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector3D +static Silk.NET.Maths.Vector3D.TryParse(string? s, System.IFormatProvider? provider, out Silk.NET.Maths.Vector3D result) -> bool +static Silk.NET.Maths.Vector3D.TryParse(System.ReadOnlySpan utf8Text, System.IFormatProvider? provider, out Silk.NET.Maths.Vector3D result) -> bool +static Silk.NET.Maths.Vector3D.TryParse(System.ReadOnlySpan s, System.IFormatProvider? provider, out Silk.NET.Maths.Vector3D result) -> bool static Silk.NET.Maths.Vector3D.UnitX.get -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.UnitY.get -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.UnitZ.get -> Silk.NET.Maths.Vector3D static Silk.NET.Maths.Vector3D.Zero.get -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector4D.Abs(Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Add(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Clamp(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D min, Silk.NET.Maths.Vector4D max) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Abs(Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Acos(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Acosh(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.AcosPi(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Asin(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Asinh(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.AsinPi(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Atan2(Silk.NET.Maths.Vector4D y, Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Atan2Pi(Silk.NET.Maths.Vector4D y, Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Atan(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Atanh(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.AtanPi(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.BitDecrement(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.BitIncrement(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Cbrt(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Ceiling(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Clamp(Silk.NET.Maths.Vector4D value, Silk.NET.Maths.Vector4D min, Silk.NET.Maths.Vector4D max) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Clamp(Silk.NET.Maths.Vector4D value, TSelf min, TSelf max) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.CopySign(Silk.NET.Maths.Vector4D value, Silk.NET.Maths.Vector4D sign) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.CopySign(Silk.NET.Maths.Vector4D value, TSelf sign) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Cos(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Cosh(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.CosPi(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Deconstruct(this Silk.NET.Maths.Vector4D vector, out T x, out T y, out T z, out T w) -> void +static Silk.NET.Maths.Vector4D.DegreesToRadians(Silk.NET.Maths.Vector4D degrees) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Distance(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2) -> T static Silk.NET.Maths.Vector4D.DistanceSquared(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2) -> T -static Silk.NET.Maths.Vector4D.Divide(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Divide(Silk.NET.Maths.Vector4D left, T divisor) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Dot(Silk.NET.Maths.Vector4D vector1, Silk.NET.Maths.Vector4D vector2) -> T -static Silk.NET.Maths.Vector4D.Lerp(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2, T amount) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Max(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Min(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Multiply(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.DivRem(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> (Silk.NET.Maths.Vector4D Quotient, Silk.NET.Maths.Vector4D Remainder) +static Silk.NET.Maths.Vector4D.Dot(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> T +static Silk.NET.Maths.Vector4D.Exp10(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Exp10M1(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Exp2(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Exp2M1(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Exp(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.ExpM1(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Floor(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.FusedMultiplyAdd(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right, Silk.NET.Maths.Vector4D addend) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.FusedMultiplyAdd(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right, TSelf addend) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.FusedMultiplyAdd(Silk.NET.Maths.Vector4D left, TSelf right, Silk.NET.Maths.Vector4D addend) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.FusedMultiplyAdd(Silk.NET.Maths.Vector4D left, TSelf right, TSelf addend) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.get_Length(Silk.NET.Maths.Vector4D vector) -> T +static Silk.NET.Maths.Vector4D.get_LengthSquared(Silk.NET.Maths.Vector4D vector) -> T +static Silk.NET.Maths.Vector4D.Hypot(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Hypot(Silk.NET.Maths.Vector4D x, TSelf y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Ieee754Remainder(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Ieee754Remainder(Silk.NET.Maths.Vector4D left, TSelf right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.ILogB(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Lerp(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Vector4D value2, TSelf amount) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.LerpClamped(Silk.NET.Maths.Vector4D a, Silk.NET.Maths.Vector4D b, Silk.NET.Maths.Vector4D amount) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.LerpClamped(Silk.NET.Maths.Vector4D a, Silk.NET.Maths.Vector4D b, T amount) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log10(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log10P1(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log2(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log2P1(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D newBase) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Log(Silk.NET.Maths.Vector4D x, TSelf newBase) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.LogP1(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Max(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Max(Silk.NET.Maths.Vector4D x, TSelf y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MaxMagnitude(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MaxMagnitudeNumber(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MaxNumber(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MaxNumber(Silk.NET.Maths.Vector4D x, TSelf y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Min(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Min(Silk.NET.Maths.Vector4D x, TSelf y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MinMagnitude(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MinMagnitudeNumber(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MinNumber(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MinNumber(Silk.NET.Maths.Vector4D x, TSelf y) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Multiply(Silk.NET.Maths.Vector4D left, T right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X2 value2) -> Silk.NET.Maths.Vector2D -static Silk.NET.Maths.Vector4D.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X3 value2) -> Silk.NET.Maths.Vector3D -static Silk.NET.Maths.Vector4D.Multiply(Silk.NET.Maths.Vector4D value1, Silk.NET.Maths.Matrix4X4 value2) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.Multiply(T left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Negate(Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Normalize(Silk.NET.Maths.Vector4D vector) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.SquareRoot(Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Subtract(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Transform(Silk.NET.Maths.Vector2D position, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Transform(Silk.NET.Maths.Vector2D value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Transform(Silk.NET.Maths.Vector3D position, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Transform(Silk.NET.Maths.Vector3D value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Transform(Silk.NET.Maths.Vector4D value, Silk.NET.Maths.Quaternion rotation) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.Transform(Silk.NET.Maths.Vector4D vector, Silk.NET.Maths.Matrix4X4 matrix) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MultiplyAddEstimate(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right, Silk.NET.Maths.Vector4D addend) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MultiplyAddEstimate(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right, TSelf addend) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MultiplyAddEstimate(Silk.NET.Maths.Vector4D left, TSelf right, Silk.NET.Maths.Vector4D addend) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.MultiplyAddEstimate(Silk.NET.Maths.Vector4D left, TSelf right, TSelf addend) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Normalize(this Silk.NET.Maths.Vector4D vector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.PopCount(Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Pow(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Pow(Silk.NET.Maths.Vector4D x, TSelf y) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.RadiansToDegrees(Silk.NET.Maths.Vector4D radians) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.ReciprocalEstimate(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.ReciprocalSqrtEstimate(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Reflect(Silk.NET.Maths.Vector4D vector, Silk.NET.Maths.Vector4D normal) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.RootN(Silk.NET.Maths.Vector4D x, int n) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.RootN(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D n) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Round(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Round(Silk.NET.Maths.Vector4D x, int digits) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Round(Silk.NET.Maths.Vector4D x, int digits, System.MidpointRounding mode) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Round(Silk.NET.Maths.Vector4D x, System.MidpointRounding mode) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.ScaleB(Silk.NET.Maths.Vector4D x, int n) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.ScaleB(Silk.NET.Maths.Vector4D x, Silk.NET.Maths.Vector4D n) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Sign(Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Sin(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.SinCos(Silk.NET.Maths.Vector4D x) -> (Silk.NET.Maths.Vector4D Sin, Silk.NET.Maths.Vector4D Cos) +static Silk.NET.Maths.Vector4D.SinCosPi(Silk.NET.Maths.Vector4D x) -> (Silk.NET.Maths.Vector4D SinPi, Silk.NET.Maths.Vector4D CosPi) +static Silk.NET.Maths.Vector4D.Sinh(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.SinPi(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Sqrt(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Tan(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Tanh(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.TanPi(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.TrailingZeroCount(Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Truncate(Silk.NET.Maths.Vector4D x) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.CreateChecked(Silk.NET.Maths.Vector4D source) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.CreateSaturating(Silk.NET.Maths.Vector4D source) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.CreateTruncating(Silk.NET.Maths.Vector4D source) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(System.Numerics.Vector4 from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator checked System.Numerics.Vector4(Silk.NET.Maths.Vector4D from) -> System.Numerics.Vector4 static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D @@ -1397,21 +1810,33 @@ static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(System.Numerics.Vector4 from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator Silk.NET.Maths.Vector4D(Silk.NET.Maths.Vector4D from) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.explicit operator System.Numerics.Vector4(Silk.NET.Maths.Vector4D from) -> System.Numerics.Vector4 +static Silk.NET.Maths.Vector4D.implicit operator (T X, T Y, T Z, T W)(Silk.NET.Maths.Vector4D v) -> (T X, T Y, T Z, T W) +static Silk.NET.Maths.Vector4D.implicit operator Silk.NET.Maths.Vector4D((T X, T Y, T Z, T W) v) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.One.get -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.operator !=(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> bool static Silk.NET.Maths.Vector4D.operator *(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator *(Silk.NET.Maths.Vector4D left, T right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator *(T left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator *(Silk.NET.Maths.Vector4D vector, T scalar) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator *(T scalar, Silk.NET.Maths.Vector4D vector) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.operator +(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator +(Silk.NET.Maths.Vector4D vector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator +(Silk.NET.Maths.Vector4D vector, T scalar) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.operator -(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator -(Silk.NET.Maths.Vector4D value) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator -(Silk.NET.Maths.Vector4D vector) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator -(Silk.NET.Maths.Vector4D vector, T scalar) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.operator /(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> Silk.NET.Maths.Vector4D -static Silk.NET.Maths.Vector4D.operator /(Silk.NET.Maths.Vector4D value1, T value2) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.operator /(Silk.NET.Maths.Vector4D vector, T scalar) -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.operator ==(Silk.NET.Maths.Vector4D left, Silk.NET.Maths.Vector4D right) -> bool +static Silk.NET.Maths.Vector4D.Parse(string! s, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Parse(System.ReadOnlySpan utf8Text, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.Parse(System.ReadOnlySpan s, System.IFormatProvider? provider) -> Silk.NET.Maths.Vector4D +static Silk.NET.Maths.Vector4D.TryParse(string? s, System.IFormatProvider? provider, out Silk.NET.Maths.Vector4D result) -> bool +static Silk.NET.Maths.Vector4D.TryParse(System.ReadOnlySpan utf8Text, System.IFormatProvider? provider, out Silk.NET.Maths.Vector4D result) -> bool +static Silk.NET.Maths.Vector4D.TryParse(System.ReadOnlySpan s, System.IFormatProvider? provider, out Silk.NET.Maths.Vector4D result) -> bool static Silk.NET.Maths.Vector4D.UnitW.get -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.UnitX.get -> Silk.NET.Maths.Vector4D static Silk.NET.Maths.Vector4D.UnitY.get -> Silk.NET.Maths.Vector4D