From b817d3102cb18f1422f644c1c6c7e3b9cf3fbb2d Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sun, 19 Nov 2023 15:51:59 +1000 Subject: [PATCH 01/25] start of additional math api proposal From 406240727147c4059bbeb339f6954b39f2feb0f0 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sun, 19 Nov 2023 16:20:39 +1000 Subject: [PATCH 02/25] Create proposal with summary. --- .../Proposal - 3.0 Additional math types.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 documentation/proposals/Proposal - 3.0 Additional math types.md diff --git a/documentation/proposals/Proposal - 3.0 Additional math types.md b/documentation/proposals/Proposal - 3.0 Additional math types.md new file mode 100644 index 0000000000..9cc7645082 --- /dev/null +++ b/documentation/proposals/Proposal - 3.0 Additional math types.md @@ -0,0 +1,19 @@ +# Summary +Proposal API for additional math types to bring it up to feature parity with other popular math libraries i.e. `SlimDX`, `SharpDX`, or `Stride3D`. Leveraging modern .NET features such as `INumber` and vectorization. + +# Contributors +- Daniel Keenan (dfkeenan) + +# Current Status +- [x] Proposed +- [ ] Discussed with API Review Board (ARB) +- [ ] Approved +- [ ] Implemented + +# Design Decisions + + +# Proposed API + +```cs +``` From 30c708cc2632d731c2c403bcf67b2982f527c0e6 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Thu, 23 Nov 2023 15:33:26 +1000 Subject: [PATCH 03/25] Reference decisions from 3.0 math proposal. --- .../proposals/Proposal - 3.0 Additional math types.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types.md b/documentation/proposals/Proposal - 3.0 Additional math types.md index 9cc7645082..299414007c 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types.md @@ -11,7 +11,16 @@ Proposal API for additional math types to bring it up to feature parity with oth - [ ] Implemented # Design Decisions +- This proposal should compliment/augment the proposed 3.0 implementation of `Silk.Net.Maths`, matching `System.Numerics` where possible, with concessions for design oversights in that api. +- This proposal assumes no knowledge of the 2.x Math library. +- Text herein marked **INFORMATIVE** does not form a normative part of this proposal, and is for background only. +- Within this proposal, the key words **must**, **required**, **shall**, **should**, **recommended**, **may**, **could**, and **optional** are to be interpreted as described in [RFC 2119 - Key words for use in RFCs to Indicate Requirement Levels](https://www.ietf.org/rfc/rfc2119.txt). The additional key word **optionally** is an alternate form of **optional**, for use where grammatically appropriate. These key words are highlighted in the proposal for clarity. +# **INFORMATIVE** Integer and Floating Point Types +While investigating the use of generic math it was decided to provide both an integer and floating point variant for each vector type and every type built from them. See [Generic Math](Proposal%20-%20Generic%20Math.md) proposal for more details. + +# I types versus F Types +Where it is appropriate for a type in this proposal to have both integer and floating point variants they will have a name that ends in I or F, defining whether it is an integer type or floating point type. Integer types **must** use a generic type argument `T` with the constraint of `IBinaryInteger`. On the other hand, floating point types **must** use a generic type argument `T` with the constraint of `IFloatingPointIeee754`. # Proposed API From f68e2bc493c9aa0d93e0b784b0ec281dd70f26bd Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Thu, 23 Nov 2023 16:48:00 +1000 Subject: [PATCH 04/25] Add headings for types under consideration. --- .../Proposal - 3.0 Additional math types.md | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types.md b/documentation/proposals/Proposal - 3.0 Additional math types.md index 299414007c..7c103aaedc 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types.md @@ -24,5 +24,30 @@ Where it is appropriate for a type in this proposal to have both integer and flo # Proposed API -```cs -``` +## Angle + +## "Collision" types. + +DirectX and other APIs include "collision shapes" that can be used for such things as culling. `Silk.Net.Maths` already includes some types i.e. `BoxF`, `PlaneF`. These are additional. + +### Frustum + +### OrientedBox + +### CollisionHelper + +### PlaneIntersectionType + +### ContainmentType + +## Color types. + +### Color + +### ColorBGRA + +### ColorHSV + +### Color3 + +### Color4 From b2734fe94046ac0b6e8b2bde01b421515412ec3b Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 25 Nov 2023 19:00:38 +1000 Subject: [PATCH 05/25] Add rough cut of Angle struct --- .../Proposal - 3.0 Additional math types.md | 201 ++++++++++++++++++ 1 file changed, 201 insertions(+) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types.md b/documentation/proposals/Proposal - 3.0 Additional math types.md index 7c103aaedc..91ed4922e5 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types.md @@ -26,6 +26,207 @@ Where it is appropriate for a type in this proposal to have both integer and flo ## Angle +Interface implementations not included for brevity. + +```csharp +public readonly struct Angle + : IEquatable> + , IEqualityOperators,Angle, bool> + , IComparable> + , IComparisonOperators,Angle, bool> + , IAdditionOperators,Angle,Angle> + , IDivisionOperators, T, Angle> + , IDivisionOperators, Angle> + , IMultiplyOperators, T, Angle> + , IMultiplyOperators, Angle> + , IModulusOperators, Angle, Angle> + , ISubtractionOperators,Angle,Angle> + where T : IFloatingPointIeee754 +{ + + public readonly T Radians; + + public Angle(T radians) { } + + + public T Degrees { get; } + public T Gradians { get; } + public T Milliradians { get; } + public T Minutes { get; } + public T Seconds { get; } + + + /// + /// Gets a System.Boolean that determines whether this Angle + /// is a right angle (i.e. 90° or π/2). + /// + public bool IsRight { get; } + + /// + /// Gets a System.Boolean that determines whether this Angle + /// is a straight angle (i.e. 180° or π). + /// + public bool IsStraight { get; } + + /// + /// Gets a System.Boolean that determines whether this Angle + /// is a full rotation angle (i.e. 360° or 2π). + /// + public bool IsFullRotation { get; } + + /// + /// Gets a System.Boolean that determines whether this Angle + /// is an oblique angle (i.e. is not 90° or a multiple of 90°). + /// + public bool IsOblique { get; } + + /// + /// Gets a System.Boolean that determines whether this Angle + /// is an acute angle (i.e. less than 90° but greater than 0°). + /// + public bool IsAcute { get; } + + /// + /// Gets a System.Boolean that determines whether this Angle + /// is an obtuse angle (i.e. greater than 90° but less than 180°). + /// + public bool IsObtuse { get; } + + /// + /// Gets a System.Boolean that determines whether this Angle + /// is a reflex angle (i.e. greater than 180° but less than 360°). + /// + public bool IsReflex { get; } + + /// + /// Gets a Angle instance that complements this angle (i.e. the two angles add to 90°). + /// + public Angle Complement { get; } + + /// + /// Gets a Angle instance that supplements this angle (i.e. the two angles add to 180°). + /// + public Angle Supplement { get; } + + /// + /// Wraps this Angle to be in the range [π, -π]. + /// + public Angle Wrap() => default; + + /// + /// Wraps this Angle to be in the range [0, 2π). + /// + public Angle WrapPositive() => default; + + + /// Computes the arc-cosine of a value. + public T Acos() => default; + + /// Computes the arc-cosine of a value and divides the result by pi. + public T AcosPi() => default; + + /// Computes the arc-sine of a value. + public T Asin() => default; + + /// Computes the arc-sine of a value and divides the result by pi. + public T AsinPi() => default; + + /// Computes the arc-tangent of a value. + public T Atan() => default; + + /// Computes the arc-tangent of a value and divides the result by pi. + public T AtanPi() => default; + + /// Computes the cosine of a value. + public T Cos() => default; + + /// Computes the cosine of a value that has been multipled by pi. + public T CosPi() => default; + + /// Computes the sine of a value. + /// The value, in radians, whose sine is to be computed. + /// The sine of . + /// This computes sin(x). + public T Sin() => default; + + /// Computes the sine and cosine of a value. + public (T Sin, T Cos) SinCos() => default; + + /// Computes the sine and cosine of a value that has been multiplied by pi. + public (T SinPi, T CosPi) SinCosPi() => default; + + /// Computes the sine of a value that has been multiplied by pi. + public T SinPi() => default; + + /// Computes the tangent of a value. + public T Tan() => default; + + /// Computes the tangent of a value that has been multipled by pi. + public T TanPi() => default; + + /// Implicit cast in radians + public static implicit operator T(Angle angle) => default; +} + +public static class Angle +{ + public static Angle FromRadians(T radians) + where T : IFloatingPointIeee754 + => default; + public static Angle FromDegrees(T degrees) + where T : IFloatingPointIeee754 + => default; + public static Angle FromGradians(T gradians) + where T : IFloatingPointIeee754 + => default; + public static Angle FromMilliradians(T milliradians) + where T : IFloatingPointIeee754 + => default; + public static Angle FromMinutes(T minutes) + where T : IFloatingPointIeee754 + => default; + public static Angle FromSeconds(T seconds) + where T : IFloatingPointIeee754 + => default; + + public static Angle Min(Angle left, Angle right) + where T : IFloatingPointIeee754 + => default; + + public static Angle Max(Angle left, Angle right) + where T : IFloatingPointIeee754 + => default; + + public static Angle Clamp(Angle value, Angle min, Angle max) + where T : IFloatingPointIeee754 + => default; + + public static Angle Atan2(T y, T x) + where T : IFloatingPointIeee754 + => default; + + public static Angle ArcTan(T y, T x) + where T : IFloatingPointIeee754 + => default; + + public static Angle ArcSin(T sin) + where T : IFloatingPointIeee754 + => default; + + public static Angle ArcCos(T cos) + where T : IFloatingPointIeee754 + => default; + + public static Angle Between(Vector2F left, Vector2F right) + where T : IFloatingPointIeee754 + => default; + + public static Angle Between(Vector3F left, Vector3F right) + where T : IFloatingPointIeee754 + => default; +} +``` + ## "Collision" types. DirectX and other APIs include "collision shapes" that can be used for such things as culling. `Silk.Net.Maths` already includes some types i.e. `BoxF`, `PlaneF`. These are additional. From c030275fa7dcb6042ff5f25bc6df2cfe37eb5a6f Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 25 Nov 2023 19:18:48 +1000 Subject: [PATCH 06/25] add parsable interfaces to Angle --- documentation/proposals/Proposal - 3.0 Additional math types.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types.md b/documentation/proposals/Proposal - 3.0 Additional math types.md index 91ed4922e5..0490aeb1f8 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types.md @@ -41,6 +41,8 @@ public readonly struct Angle , IMultiplyOperators, Angle> , IModulusOperators, Angle, Angle> , ISubtractionOperators,Angle,Angle> + , IParsable> + , ISpanParsable> where T : IFloatingPointIeee754 { From d4c84a42d2debf078dbd9c6475da08a4ff984884 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 25 Nov 2023 19:24:57 +1000 Subject: [PATCH 07/25] Add more angle methods. --- .../Proposal - 3.0 Additional math types.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types.md b/documentation/proposals/Proposal - 3.0 Additional math types.md index 0490aeb1f8..6997b7261e 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types.md @@ -226,6 +226,22 @@ public static class Angle public static Angle Between(Vector3F left, Vector3F right) where T : IFloatingPointIeee754 => default; + + public static Angle ZeroAngle() + where T : IFloatingPointIeee754 + => default; + + public static Angle RightAngle() + where T : IFloatingPointIeee754 + => default; + + public static Angle StraightAngle() + where T : IFloatingPointIeee754 + => default; + + public static Angle FullRotationAngle() + where T : IFloatingPointIeee754 + => default; } ``` From 4b4798a5c72639d53b0ebf920f899269b3af587a Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 25 Nov 2023 19:55:06 +1000 Subject: [PATCH 08/25] add more angle helper methods. --- .../proposals/Proposal - 3.0 Additional math types.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types.md b/documentation/proposals/Proposal - 3.0 Additional math types.md index 6997b7261e..325810403e 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types.md @@ -203,6 +203,14 @@ public static class Angle where T : IFloatingPointIeee754 => default; + public static Angle Lerp(Angle start, Angle end, T amount) + where T : IFloatingPointIeee754 + => default; + + public static Angle SmoothStep(Angle start, Angle end, T amount) + where T : IFloatingPointIeee754 + => default; + public static Angle Atan2(T y, T x) where T : IFloatingPointIeee754 => default; From 9f65f5bb9c781626056871de5ab9abfac0d10464 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sun, 26 Nov 2023 11:35:28 +1000 Subject: [PATCH 09/25] Split proposal into 3 --- ...al - 3.0 Additional math types - Angle.md} | 41 +++++-------------- ...- 3.0 Additional math types - Collision.md | 41 +++++++++++++++++++ ...sal - 3.0 Additional math types - Color.md | 37 +++++++++++++++++ 3 files changed, 89 insertions(+), 30 deletions(-) rename documentation/proposals/{Proposal - 3.0 Additional math types.md => Proposal - 3.0 Additional math types - Angle.md} (95%) create mode 100644 documentation/proposals/Proposal - 3.0 Additional math types - Collision.md create mode 100644 documentation/proposals/Proposal - 3.0 Additional math types - Color.md diff --git a/documentation/proposals/Proposal - 3.0 Additional math types.md b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md similarity index 95% rename from documentation/proposals/Proposal - 3.0 Additional math types.md rename to documentation/proposals/Proposal - 3.0 Additional math types - Angle.md index 325810403e..934649a16d 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md @@ -46,13 +46,14 @@ public readonly struct Angle where T : IFloatingPointIeee754 { - public readonly T Radians; + public readonly T TotalRadians; - public Angle(T radians) { } + public Angle(T totalRadians) { } public T Degrees { get; } - public T Gradians { get; } + public T TotalDegrees { get; } + public T TotalRdians { get; } public T Milliradians { get; } public T Minutes { get; } public T Seconds { get; } @@ -170,6 +171,12 @@ public readonly struct Angle public static implicit operator T(Angle angle) => default; } +``` + + + +```csharp + public static class Angle { public static Angle FromRadians(T radians) @@ -251,30 +258,4 @@ public static class Angle where T : IFloatingPointIeee754 => default; } -``` - -## "Collision" types. - -DirectX and other APIs include "collision shapes" that can be used for such things as culling. `Silk.Net.Maths` already includes some types i.e. `BoxF`, `PlaneF`. These are additional. - -### Frustum - -### OrientedBox - -### CollisionHelper - -### PlaneIntersectionType - -### ContainmentType - -## Color types. - -### Color - -### ColorBGRA - -### ColorHSV - -### Color3 - -### Color4 +``` \ No newline at end of file diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md new file mode 100644 index 0000000000..fb1a638bb5 --- /dev/null +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md @@ -0,0 +1,41 @@ +# Summary +Proposal API for additional math types to bring it up to feature parity with other popular math libraries i.e. `SlimDX`, `SharpDX`, or `Stride3D`. Leveraging modern .NET features such as `INumber` and vectorization. + +This proposal is regarding "collision shapes" for containment and intersection tests. + +# Contributors +- Daniel Keenan (dfkeenan) + +# Current Status +- [x] Proposed +- [ ] Discussed with API Review Board (ARB) +- [ ] Approved +- [ ] Implemented + +# Design Decisions +- This proposal should compliment/augment the proposed 3.0 implementation of `Silk.Net.Maths`, matching `System.Numerics` where possible, with concessions for design oversights in that api. +- This proposal assumes no knowledge of the 2.x Math library. +- Text herein marked **INFORMATIVE** does not form a normative part of this proposal, and is for background only. +- Within this proposal, the key words **must**, **required**, **shall**, **should**, **recommended**, **may**, **could**, and **optional** are to be interpreted as described in [RFC 2119 - Key words for use in RFCs to Indicate Requirement Levels](https://www.ietf.org/rfc/rfc2119.txt). The additional key word **optionally** is an alternate form of **optional**, for use where grammatically appropriate. These key words are highlighted in the proposal for clarity. + +# **INFORMATIVE** Integer and Floating Point Types +While investigating the use of generic math it was decided to provide both an integer and floating point variant for each vector type and every type built from them. See [Generic Math](Proposal%20-%20Generic%20Math.md) proposal for more details. + +# I types versus F Types +Where it is appropriate for a type in this proposal to have both integer and floating point variants they will have a name that ends in I or F, defining whether it is an integer type or floating point type. Integer types **must** use a generic type argument `T` with the constraint of `IBinaryInteger`. On the other hand, floating point types **must** use a generic type argument `T` with the constraint of `IFloatingPointIeee754`. + +# Proposed API + +DirectX and other APIs include "collision shapes" that can be used for such things as culling. `Silk.Net.Maths` already includes some types i.e. `BoxF`, `PlaneF`. These are additional. + +### Frustum + +### OrientedBox + +### CollisionHelper + +### PlaneIntersectionType + +### ContainmentType + + diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Color.md b/documentation/proposals/Proposal - 3.0 Additional math types - Color.md new file mode 100644 index 0000000000..79853831b0 --- /dev/null +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Color.md @@ -0,0 +1,37 @@ +# Summary +Proposal API for additional math types to bring it up to feature parity with other popular math libraries i.e. `SlimDX`, `SharpDX`, or `Stride3D`. Leveraging modern .NET features such as `INumber` and vectorization. + +This proposal is regarding color type structs. + +# Contributors +- Daniel Keenan (dfkeenan) + +# Current Status +- [x] Proposed +- [ ] Discussed with API Review Board (ARB) +- [ ] Approved +- [ ] Implemented + +# Design Decisions +- This proposal should compliment/augment the proposed 3.0 implementation of `Silk.Net.Maths`, matching `System.Numerics` where possible, with concessions for design oversights in that api. +- This proposal assumes no knowledge of the 2.x Math library. +- Text herein marked **INFORMATIVE** does not form a normative part of this proposal, and is for background only. +- Within this proposal, the key words **must**, **required**, **shall**, **should**, **recommended**, **may**, **could**, and **optional** are to be interpreted as described in [RFC 2119 - Key words for use in RFCs to Indicate Requirement Levels](https://www.ietf.org/rfc/rfc2119.txt). The additional key word **optionally** is an alternate form of **optional**, for use where grammatically appropriate. These key words are highlighted in the proposal for clarity. + +# **INFORMATIVE** Integer and Floating Point Types +While investigating the use of generic math it was decided to provide both an integer and floating point variant for each vector type and every type built from them. See [Generic Math](Proposal%20-%20Generic%20Math.md) proposal for more details. + +# I types versus F Types +Where it is appropriate for a type in this proposal to have both integer and floating point variants they will have a name that ends in I or F, defining whether it is an integer type or floating point type. Integer types **must** use a generic type argument `T` with the constraint of `IBinaryInteger`. On the other hand, floating point types **must** use a generic type argument `T` with the constraint of `IFloatingPointIeee754`. + +# Proposed API + +### Color + +### ColorBGRA + +### ColorHSV + +### Color3 + +### Color4 From b5013c0122656ba41fcd5a4a3225b6dc7807d4e4 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sun, 26 Nov 2023 11:46:51 +1000 Subject: [PATCH 10/25] Tweak angles --- ...sal - 3.0 Additional math types - Angle.md | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md index 934649a16d..d6cdaf0ddb 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md @@ -43,6 +43,9 @@ public readonly struct Angle , ISubtractionOperators,Angle,Angle> , IParsable> , ISpanParsable> + , IUtf8SpanParsable> + , IFormattable + , IUtf8SpanFormattable where T : IFloatingPointIeee754 { @@ -50,11 +53,14 @@ public readonly struct Angle public Angle(T totalRadians) { } - + /// Angle in degrees in the range [0, 360]. public T Degrees { get; } + /// Total angle in degrees. public T TotalDegrees { get; } - public T TotalRdians { get; } - public T Milliradians { get; } + /// Angle in radians in range [π, -π]. + public T Radians { get; } + + public T Hours { get; } public T Minutes { get; } public T Seconds { get; } @@ -185,10 +191,7 @@ public static class Angle public static Angle FromDegrees(T degrees) where T : IFloatingPointIeee754 => default; - public static Angle FromGradians(T gradians) - where T : IFloatingPointIeee754 - => default; - public static Angle FromMilliradians(T milliradians) + public static Angle FromHours(T hours) where T : IFloatingPointIeee754 => default; public static Angle FromMinutes(T minutes) @@ -198,6 +201,10 @@ public static class Angle where T : IFloatingPointIeee754 => default; + public static Angle FromTimeSpan(TimeSpan timeSpan) + where T : IFloatingPointIeee754 + => default; + public static Angle Min(Angle left, Angle right) where T : IFloatingPointIeee754 => default; From de5f43c046c35520649f004485dc28cbcb4cbc8a Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sun, 26 Nov 2023 14:33:47 +1000 Subject: [PATCH 11/25] More collisions --- ...posal - 3.0 Additional math types - Collision.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md index fb1a638bb5..00af0cabbf 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md @@ -1,7 +1,7 @@ # Summary Proposal API for additional math types to bring it up to feature parity with other popular math libraries i.e. `SlimDX`, `SharpDX`, or `Stride3D`. Leveraging modern .NET features such as `INumber` and vectorization. -This proposal is regarding "collision shapes" for containment and intersection tests. +DirectX and other APIs include "collision shapes" that can be used for such things as culling. This proposal covers the addition of similar "Bounding{Shape}" types and their corresponding containment and intersection test. # Contributors - Daniel Keenan (dfkeenan) @@ -26,16 +26,19 @@ Where it is appropriate for a type in this proposal to have both integer and flo # Proposed API -DirectX and other APIs include "collision shapes" that can be used for such things as culling. `Silk.Net.Maths` already includes some types i.e. `BoxF`, `PlaneF`. These are additional. +`BoundingOrientedBox` is defined with a quaternion as it's orientation. `Quaternion` is constrained by the `IBinaryFloatingPointIeee754` scalar type. Therefore all bounding shapes with be constrained by the `IBinaryFloatingPointIeee754` scalar type. -### Frustum +### BoundingBox -### OrientedBox +### BoundingOrientedBox -### CollisionHelper +### BoundingFrustum + +### BoundingSphere ### PlaneIntersectionType ### ContainmentType +### CollisionHelper From 2765624590de16c65e05ad654d48b7c6f009f59a Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sun, 26 Nov 2023 16:02:46 +1000 Subject: [PATCH 12/25] Angle - rename T to TScalar --- ...sal - 3.0 Additional math types - Angle.md | 192 +++++++++--------- 1 file changed, 96 insertions(+), 96 deletions(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md index d6cdaf0ddb..3a8296eea4 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md @@ -29,152 +29,152 @@ Where it is appropriate for a type in this proposal to have both integer and flo Interface implementations not included for brevity. ```csharp -public readonly struct Angle - : IEquatable> - , IEqualityOperators,Angle, bool> - , IComparable> - , IComparisonOperators,Angle, bool> - , IAdditionOperators,Angle,Angle> - , IDivisionOperators, T, Angle> - , IDivisionOperators, Angle> - , IMultiplyOperators, T, Angle> - , IMultiplyOperators, Angle> - , IModulusOperators, Angle, Angle> - , ISubtractionOperators,Angle,Angle> - , IParsable> - , ISpanParsable> - , IUtf8SpanParsable> +public readonly struct Angle + : IEquatable> + , IEqualityOperators,Angle, bool> + , IComparable> + , IComparisonOperators,Angle, bool> + , IAdditionOperators,Angle,Angle> + , IDivisionOperators, TScalar, Angle> + , IDivisionOperators, Angle> + , IMultiplyOperators, TScalar, Angle> + , IMultiplyOperators, Angle> + , IModulusOperators, Angle, Angle> + , ISubtractionOperators,Angle,Angle> + , IParsable> + , ISpanParsable> + , IUtf8SpanParsable> , IFormattable , IUtf8SpanFormattable - where T : IFloatingPointIeee754 + where TScalar : IFloatingPointIeee754 { - public readonly T TotalRadians; + public readonly TScalar TotalRadians; - public Angle(T totalRadians) { } + public Angle(TScalar totalRadians) { } /// Angle in degrees in the range [0, 360]. - public T Degrees { get; } + public TScalar Degrees { get; } /// Total angle in degrees. - public T TotalDegrees { get; } + public TScalar TotalDegrees { get; } /// Angle in radians in range [π, -π]. - public T Radians { get; } + public TScalar Radians { get; } - public T Hours { get; } - public T Minutes { get; } - public T Seconds { get; } + public TScalar Hours { get; } + public TScalar Minutes { get; } + public TScalar Seconds { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Angle /// is a right angle (i.e. 90° or π/2). /// public bool IsRight { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Angle /// is a straight angle (i.e. 180° or π). /// public bool IsStraight { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Angle /// is a full rotation angle (i.e. 360° or 2π). /// public bool IsFullRotation { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Angle /// is an oblique angle (i.e. is not 90° or a multiple of 90°). /// public bool IsOblique { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Angle /// is an acute angle (i.e. less than 90° but greater than 0°). /// public bool IsAcute { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Angle /// is an obtuse angle (i.e. greater than 90° but less than 180°). /// public bool IsObtuse { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Angle /// is a reflex angle (i.e. greater than 180° but less than 360°). /// public bool IsReflex { get; } /// - /// Gets a Angle instance that complements this angle (i.e. the two angles add to 90°). + /// Gets a Angle instance that complements this angle (i.e. the two angles add to 90°). /// - public Angle Complement { get; } + public Angle Complement { get; } /// - /// Gets a Angle instance that supplements this angle (i.e. the two angles add to 180°). + /// Gets a Angle instance that supplements this angle (i.e. the two angles add to 180°). /// - public Angle Supplement { get; } + public Angle Supplement { get; } /// - /// Wraps this Angle to be in the range [π, -π]. + /// Wraps this Angle to be in the range [π, -π]. /// - public Angle Wrap() => default; + public Angle Wrap() => default; /// - /// Wraps this Angle to be in the range [0, 2π). + /// Wraps this Angle to be in the range [0, 2π). /// - public Angle WrapPositive() => default; + public Angle WrapPositive() => default; /// Computes the arc-cosine of a value. - public T Acos() => default; + public TScalar Acos() => default; /// Computes the arc-cosine of a value and divides the result by pi. - public T AcosPi() => default; + public TScalar AcosPi() => default; /// Computes the arc-sine of a value. - public T Asin() => default; + public TScalar Asin() => default; /// Computes the arc-sine of a value and divides the result by pi. - public T AsinPi() => default; + public TScalar AsinPi() => default; /// Computes the arc-tangent of a value. - public T Atan() => default; + public TScalar Atan() => default; /// Computes the arc-tangent of a value and divides the result by pi. - public T AtanPi() => default; + public TScalar AtanPi() => default; /// Computes the cosine of a value. - public T Cos() => default; + public TScalar Cos() => default; /// Computes the cosine of a value that has been multipled by pi. - public T CosPi() => default; + public TScalar CosPi() => default; /// Computes the sine of a value. /// The value, in radians, whose sine is to be computed. /// The sine of . /// This computes sin(x). - public T Sin() => default; + public TScalar Sin() => default; /// Computes the sine and cosine of a value. - public (T Sin, T Cos) SinCos() => default; + public (TScalar Sin, TScalar Cos) SinCos() => default; /// Computes the sine and cosine of a value that has been multiplied by pi. - public (T SinPi, T CosPi) SinCosPi() => default; + public (TScalar SinPi, TScalar CosPi) SinCosPi() => default; /// Computes the sine of a value that has been multiplied by pi. - public T SinPi() => default; + public TScalar SinPi() => default; /// Computes the tangent of a value. - public T Tan() => default; + public TScalar Tan() => default; /// Computes the tangent of a value that has been multipled by pi. - public T TanPi() => default; + public TScalar TanPi() => default; /// Implicit cast in radians - public static implicit operator T(Angle angle) => default; + public static implicit operator TScalar(Angle angle) => default; } ``` @@ -185,84 +185,84 @@ public readonly struct Angle public static class Angle { - public static Angle FromRadians(T radians) - where T : IFloatingPointIeee754 + public static Angle FromRadians(TScalar radians) + where TScalar : IFloatingPointIeee754 => default; - public static Angle FromDegrees(T degrees) - where T : IFloatingPointIeee754 + public static Angle FromDegrees(TScalar degrees) + where TScalar : IFloatingPointIeee754 => default; - public static Angle FromHours(T hours) - where T : IFloatingPointIeee754 + public static Angle FromHours(TScalar hours) + where TScalar : IFloatingPointIeee754 => default; - public static Angle FromMinutes(T minutes) - where T : IFloatingPointIeee754 + public static Angle FromMinutes(TScalar minutes) + where TScalar : IFloatingPointIeee754 => default; - public static Angle FromSeconds(T seconds) - where T : IFloatingPointIeee754 + public static Angle FromSeconds(TScalar seconds) + where TScalar : IFloatingPointIeee754 => default; - public static Angle FromTimeSpan(TimeSpan timeSpan) - where T : IFloatingPointIeee754 + public static Angle FromTimeSpan(TimeSpan timeSpan) + where TScalar : IFloatingPointIeee754 => default; - public static Angle Min(Angle left, Angle right) - where T : IFloatingPointIeee754 + public static Angle Min(Angle left, Angle right) + where TScalar : IFloatingPointIeee754 => default; - public static Angle Max(Angle left, Angle right) - where T : IFloatingPointIeee754 + public static Angle Max(Angle left, Angle right) + where TScalar : IFloatingPointIeee754 => default; - public static Angle Clamp(Angle value, Angle min, Angle max) - where T : IFloatingPointIeee754 + public static Angle Clamp(Angle value, Angle min, Angle max) + where TScalar : IFloatingPointIeee754 => default; - public static Angle Lerp(Angle start, Angle end, T amount) - where T : IFloatingPointIeee754 + public static Angle Lerp(Angle start, Angle end, TScalar amount) + where TScalar : IFloatingPointIeee754 => default; - public static Angle SmoothStep(Angle start, Angle end, T amount) - where T : IFloatingPointIeee754 + public static Angle SmoothStep(Angle start, Angle end, TScalar amount) + where TScalar : IFloatingPointIeee754 => default; - public static Angle Atan2(T y, T x) - where T : IFloatingPointIeee754 + public static Angle Atan2(TScalar y, TScalar x) + where TScalar : IFloatingPointIeee754 => default; - public static Angle ArcTan(T y, T x) - where T : IFloatingPointIeee754 + public static Angle ArcTan(TScalar y, TScalar x) + where TScalar : IFloatingPointIeee754 => default; - public static Angle ArcSin(T sin) - where T : IFloatingPointIeee754 + public static Angle ArcSin(TScalar sin) + where TScalar : IFloatingPointIeee754 => default; - public static Angle ArcCos(T cos) - where T : IFloatingPointIeee754 + public static Angle ArcCos(TScalar cos) + where TScalar : IFloatingPointIeee754 => default; - public static Angle Between(Vector2F left, Vector2F right) - where T : IFloatingPointIeee754 + public static Angle Between(Vector2F left, Vector2F right) + where TScalar : IFloatingPointIeee754 => default; - public static Angle Between(Vector3F left, Vector3F right) - where T : IFloatingPointIeee754 + public static Angle Between(Vector3F left, Vector3F right) + where TScalar : IFloatingPointIeee754 => default; - public static Angle ZeroAngle() - where T : IFloatingPointIeee754 + public static Angle ZeroAngle() + where TScalar : IFloatingPointIeee754 => default; - public static Angle RightAngle() - where T : IFloatingPointIeee754 + public static Angle RightAngle() + where TScalar : IFloatingPointIeee754 => default; - public static Angle StraightAngle() - where T : IFloatingPointIeee754 + public static Angle StraightAngle() + where TScalar : IFloatingPointIeee754 => default; - public static Angle FullRotationAngle() - where T : IFloatingPointIeee754 + public static Angle FullRotationAngle() + where TScalar : IFloatingPointIeee754 => default; } ``` \ No newline at end of file From a675423cf9dd89966bf7e1360b6f267a0a338790 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 2 Dec 2023 15:45:10 +1000 Subject: [PATCH 13/25] More angles --- ...sal - 3.0 Additional math types - Angle.md | 129 ++++++------------ 1 file changed, 43 insertions(+), 86 deletions(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md index 3a8296eea4..8dae115305 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md @@ -16,19 +16,27 @@ Proposal API for additional math types to bring it up to feature parity with oth - Text herein marked **INFORMATIVE** does not form a normative part of this proposal, and is for background only. - Within this proposal, the key words **must**, **required**, **shall**, **should**, **recommended**, **may**, **could**, and **optional** are to be interpreted as described in [RFC 2119 - Key words for use in RFCs to Indicate Requirement Levels](https://www.ietf.org/rfc/rfc2119.txt). The additional key word **optionally** is an alternate form of **optional**, for use where grammatically appropriate. These key words are highlighted in the proposal for clarity. -# **INFORMATIVE** Integer and Floating Point Types -While investigating the use of generic math it was decided to provide both an integer and floating point variant for each vector type and every type built from them. See [Generic Math](Proposal%20-%20Generic%20Math.md) proposal for more details. -# I types versus F Types -Where it is appropriate for a type in this proposal to have both integer and floating point variants they will have a name that ends in I or F, defining whether it is an integer type or floating point type. Integer types **must** use a generic type argument `T` with the constraint of `IBinaryInteger`. On the other hand, floating point types **must** use a generic type argument `T` with the constraint of `IFloatingPointIeee754`. # Proposed API ## Angle +* `IParsable`, `ISpanParsable`, `IUtf8SpanParsable` + * must parse angle in degrees using `IParsable`, `ISpanParsable`, `IUtf8SpanParsable` + * optional handle `°` character + +* `IFormattable`, `IUtf8SpanFormattable` + * must produce text in degrees with default format of 2 decimal places. i.e. format string `0.##` + * optional include `°` character. i.e. format string `0.##°` + Interface implementations not included for brevity. ```csharp +/// +/// Represents a unit independant angle using a floating-point +/// internal representation. +/// public readonly struct Angle : IEquatable> , IEqualityOperators,Angle, bool> @@ -48,131 +56,76 @@ public readonly struct Angle , IUtf8SpanFormattable where TScalar : IFloatingPointIeee754 { - - public readonly TScalar TotalRadians; - - public Angle(TScalar totalRadians) { } + public Angle(TScalar radians) { } /// Angle in degrees in the range [0, 360]. public TScalar Degrees { get; } - /// Total angle in degrees. - public TScalar TotalDegrees { get; } + /// Angle in radians in range [π, -π]. public TScalar Radians { get; } - public TScalar Hours { get; } + /// Angle in radians in range [0, 2π]. + public TScalar PositiveRadians { get; } + + /// Gets or sets the minutes component of the degrees this Silk.NET.Maths.Angle represents. public TScalar Minutes { get; } + + /// Gets or sets the seconds of the degrees this Silk.NET.Maths.Angle represents. public TScalar Seconds { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Silk.NET.Maths.Angle /// is a right angle (i.e. 90° or π/2). /// public bool IsRight { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Silk.NET.Maths.Angle /// is a straight angle (i.e. 180° or π). /// public bool IsStraight { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Silk.NET.Maths.Angle /// is a full rotation angle (i.e. 360° or 2π). /// public bool IsFullRotation { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Silk.NET.Maths.Angle /// is an oblique angle (i.e. is not 90° or a multiple of 90°). /// public bool IsOblique { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Silk.NET.Maths.Angle /// is an acute angle (i.e. less than 90° but greater than 0°). /// public bool IsAcute { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Silk.NET.Maths.Angle /// is an obtuse angle (i.e. greater than 90° but less than 180°). /// public bool IsObtuse { get; } /// - /// Gets a System.Boolean that determines whether this Angle + /// Gets a System.Boolean that determines whether this Silk.NET.Maths.Angle /// is a reflex angle (i.e. greater than 180° but less than 360°). /// public bool IsReflex { get; } /// - /// Gets a Angle instance that complements this angle (i.e. the two angles add to 90°). + /// Gets a Silk.NET.Maths.Angle instance that complements this angle (i.e. the two angles add to 90°). /// public Angle Complement { get; } /// - /// Gets a Angle instance that supplements this angle (i.e. the two angles add to 180°). + /// Gets a Silk.NET.Maths.Angle instance that supplements this angle (i.e. the two angles add to 180°). /// public Angle Supplement { get; } - /// - /// Wraps this Angle to be in the range [π, -π]. - /// - public Angle Wrap() => default; - - /// - /// Wraps this Angle to be in the range [0, 2π). - /// - public Angle WrapPositive() => default; - - - /// Computes the arc-cosine of a value. - public TScalar Acos() => default; - - /// Computes the arc-cosine of a value and divides the result by pi. - public TScalar AcosPi() => default; - - /// Computes the arc-sine of a value. - public TScalar Asin() => default; - - /// Computes the arc-sine of a value and divides the result by pi. - public TScalar AsinPi() => default; - - /// Computes the arc-tangent of a value. - public TScalar Atan() => default; - - /// Computes the arc-tangent of a value and divides the result by pi. - public TScalar AtanPi() => default; - - /// Computes the cosine of a value. - public TScalar Cos() => default; - - /// Computes the cosine of a value that has been multipled by pi. - public TScalar CosPi() => default; - - /// Computes the sine of a value. - /// The value, in radians, whose sine is to be computed. - /// The sine of . - /// This computes sin(x). - public TScalar Sin() => default; - - /// Computes the sine and cosine of a value. - public (TScalar Sin, TScalar Cos) SinCos() => default; - - /// Computes the sine and cosine of a value that has been multiplied by pi. - public (TScalar SinPi, TScalar CosPi) SinCosPi() => default; - - /// Computes the sine of a value that has been multiplied by pi. - public TScalar SinPi() => default; - - /// Computes the tangent of a value. - public TScalar Tan() => default; - - /// Computes the tangent of a value that has been multipled by pi. - public TScalar TanPi() => default; - /// Implicit cast in radians public static implicit operator TScalar(Angle angle) => default; } @@ -188,20 +141,16 @@ public static class Angle public static Angle FromRadians(TScalar radians) where TScalar : IFloatingPointIeee754 => default; + public static Angle FromDegrees(TScalar degrees) where TScalar : IFloatingPointIeee754 => default; - public static Angle FromHours(TScalar hours) - where TScalar : IFloatingPointIeee754 - => default; + public static Angle FromMinutes(TScalar minutes) where TScalar : IFloatingPointIeee754 => default; - public static Angle FromSeconds(TScalar seconds) - where TScalar : IFloatingPointIeee754 - => default; - public static Angle FromTimeSpan(TimeSpan timeSpan) + public static Angle FromSeconds(TScalar seconds) where TScalar : IFloatingPointIeee754 => default; @@ -213,15 +162,23 @@ public static class Angle where TScalar : IFloatingPointIeee754 => default; - public static Angle Clamp(Angle value, Angle min, Angle max) + public static Angle Add(Angle left, Angle right) + where TScalar : IFloatingPointIeee754 + => default; + + public static Angle Subtract(Angle left, Angle right) where TScalar : IFloatingPointIeee754 => default; - public static Angle Lerp(Angle start, Angle end, TScalar amount) + public static Angle Multiply(Angle left, TScalar right) where TScalar : IFloatingPointIeee754 => default; - public static Angle SmoothStep(Angle start, Angle end, TScalar amount) + public static Angle Divide(Angle left, TScalar right) + where TScalar : IFloatingPointIeee754 + => default; + + public static Angle Clamp(Angle value, Angle min, Angle max) where TScalar : IFloatingPointIeee754 => default; From ad2a860215d5ea9e675e950836511f9fcec1f72f Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 9 Dec 2023 20:50:07 +1000 Subject: [PATCH 14/25] Add some collision shape interfaces. --- ...- 3.0 Additional math types - Collision.md | 188 +++++++++++++++++- 1 file changed, 184 insertions(+), 4 deletions(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md index 00af0cabbf..f03f41ee9a 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md @@ -26,19 +26,199 @@ Where it is appropriate for a type in this proposal to have both integer and flo # Proposed API -`BoundingOrientedBox` is defined with a quaternion as it's orientation. `Quaternion` is constrained by the `IBinaryFloatingPointIeee754` scalar type. Therefore all bounding shapes with be constrained by the `IBinaryFloatingPointIeee754` scalar type. +`BoundingOrientedBox` is defined with a quaternion as it's orientation. `Quaternion` is constrained by the `IBinaryFloatingPointIeee754` scalar type. Therefore all bounding shapes with be constrained by the `IBinaryFloatingPointIeee754` scalar type. + +### PlaneIntersectionType + +```csharp + public enum PlaneIntersectionType + { + Back, + Front, + Intersecting, + } +``` + +### ContainmentType +```csharp +public enum ContainmentType +{ + Disjoint, + Contains, + Intersects, +} +``` + +### IIntersectWithRay +```csharp +public interface IIntersectWithRay + where TScalar : IFloatingPointIeee754 +{ + public bool Intersects(ref readonly Ray3F ray); + + public static abstract bool Intersects(ref readonly TSelf shape, ref readonly Ray3F ray); + + public bool Intersects(ref readonly Ray3F ray, out float distance); + + public static abstract bool Intersects(ref readonly TSelf shape, ref readonly Ray3F ray, out float distance); + + public bool Intersects(ref readonly Ray3F ray, out Vector3F point); + + public static abstract bool Intersects(ref readonly TSelf shape, ref readonly Ray3F ray, out Vector3F point); +} +``` + +### IIntersectWithPlane +```csharp +public interface IIntersectWithPlane + where TScalar : IFloatingPointIeee754 +{ + + public PlaneIntersectionType Intersects(ref readonly PlaneF plane); + public static abstract PlaneIntersectionType Intersects(ref readonly TSelf shape, ref readonly PlaneF plane); +} +``` + +### IIntersect +```csharp +public interface IIntersect +{ + public bool Intersects(ref readonly TOther other); + + public static abstract bool Intersects(ref readonly TSelf shape, ref readonly TOther other); +} +``` + +### IContainPoint +```csharp +public interface IContainPoint + where TScalar : IFloatingPointIeee754 +{ + + public ContainmentType Contains(ref readonly Vector3F point); + + public static abstract ContainmentType Contains(ref readonly TSelf shape, ref readonly Vector3F point); + + public ContainmentType Contains(ref readonly Vector3F vertex1, ref readonly Vector3F vertex2, ref readonly Vector3F vertex3); + + public static abstract ContainmentType Contains(ref readonly TSelf shape, ref readonly Vector3F vertex1, ref readonly Vector3F vertex2, ref readonly Vector3F vertex3); +} +``` + +### IContain +```csharp +public interface IContain +{ + public ContainmentType Contains(ref readonly TOther other); + + public static abstract ContainmentType Contains(ref readonly TSelf shape, ref readonly TOther other); +} +``` + +### IColliderShape +```csharp +public interface IColliderShape + where TScalar : IFloatingPointIeee754 +{ + public static abstract void FromPoints(ReadOnlySpan> points, out TSelf result); + public static abstract TSelf FromPoints(ReadOnlySpan> points); + + public static abstract void Merge(ref readonly TSelf value1, ref readonly TSelf value2, out TSelf result); + + public static abstract TSelf Merge(TSelf value1, TSelf value2); + + public static abstract void Transform(ref readonly TSelf value, ref readonly Matrix4x4F transform); + public static abstract void Transform(ref readonly TSelf value, ref readonly Matrix4x4F transform, out TSelf result); +} +``` ### BoundingBox +Access aligned box + +```csharp +public struct BoundingBox + : IEquatable> + , IEqualityOperators, BoundingBox, bool> + , IIntersectWithRay, TScalar> + , IIntersectWithPlane, TScalar> + , IColliderShape, TScalar> + , IContainPoint, TScalar> + , IIntersect, BoundingBox> + //Implement IIntersect for other shapes + , IContain, BoundingBox> + //Implement IContain for other shapes + , IFormattable + where TScalar: IBinaryFloatingPointIeee754 +{ + +} +``` + +### BoundingBoxExtent + +Access aligned box for fast frustum culling. + +```csharp + +``` + ### BoundingOrientedBox +Box with orientation + +```csharp +public struct BoundingOrientedBox + : IEquatable> + , IEqualityOperators, BoundingOrientedBox, bool> + , IIntersectWithRay, TScalar> + , IIntersectWithPlane, TScalar> + , IColliderShape, TScalar> + , IContainPoint, TScalar> + , IIntersect, BoundingOrientedBox> + //Implement IIntersect for other shapes + , IContain, BoundingOrientedBox> + //Implement IContain for other shapes + , IFormattable + where TScalar : IBinaryFloatingPointIeee754 +{ + +} +``` + ### BoundingFrustum -### BoundingSphere +Frustum -### PlaneIntersectionType +```csharp -### ContainmentType +``` + +### BoundingSphere + +Sphere + +```csharp +public struct BoundingSphere + : IEquatable> + , IEqualityOperators, BoundingSphere, bool> + , IIntersectWithRay, TScalar> + , IIntersectWithPlane, TScalar> + , IColliderShape, TScalar> + , IContainPoint, TScalar> + , IIntersect, BoundingSphere> + //Implement IIntersect for other shapes + , IContain, BoundingSphere> + //Implement IContain for other shapes + , IFormattable + where TScalar : IBinaryFloatingPointIeee754 +{ + +} +``` ### CollisionHelper +```csharp + +``` \ No newline at end of file From 3fccc873d87291c0367b4b7d5b4dca01fa01d499 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 30 Mar 2024 17:10:35 +1000 Subject: [PATCH 15/25] Angel changes --- .../Proposal - 3.0 Additional math types - Angle.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md index 8dae115305..bac6593adc 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md @@ -58,9 +58,12 @@ public readonly struct Angle { public Angle(TScalar radians) { } - /// Angle in degrees in the range [0, 360]. + /// Angle in degrees in the range [0, 360]. Without fractional component. public TScalar Degrees { get; } + /// Angle in degrees in the range [0, 360]. With fractional component. + public TScalar TotalDegrees { get; } + /// Angle in radians in range [π, -π]. public TScalar Radians { get; } @@ -146,13 +149,9 @@ public static class Angle where TScalar : IFloatingPointIeee754 => default; - public static Angle FromMinutes(TScalar minutes) - where TScalar : IFloatingPointIeee754 - => default; - - public static Angle FromSeconds(TScalar seconds) + public static Angle FromDegrees(TScalar degrees, TScalar minutes, TScalar seconds) where TScalar : IFloatingPointIeee754 - => default; + => default; public static Angle Min(Angle left, Angle right) where TScalar : IFloatingPointIeee754 From bca07ec1b8c674c44c2ddbc1db0c1d248a15b18d Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sun, 31 Mar 2024 16:56:06 +1000 Subject: [PATCH 16/25] More collision updates. --- ...- 3.0 Additional math types - Collision.md | 81 +++++++++---------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md index f03f41ee9a..e2d3f259f2 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md @@ -26,7 +26,9 @@ Where it is appropriate for a type in this proposal to have both integer and flo # Proposed API -`BoundingOrientedBox` is defined with a quaternion as it's orientation. `Quaternion` is constrained by the `IBinaryFloatingPointIeee754` scalar type. Therefore all bounding shapes with be constrained by the `IBinaryFloatingPointIeee754` scalar type. +`Silk.NET.Math` and the generic math proposal for 3.0 already contain "geometric types that would be suitable to use for collision/intersection types. i.e. Box3F. + +This proposal is to add additional APIs for the purpose of intersection tests. ### PlaneIntersectionType @@ -132,52 +134,39 @@ public interface IColliderShape } ``` -### BoundingBox +### BoxF -Access aligned box +Additional interfaces/members for BoxF. Interface implementations not included for brevity. ```csharp -public struct BoundingBox - : IEquatable> - , IEqualityOperators, BoundingBox, bool> - , IIntersectWithRay, TScalar> +public struct BoxF + : IIntersectWithRay, TScalar> , IIntersectWithPlane, TScalar> , IColliderShape, TScalar> , IContainPoint, TScalar> - , IIntersect, BoundingBox> + , IIntersect, BoxF> //Implement IIntersect for other shapes - , IContain, BoundingBox> + , IContain, BoxF> //Implement IContain for other shapes - , IFormattable where TScalar: IBinaryFloatingPointIeee754 { } ``` -### BoundingBoxExtent - -Access aligned box for fast frustum culling. - -```csharp - -``` - -### BoundingOrientedBox +### SphereF -Box with orientation +Additional interfaces/members for SphereF. Interface implementations not included for brevity. ```csharp -public struct BoundingOrientedBox - : IEquatable> - , IEqualityOperators, BoundingOrientedBox, bool> - , IIntersectWithRay, TScalar> - , IIntersectWithPlane, TScalar> - , IColliderShape, TScalar> - , IContainPoint, TScalar> - , IIntersect, BoundingOrientedBox> +public struct SphereF + , IIntersectWithRay, TScalar> + , IIntersectWithPlane, TScalar> + , IColliderShape, TScalar> + , IContainPoint, TScalar> + , IIntersect, SphereF> //Implement IIntersect for other shapes - , IContain, BoundingOrientedBox> + , IContain, SphereF> //Implement IContain for other shapes , IFormattable where TScalar : IBinaryFloatingPointIeee754 @@ -186,29 +175,29 @@ public struct BoundingOrientedBox } ``` -### BoundingFrustum +### BoxFExtent -Frustum +Access aligned box for fast frustum culling. Interface implementations not included for brevity. ```csharp ``` -### BoundingSphere +### OrientedBoxF -Sphere +Box with orientation. Interface implementations not included for brevity. ```csharp -public struct BoundingSphere - : IEquatable> - , IEqualityOperators, BoundingSphere, bool> - , IIntersectWithRay, TScalar> - , IIntersectWithPlane, TScalar> - , IColliderShape, TScalar> - , IContainPoint, TScalar> - , IIntersect, BoundingSphere> +public struct OrientedBoxF + : IEquatable> + , IEqualityOperators, OrientedBoxF, bool> + , IIntersectWithRay, TScalar> + , IIntersectWithPlane, TScalar> + , IColliderShape, TScalar> + , IContainPoint, TScalar> + , IIntersect, OrientedBoxF> //Implement IIntersect for other shapes - , IContain, BoundingSphere> + , IContain, OrientedBoxF> //Implement IContain for other shapes , IFormattable where TScalar : IBinaryFloatingPointIeee754 @@ -217,6 +206,14 @@ public struct BoundingSphere } ``` +### FrustumF + +Frustum + +```csharp + +``` + ### CollisionHelper ```csharp From 272a2bf115c3c838b7f325144c1b9eb05c7ae83a Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 4 May 2024 14:42:32 +1000 Subject: [PATCH 17/25] Make Angle constructor internal --- .../proposals/Proposal - 3.0 Additional math types - Angle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md index bac6593adc..b30072df84 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md @@ -56,7 +56,7 @@ public readonly struct Angle , IUtf8SpanFormattable where TScalar : IFloatingPointIeee754 { - public Angle(TScalar radians) { } + internal Angle(TScalar radians) { } /// Angle in degrees in the range [0, 360]. Without fractional component. public TScalar Degrees { get; } From b655ee72712ea117e9e06af097c747c3ab0b2cd9 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 4 May 2024 15:28:02 +1000 Subject: [PATCH 18/25] Add some Frustum details --- ...- 3.0 Additional math types - Collision.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md index e2d3f259f2..2c5ea61b3c 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md @@ -211,6 +211,36 @@ public struct OrientedBoxF Frustum ```csharp +public struct FrustumF + , IIntersectWithRay, TScalar> + , IIntersectWithPlane, TScalar> + , IColliderShape, TScalar> + , IContainPoint, TScalar> + , IIntersect, FrustumF> + //Implement IIntersect for other shapes + , IContain, FrustumF> + //Implement IContain for other shapes + , IFormattable + , IEquatable> + where TScalar : IBinaryFloatingPointIeee754 +{ + public PlaneF LeftPlane; + public PlaneF RightPlane; + public PlaneF TopPlane; + public PlaneF BottomPlane; + public PlaneF NearPlane; + public PlaneF FarPlane; +} + +``` + +```csharp +public static class Frustum +{ + public static FrustumF FromMatrix(Matrix4x4F) + where TScalar : IBinaryFloatingPointIeee754 + => default; +} ``` From 2b448aeb8d5859519c5a48c26e4443c52ba44d70 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 4 May 2024 15:28:30 +1000 Subject: [PATCH 19/25] Add meeting agenda/notes sections --- .../proposals/Proposal - 3.0 Additional math types - Angle.md | 4 +++- .../Proposal - 3.0 Additional math types - Collision.md | 4 +++- .../proposals/Proposal - 3.0 Additional math types - Color.md | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md index b30072df84..e46c0574c3 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md @@ -221,4 +221,6 @@ public static class Angle where TScalar : IFloatingPointIeee754 => default; } -``` \ No newline at end of file +``` + +# Meeting Agenda/Notes \ No newline at end of file diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md index 2c5ea61b3c..4d3887186e 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md @@ -248,4 +248,6 @@ public static class Frustum ```csharp -``` \ No newline at end of file +``` + +# Meeting Agenda/Notes \ No newline at end of file diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Color.md b/documentation/proposals/Proposal - 3.0 Additional math types - Color.md index 79853831b0..50ceef73c6 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Color.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Color.md @@ -35,3 +35,5 @@ Where it is appropriate for a type in this proposal to have both integer and flo ### Color3 ### Color4 + +# Meeting Agenda/Notes From 6ed4e0bd82b6a64902421847180ec7a0adc4ad35 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 4 May 2024 15:40:34 +1000 Subject: [PATCH 20/25] Add discussion notes to angle --- .../Proposal - 3.0 Additional math types - Angle.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md index e46c0574c3..a834fb014f 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md @@ -223,4 +223,15 @@ public static class Angle } ``` -# Meeting Agenda/Notes \ No newline at end of file +# Meeting Agenda/Notes +## TDB +* Degrees, minutes and seconds are not fractional. Should they be changed to an integer type (`int`)? + * ```csharp + public int Degrees { get; } + public int Minutes { get; } + public int Seconds { get; } + + public static Angle FromDegrees(int degrees, int minutes, int seconds) + where TScalar : IFloatingPointIeee754 + => default; + ``` \ No newline at end of file From 302c108dd418c30069209355e455eec06801a0a7 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 4 May 2024 15:58:54 +1000 Subject: [PATCH 21/25] Add Empty to IColliderShape --- .../Proposal - 3.0 Additional math types - Collision.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md index 4d3887186e..c0c2cae23a 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md @@ -122,6 +122,8 @@ public interface IContain public interface IColliderShape where TScalar : IFloatingPointIeee754 { + public static abstract TSelf Empty { get; } + public static abstract void FromPoints(ReadOnlySpan> points, out TSelf result); public static abstract TSelf FromPoints(ReadOnlySpan> points); From c8ef63d4bbcc204359ba3564497c9e737e32d568 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sun, 5 May 2024 00:10:32 +1000 Subject: [PATCH 22/25] Make a start on color types. (Copying Stride 3D.) --- ...sal - 3.0 Additional math types - Color.md | 2808 +++++++++++++++++ 1 file changed, 2808 insertions(+) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Color.md b/documentation/proposals/Proposal - 3.0 Additional math types - Color.md index 50ceef73c6..9a7e115ebd 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Color.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Color.md @@ -28,12 +28,2820 @@ Where it is appropriate for a type in this proposal to have both integer and flo ### Color +```csharp + [StructLayout(LayoutKind.Sequential, Size = 4)] + public partial struct Color : IEquatable + { + public byte R; + public byte G; + public byte B; + public byte A; + + /// + /// Initializes a new instance of the struct. + /// + /// The value that will be assigned to all components. + public Color(byte value) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The value that will be assigned to all components. + public Color(float value) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red component of the color. + /// The green component of the color. + /// The blue component of the color. + /// The alpha component of the color. + public Color(byte red, byte green, byte blue, byte alpha) + { + } + + /// + /// Initializes a new instance of the struct. Alpha is set to 255. + /// + /// The red component of the color. + /// The green component of the color. + /// The blue component of the color. + public Color(byte red, byte green, byte blue) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red component of the color. + /// The green component of the color. + /// The blue component of the color. + /// The alpha component of the color. + public Color(float red, float green, float blue, float alpha) + { + } + + /// + /// Initializes a new instance of the struct. Alpha is set to 255. + /// + /// The red component of the color. + /// The green component of the color. + /// The blue component of the color. + public Color(float red, float green, float blue) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red, green, blue, and alpha components of the color. + public Color(Vector4F value) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red, green, and blue components of the color. + /// The alpha component of the color. + public Color(Vector3F value, float alpha) + { + } + + /// + /// Initializes a new instance of the struct. Alpha is set to 255. + /// + /// The red, green, and blue components of the color. + public Color(Vector3F value) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// A packed integer containing all four color components in RGBA order. + public Color(uint rgba) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// A packed integer containing all four color components in RGBA order. + public Color(int rgba) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The values to assign to the red, green, and blue, alpha components of the color. This must be an array with four elements. + /// Thrown when is null. + /// Thrown when contains more or less than four elements. + public Color(float[] values) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The values to assign to the red, green, blue, or alpha components of the color. This must be an array with four elements. + /// Thrown when is null. + /// Thrown when contains more or less than four elements. + public Color(byte[] values) + { + } + + /// + /// Gets or sets the component at the specified index. + /// + /// The value of the red, green, blue, or alpha component, depending on the index. + /// The index of the component to access. Use 0 for the red(R) component, 1 for the green(G) component, 2 for the blue(B) component, and 3 for the alpha(A) component. + /// The value of the component at the specified index. + /// Thrown when the is out of the range [0, 3]. + public byte this[int index] { get; set; } + + /// + /// Converts the color into a packed integer. + /// + /// A packed integer containing all four color components. + public int ToBgra() + => default; + + /// + /// Converts the color into a packed integer. + /// + /// A packed integer containing all four color components. + public int ToRgba() + => default; + + /// + /// Converts the color into a packed integer. + /// + /// A packed integer containing all four color components. + public int ToArgb() + => default; + + /// + /// Converts the color into a packed integer. + /// + /// A packed integer containing all four color components. + public int ToAbgr() + => default; + + /// + /// Converts the color into a three component vector. + /// + /// A three component vector containing the red, green, and blue components of the color. + public Vector3F ToVector3() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Converts the color into a three component color. + /// + /// A three component color containing the red, green, and blue components of the color. + public Color3 ToColor3() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Converts the color into a four component vector. + /// + /// A four component vector containing all four color components. + public Vector4F ToVector4() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Creates an array containing the elements of the color. + /// + /// A four-element array containing the components of the color in RGBA order. + public byte[] ToArray() + => default; + + /// + /// Gets the brightness. + /// + /// The Hue-Saturation-Brightness (HSB) saturation for this + public float GetBrightness() + => default; + + /// + /// Gets the hue. + /// + /// The Hue-Saturation-Brightness (HSB) saturation for this + public float GetHue() + => default; + + /// + /// Gets the saturation. + /// + /// The Hue-Saturation-Brightness (HSB) saturation for this + public float GetSaturation() + => default; + + /// + /// Adds two colors. + /// + /// The first color to add. + /// The second color to add. + /// When the method completes, completes the sum of the two colors. + public static void Add(ref readonly Color left, ref readonly Color right, out Color result) + { + } + + /// + /// Adds two colors. + /// + /// The first color to add. + /// The second color to add. + /// The sum of the two colors. + public static Color Add(Color left, Color right) + => default; + + /// + /// Subtracts two colors. + /// + /// The first color to subtract. + /// The second color to subtract. + /// WHen the method completes, contains the difference of the two colors. + public static void Subtract(ref readonly Color left, ref readonly Color right, out Color result) + { + } + + /// + /// Subtracts two colors. + /// + /// The first color to subtract. + /// The second color to subtract + /// The difference of the two colors. + public static Color Subtract(Color left, Color right) + => default; + + /// + /// Modulates two colors. + /// + /// The first color to modulate. + /// The second color to modulate. + /// When the method completes, contains the modulated color. + public static void Modulate(ref readonly Color left, ref readonly Color right, out Color result) + { + } + + /// + /// Modulates two colors. + /// + /// The first color to modulate. + /// The second color to modulate. + /// The modulated color. + public static Color Modulate(Color left, Color right) + => default; + + /// + /// Scales a color. + /// + /// The color to scale. + /// The amount by which to scale. + /// When the method completes, contains the scaled color. + public static void Scale(ref readonly Color value, float scale, out Color result) + { + } + + /// + /// Scales a color. + /// + /// The color to scale. + /// The amount by which to scale. + /// The scaled color. + public static Color Scale(Color value, float scale) + => default; + + /// + /// Negates a color. + /// + /// The color to negate. + /// When the method completes, contains the negated color. + public static void Negate(ref readonly Color value, out Color result) + { + } + + /// + /// Negates a color. + /// + /// The color to negate. + /// The negated color. + public static Color Negate(Color value) + => default; + + /// + /// Restricts a value to be within a specified range. + /// + /// The value to clamp. + /// The minimum value. + /// The maximum value. + /// When the method completes, contains the clamped value. + public static void Clamp(ref readonly Color value, ref readonly Color min, ref readonly Color max, out Color result) + { + } + + /// + /// Converts the color from a packed BGRA integer. + /// + /// A packed integer containing all four color components in BGRA order + /// A color. + public static Color FromBgra(int color) + => default; + + /// + /// Converts the color from a packed BGRA integer. + /// + /// A packed integer containing all four color components in BGRA order + /// A color. + public static Color FromBgra(uint color) + => default; + + /// + /// Converts the color from a packed ABGR integer. + /// + /// A packed integer containing all four color components in ABGR order + /// A color. + public static Color FromAbgr(int color) + => default; + + /// + /// Converts the color from a packed ABGR integer. + /// + /// A packed integer containing all four color components in ABGR order + /// A color. + public static Color FromAbgr(uint color) + => default; + + /// + /// Converts the color from a packed RGBA integer. + /// + /// A packed integer containing all four color components in RGBA order + /// A color. + public static Color FromRgba(int color) + => default; + + /// + /// Converts the color from a packed RGBA integer. + /// + /// A packed integer containing all four color components in RGBA order + /// A color. + public static Color FromRgba(uint color) + => default; + + /// + /// Restricts a value to be within a specified range. + /// + /// The value to clamp. + /// The minimum value. + /// The maximum value. + /// The clamped value. + public static Color Clamp(Color value, Color min, Color max) + => default; + + /// + /// Performs a linear interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// When the method completes, contains the linear interpolation of the two colors. + /// + /// Passing a value of 0 will cause to be returned; a value of 1 will cause to be returned. + /// + public static void Lerp(ref readonly Color start, ref readonly Color end, float amount, out Color result) + { + } + + /// + /// Performs a linear interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// The linear interpolation of the two colors. + /// + /// Passing a value of 0 will cause to be returned; a value of 1 will cause to be returned. + /// + public static Color Lerp(Color start, Color end, float amount) + => default; + + /// + /// Performs a cubic interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// When the method completes, contains the cubic interpolation of the two colors. + public static void SmoothStep(ref readonly Color start, ref readonly Color end, float amount, out Color result) + { + } + + /// + /// Performs a cubic interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// The cubic interpolation of the two colors. + public static Color SmoothStep(Color start, Color end, float amount) + => default; + + /// + /// Returns a color containing the smallest components of the specified colors. + /// + /// The first source color. + /// The second source color. + /// When the method completes, contains an new color composed of the largest components of the source colors. + public static void Max(ref readonly Color left, ref readonly Color right, out Color result) + { + } + + /// + /// Returns a color containing the largest components of the specified colorss. + /// + /// The first source color. + /// The second source color. + /// A color containing the largest components of the source colors. + public static Color Max(Color left, Color right) + => default; + + /// + /// Returns a color containing the smallest components of the specified colors. + /// + /// The first source color. + /// The second source color. + /// When the method completes, contains an new color composed of the smallest components of the source colors. + public static void Min(ref readonly Color left, ref readonly Color right, out Color result) + { + } + + /// + /// Returns a color containing the smallest components of the specified colors. + /// + /// The first source color. + /// The second source color. + /// A color containing the smallest components of the source colors. + public static Color Min(Color left, Color right) + => default; + + /// + /// Adjusts the contrast of a color. + /// + /// The color whose contrast is to be adjusted. + /// The amount by which to adjust the contrast. + /// When the method completes, contains the adjusted color. + public static void AdjustContrast(ref readonly Color value, float contrast, out Color result) + { + } + + /// + /// Adjusts the contrast of a color. + /// + /// The color whose contrast is to be adjusted. + /// The amount by which to adjust the contrast. + /// The adjusted color. + public static Color AdjustContrast(Color value, float contrast) + => default; + + /// + /// Adjusts the saturation of a color. + /// + /// The color whose saturation is to be adjusted. + /// The amount by which to adjust the saturation. + /// When the method completes, contains the adjusted color. + public static void AdjustSaturation(ref readonly Color value, float saturation, out Color result) + { + } + + /// + /// Adjusts the saturation of a color. + /// + /// The color whose saturation is to be adjusted. + /// The amount by which to adjust the saturation. + /// The adjusted color. + public static Color AdjustSaturation(Color value, float saturation) + => default; + + /// + /// Adds two colors. + /// + /// The first color to add. + /// The second color to add. + /// The sum of the two colors. + public static Color operator +(Color left, Color right) + => default; + + /// + /// Assert a color (return it unchanged). + /// + /// The color to assert (unchanged). + /// The asserted (unchanged) color. + public static Color operator +(Color value) + => default; + + /// + /// Subtracts two colors. + /// + /// The first color to subtract. + /// The second color to subtract. + /// The difference of the two colors. + public static Color operator -(Color left, Color right) + => default; + + /// + /// Negates a color. + /// + /// The color to negate. + /// A negated color. + public static Color operator -(Color value) + => default; + + /// + /// Scales a color. + /// + /// The factor by which to scale the color. + /// The color to scale. + /// The scaled color. + public static Color operator *(float scale, Color value) + => default; + + /// + /// Scales a color. + /// + /// The factor by which to scale the color. + /// The color to scale. + /// The scaled color. + public static Color operator *(Color value, float scale) + => default; + + /// + /// Modulates two colors. + /// + /// The first color to modulate. + /// The second color to modulate. + /// The modulated color. + public static Color operator *(Color left, Color right) + => default; + + /// + /// Tests for equality between two objects. + /// + /// The first value to compare. + /// The second value to compare. + /// true if has the same value as ; otherwise, false. + public static bool operator ==(Color left, Color right) + => default; + + /// + /// Tests for inequality between two objects. + /// + /// The first value to compare. + /// The second value to compare. + /// true if has a different value than ; otherwise, false. + public static bool operator !=(Color left, Color right) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color3(Color value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Vector3F(Color value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Vector4F(Color value) + => default; + + /// + /// Convert this instance to a + /// + /// The result of the conversion. + public Color4 ToColor4() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Performs an implicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static implicit operator Color4(Color value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color(Vector3F value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color(Color3 value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color(Vector4F value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color(Color4 value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// + /// The result of the conversion. + /// + public static explicit operator int (Color value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// + /// The result of the conversion. + /// + public static explicit operator Color(int value) + => default; + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + => default; + + /// + /// Returns a hash code for this instance. + /// + /// + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// + public override int GetHashCode() + => default; + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public bool Equals(Color other) + => default; + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public override bool Equals(object value) + => default; + + } +``` ### ColorBGRA +```csharp + [StructLayout(LayoutKind.Sequential, Size = 4)] + public partial struct ColorBGRA : IEquatable, IFormattable + { + public byte B; + public byte G; + public byte R; + public byte A; + + /// + /// Initializes a new instance of the struct. + /// + /// The value that will be assigned to all components. + public ColorBGRA(byte value) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The value that will be assigned to all components. + public ColorBGRA(float value) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red component of the color. + /// The green component of the color. + /// The blue component of the color. + /// The alpha component of the color. + public ColorBGRA(byte red, byte green, byte blue, byte alpha) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red component of the color. + /// The green component of the color. + /// The blue component of the color. + /// The alpha component of the color. + public ColorBGRA(float red, float green, float blue, float alpha) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red, green, blue, and alpha components of the color. + public ColorBGRA(Vector4F value) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red, green, and blue components of the color. + /// The alpha component of the color. + public ColorBGRA(Vector3F value, float alpha) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// A packed integer containing all four color components in BGRA order. + public ColorBGRA(uint bgra) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// A packed integer containing all four color components in BGRA. + public ColorBGRA(int bgra) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The values to assign to the red, green, and blue, alpha components of the color. This must be an array with four elements. + /// Thrown when is null. + /// Thrown when contains more or less than four elements. + public ColorBGRA(float[] values) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The values to assign to the red, green, and blue, alpha components of the color. This must be an array with four elements. + /// Thrown when is null. + /// Thrown when contains more or less than four elements. + public ColorBGRA(byte[] values) + { + } + + /// + /// Gets or sets the component at the specified index. + /// + /// The value of the alpha, red, green, or blue component, depending on the index. + /// The index of the component to access. Use 0 for the alpha component, 1 for the red component, 2 for the green component, and 3 for the blue component. + /// The value of the component at the specified index. + /// Thrown when the is out of the range [0, 3]. + public byte this[int index] { get; set; } + + /// + /// Converts the color into a packed integer. + /// + /// A packed integer containing all four color components. + public int ToBgra() + => default; + + /// + /// Converts the color into a packed integer. + /// + /// A packed integer containing all four color components. + public int ToRgba() + => default; + + /// + /// Converts the color into a three component vector. + /// + /// A three component vector containing the red, green, and blue components of the color. + public Vector3F ToVector3() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Converts the color into a three component color. + /// + /// A three component color containing the red, green, and blue components of the color. + public Color3 ToColor3() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Converts the color into a four component vector. + /// + /// A four component vector containing all four color components. + public Vector4F ToVector4() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Creates an array containing the elements of the color. + /// + /// A four-element array containing the components of the color in BGRA order. + public byte[] ToArray() + => default; + + /// + /// Gets the brightness. + /// + /// The Hue-Saturation-Brightness (HSB) saturation for this + public float GetBrightness() + => default; + + /// + /// Gets the hue. + /// + /// The Hue-Saturation-Brightness (HSB) saturation for this + public float GetHue() + => default; + + /// + /// Gets the saturation. + /// + /// The Hue-Saturation-Brightness (HSB) saturation for this + public float GetSaturation() + => default; + + /// + /// Converts the color from a packed BGRA integer. + /// + /// A packed integer containing all four color components in BGRA order + /// A color. + public static ColorBGRA FromBgra(int color) + => default; + + /// + /// Converts the color from a packed BGRA integer. + /// + /// A packed integer containing all four color components in BGRA order + /// A color. + public static ColorBGRA FromBgra(uint color) + => default; + + /// + /// Converts the color from a packed RGBA integer. + /// + /// A packed integer containing all four color components in RGBA order + /// A color. + public static ColorBGRA FromRgba(int color) + => default; + + /// + /// Converts the color from a packed RGBA integer. + /// + /// A packed integer containing all four color components in RGBA order + /// A color. + public static ColorBGRA FromRgba(uint color) + => default; + + /// + /// Adds two colors. + /// + /// The first color to add. + /// The second color to add. + /// When the method completes, completes the sum of the two colors. + public static void Add(ref readonly ColorBGRA left, ref readonly ColorBGRA right, out ColorBGRA result) + { + } + + /// + /// Adds two colors. + /// + /// The first color to add. + /// The second color to add. + /// The sum of the two colors. + public static ColorBGRA Add(ColorBGRA left, ColorBGRA right) + => default; + + /// + /// Subtracts two colors. + /// + /// The first color to subtract. + /// The second color to subtract. + /// WHen the method completes, contains the difference of the two colors. + public static void Subtract(ref readonly ColorBGRA left, ref readonly ColorBGRA right, out ColorBGRA result) + { + } + + /// + /// Subtracts two colors. + /// + /// The first color to subtract. + /// The second color to subtract + /// The difference of the two colors. + public static ColorBGRA Subtract(ColorBGRA left, ColorBGRA right) + => default; + + /// + /// Modulates two colors. + /// + /// The first color to modulate. + /// The second color to modulate. + /// When the method completes, contains the modulated color. + public static void Modulate(ref readonly ColorBGRA left, ref readonly ColorBGRA right, out ColorBGRA result) + { + } + + /// + /// Modulates two colors. + /// + /// The first color to modulate. + /// The second color to modulate. + /// The modulated color. + public static ColorBGRA Modulate(ColorBGRA left, ColorBGRA right) + => default; + + /// + /// Scales a color. + /// + /// The color to scale. + /// The amount by which to scale. + /// When the method completes, contains the scaled color. + public static void Scale(ref readonly ColorBGRA value, float scale, out ColorBGRA result) + { + } + + /// + /// Scales a color. + /// + /// The color to scale. + /// The amount by which to scale. + /// The scaled color. + public static ColorBGRA Scale(ColorBGRA value, float scale) + => default; + + /// + /// Negates a color. + /// + /// The color to negate. + /// When the method completes, contains the negated color. + public static void Negate(ref readonly ColorBGRA value, out ColorBGRA result) + { + } + + /// + /// Negates a color. + /// + /// The color to negate. + /// The negated color. + public static ColorBGRA Negate(ColorBGRA value) + => default; + + /// + /// Restricts a value to be within a specified range. + /// + /// The value to clamp. + /// The minimum value. + /// The maximum value. + /// When the method completes, contains the clamped value. + public static void Clamp(ref readonly ColorBGRA value, ref readonly ColorBGRA min, ref readonly ColorBGRA max, out ColorBGRA result) + { + } + + /// + /// Restricts a value to be within a specified range. + /// + /// The value to clamp. + /// The minimum value. + /// The maximum value. + /// The clamped value. + public static ColorBGRA Clamp(ColorBGRA value, ColorBGRA min, ColorBGRA max) + => default; + + /// + /// Performs a linear interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// When the method completes, contains the linear interpolation of the two colors. + /// + /// Passing a value of 0 will cause to be returned; a value of 1 will cause to be returned. + /// + public static void Lerp(ref readonly ColorBGRA start, ref readonly ColorBGRA end, float amount, out ColorBGRA result) + { + } + + /// + /// Performs a linear interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// The linear interpolation of the two colors. + /// + /// Passing a value of 0 will cause to be returned; a value of 1 will cause to be returned. + /// + public static ColorBGRA Lerp(ColorBGRA start, ColorBGRA end, float amount) + => default; + + /// + /// Performs a cubic interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// When the method completes, contains the cubic interpolation of the two colors. + public static void SmoothStep(ref readonly ColorBGRA start, ref readonly ColorBGRA end, float amount, out ColorBGRA result) + { + } + + /// + /// Performs a cubic interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// The cubic interpolation of the two colors. + public static ColorBGRA SmoothStep(ColorBGRA start, ColorBGRA end, float amount) + => default; + + /// + /// Returns a color containing the smallest components of the specified colorss. + /// + /// The first source color. + /// The second source color. + /// When the method completes, contains an new color composed of the largest components of the source colorss. + public static void Max(ref readonly ColorBGRA left, ref readonly ColorBGRA right, out ColorBGRA result) + { + } + + /// + /// Returns a color containing the largest components of the specified colorss. + /// + /// The first source color. + /// The second source color. + /// A color containing the largest components of the source colors. + public static ColorBGRA Max(ColorBGRA left, ColorBGRA right) + => default; + + /// + /// Returns a color containing the smallest components of the specified colors. + /// + /// The first source color. + /// The second source color. + /// When the method completes, contains an new color composed of the smallest components of the source colors. + public static void Min(ref readonly ColorBGRA left, ref readonly ColorBGRA right, out ColorBGRA result) + { + } + + /// + /// Returns a color containing the smallest components of the specified colors. + /// + /// The first source color. + /// The second source color. + /// A color containing the smallest components of the source colors. + public static ColorBGRA Min(ColorBGRA left, ColorBGRA right) + => default; + + /// + /// Adjusts the contrast of a color. + /// + /// The color whose contrast is to be adjusted. + /// The amount by which to adjust the contrast. + /// When the method completes, contains the adjusted color. + public static void AdjustContrast(ref readonly ColorBGRA value, float contrast, out ColorBGRA result) + { + } + + /// + /// Adjusts the contrast of a color. + /// + /// The color whose contrast is to be adjusted. + /// The amount by which to adjust the contrast. + /// The adjusted color. + public static ColorBGRA AdjustContrast(ColorBGRA value, float contrast) + => default; + + /// + /// Adjusts the saturation of a color. + /// + /// The color whose saturation is to be adjusted. + /// The amount by which to adjust the saturation. + /// When the method completes, contains the adjusted color. + public static void AdjustSaturation(ref readonly ColorBGRA value, float saturation, out ColorBGRA result) + { + } + + /// + /// Adjusts the saturation of a color. + /// + /// The color whose saturation is to be adjusted. + /// The amount by which to adjust the saturation. + /// The adjusted color. + public static ColorBGRA AdjustSaturation(ColorBGRA value, float saturation) + => default; + + /// + /// Adds two colors. + /// + /// The first color to add. + /// The second color to add. + /// The sum of the two colors. + public static ColorBGRA operator +(ColorBGRA left, ColorBGRA right) + => default; + + /// + /// Assert a color (return it unchanged). + /// + /// The color to assert (unchange). + /// The asserted (unchanged) color. + public static ColorBGRA operator +(ColorBGRA value) + => default; + + /// + /// Subtracts two colors. + /// + /// The first color to subtract. + /// The second color to subtract. + /// The difference of the two colors. + public static ColorBGRA operator -(ColorBGRA left, ColorBGRA right) + => default; + + /// + /// Negates a color. + /// + /// The color to negate. + /// A negated color. + public static ColorBGRA operator -(ColorBGRA value) + => default; + + /// + /// Scales a color. + /// + /// The factor by which to scale the color. + /// The color to scale. + /// The scaled color. + public static ColorBGRA operator *(float scale, ColorBGRA value) + => default; + + /// + /// Scales a color. + /// + /// The factor by which to scale the color. + /// The color to scale. + /// The scaled color. + public static ColorBGRA operator *(ColorBGRA value, float scale) + => default; + + /// + /// Modulates two colors. + /// + /// The first color to modulate. + /// The second color to modulate. + /// The modulated color. + public static ColorBGRA operator *(ColorBGRA left, ColorBGRA right) + => default; + + /// + /// Tests for equality between two objects. + /// + /// The first value to compare. + /// The second value to compare. + /// true if has the same value as ; otherwise, false. + public static bool operator ==(ColorBGRA left, ColorBGRA right) + => default; + + /// + /// Tests for inequality between two objects. + /// + /// The first value to compare. + /// The second value to compare. + /// true if has a different value than ; otherwise, false. + public static bool operator !=(ColorBGRA left, ColorBGRA right) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color3(ColorBGRA value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Vector3F(ColorBGRA value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Vector4F(ColorBGRA value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color4(ColorBGRA value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator ColorBGRA(Vector3F value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator ColorBGRA(Color3 value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator ColorBGRA(Vector4F value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator ColorBGRA(Color4 value) + => default; + + /// + /// Performs an implicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static implicit operator ColorBGRA(Color value) + => default; + + /// + /// Performs an implicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static implicit operator Color(ColorBGRA value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// + /// The result of the conversion. + /// + public static explicit operator int (ColorBGRA value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// + /// The result of the conversion. + /// + public static explicit operator ColorBGRA(int value) + => default; + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + => default; + + /// + /// Returns a that represents this instance. + /// + /// The format to apply to each channel (byte). + /// + /// A that represents this instance. + /// + public string ToString(string format) + => default; + + /// + /// Returns a that represents this instance. + /// + /// The format provider. + /// + /// A that represents this instance. + /// + public string ToString(IFormatProvider formatProvider) + => default; + + /// + /// Returns a that represents this instance. + /// + /// The format to apply to each channel (byte). + /// The format provider. + /// + /// A that represents this instance. + /// + public string ToString(string format, IFormatProvider formatProvider) + => default; + + /// + /// Returns a hash code for this instance. + /// + /// + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// + public override int GetHashCode() + => default; + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public bool Equals(ColorBGRA other) + => default; + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public override bool Equals(object value) + => default; + + /// + /// Deconstructs the vector's components into named variables. + /// + /// The R component + /// The G component + /// The B component + /// The A component + public void Deconstruct(out byte r, out byte g, out byte b, out byte a) + { + } + + } +``` ### ColorHSV +```csharp + [StructLayout(LayoutKind.Sequential, Pack = 4)] + public struct ColorHSV : IEquatable, IFormattable + { + public float H; + public float S; + public float V; + public float A; + + /// + /// Initializes a new instance of the struct. + /// + /// The h. + /// The s. + /// The v. + /// A. + public ColorHSV(float h, float s, float v, float a) + { + } + + /// + /// Converts the color into a three component vector. + /// + /// A three component vector containing the red, green, and blue components of the color. + public Color4 ToColor() + where TScalar : IFloatingPointIeee754 + => default; + + /// + public bool Equals(ColorHSV other) + => default; + + /// + public override bool Equals(object obj) + => default; + + /// + public override int GetHashCode() + => default; + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + => default; + + /// + /// Returns a that represents this instance. + /// + /// The format. + /// + /// A that represents this instance. + /// + public string ToString(string format) + => default; + + /// + /// Returns a that represents this instance. + /// + /// The format provider. + /// + /// A that represents this instance. + /// + public string ToString(IFormatProvider formatProvider) + => default; + + /// + /// Returns a that represents this instance. + /// + /// The format. + /// The format provider. + /// + /// A that represents this instance. + /// + public string ToString(string format, IFormatProvider formatProvider) + => default; + + /// + /// Deconstructs the vector's components into named variables. + /// + /// The H component + /// The S component + /// The V component + /// The A component + public void Deconstruct(out float h, out float s, out float v, out float a) + { + } + + } +``` ### Color3 +```csharp + [StructLayout(LayoutKind.Sequential, Pack = 4)] + public struct Color3 : IEquatable>, IFormattable where TScalar : IFloatingPointIeee754 + { + public TScalar R; + public TScalar G; + public TScalar B; + + /// + /// Initializes a new instance of the struct. + /// + /// The value that will be assigned to all components. + public Color3(TScalar value) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red component of the color. + /// The green component of the color. + /// The blue component of the color. + public Color3(TScalar red, TScalar green, TScalar blue) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red, green, and blue components of the color. + public Color3(Vector3F value) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// A packed integer containing all three color components. + /// The alpha component is ignored. + public Color3(int rgb) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// A packed unsigned integer containing all three color components. + /// The alpha component is ignored. + public Color3(uint rgb) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The values to assign to the red, green, and blue components of the color. This must be an array with three elements. + /// Thrown when is null. + /// Thrown when contains more or less than four elements. + public Color3(TScalar[] values) + { + } + + /// + /// Gets or sets the component at the specified index. + /// + /// The value of the red, green, or blue component, depending on the index. + /// The index of the component to access. Use 0 for the red component, 1 for the green component, and 2 for the blue component. + /// The value of the component at the specified index. + /// Thrown when the is out of the range [0, 2]. + public TScalar this[int index] { get; set; } + + /// + /// Converts the color into a packed integer. + /// + /// A packed integer containing all three color components. + /// The alpha channel is set to 255. + public int ToRgb() + => default; + + /// + /// Raises the exponent for each components. + /// + /// The exponent. + public void Pow(TScalar exponent) + { + } + + /// + /// Converts the color into a three component vector. + /// + /// A three component vector containing the red, green, and blue components of the color. + public Vector3F ToVector3() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Creates an array containing the elements of the color. + /// + /// A three-element array containing the components of the color. + public TScalar[] ToArray() + => default; + + /// + /// Converts this color from linear space to sRGB space. + /// + /// A color3 in sRGB space. + public Color3 ToSRgb() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Converts this color from sRGB space to linear space. + /// + /// Color3. + public Color3 ToLinear() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Adds two colors. + /// + /// The first color to add. + /// The second color to add. + /// The sum of the two colors. + public static Color3 operator +(Color3 left, Color3 right) + => default; + + /// + /// Assert a color (return it unchanged). + /// + /// The color to assert (unchange). + /// The asserted (unchanged) color. + public static Color3 operator +(Color3 value) + => default; + + /// + /// Subtracts two colors. + /// + /// The first color to subtract. + /// The second color to subtract. + /// The difference of the two colors. + public static Color3 operator -(Color3 left, Color3 right) + => default; + + /// + /// Negates a color. + /// + /// The color to negate. + /// A negated color. + public static Color3 operator -(Color3 value) + => default; + + /// + /// Scales a color. + /// + /// The factor by which to scale the color. + /// The color to scale. + /// The scaled color. + public static Color3 operator *(TScalar scale, Color3 value) + => default; + + /// + /// Scales a color. + /// + /// The factor by which to scale the color. + /// The color to scale. + /// The scaled color. + public static Color3 operator *(Color3 value, TScalar scale) + => default; + + /// + /// Modulates two colors. + /// + /// The first color to modulate. + /// The second color to modulate. + /// The modulated color. + public static Color3 operator *(Color3 left, Color3 right) + => default; + + /// + /// Tests for equality between two objects. + /// + /// The first value to compare. + /// The second value to compare. + /// true if has the same value as ; otherwise, false. + public static bool operator ==(Color3 left, Color3 right) + => default; + + /// + /// Tests for inequality between two objects. + /// + /// The first value to compare. + /// The second value to compare. + /// true if has a different value than ; otherwise, false. + public static bool operator !=(Color3 left, Color3 right) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color4(Color3 value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Vector3F(Color3 value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color3(Vector3F value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color3(int value) + => default; + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + => default; + + /// + /// Convert this color to an equivalent with an opaque alpha. + /// + /// An equivalent with an opaque alpha. + public Color4 ToColor4() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Returns a that represents this instance. + /// + /// The format. + /// + /// A that represents this instance. + /// + public string ToString(string format) + => default; + + /// + /// Returns a that represents this instance. + /// + /// The format provider. + /// + /// A that represents this instance. + /// + public string ToString(IFormatProvider formatProvider) + => default; + + /// + /// Returns a that represents this instance. + /// + /// The format. + /// The format provider. + /// + /// A that represents this instance. + /// + public string ToString(string format, IFormatProvider formatProvider) + => default; + + /// + /// Returns a hash code for this instance. + /// + /// + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// + public override int GetHashCode() + => default; + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public bool Equals(Color3 other) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public override bool Equals(object value) + => default; + + /// + /// Deconstructs the vector's components into named variables. + /// + /// The R component + /// The G component + /// The B component + public void Deconstruct(out TScalar r, out TScalar g, out TScalar b) + { + } + + } +``` +```csharp + public static class Color3 + { + /// + /// Adds two colors. + /// + /// The first color to add. + /// The second color to add. + /// When the method completes, completes the sum of the two colors. + public static void Add(ref readonly Color3 left, ref readonly Color3 right, out Color3 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Adds two colors. + /// + /// The first color to add. + /// The second color to add. + /// The sum of the two colors. + public static Color3 Add(Color3 left, Color3 right) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Subtracts two colors. + /// + /// The first color to subtract. + /// The second color to subtract. + /// WHen the method completes, contains the difference of the two colors. + public static void Subtract(ref readonly Color3 left, ref readonly Color3 right, out Color3 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Subtracts two colors. + /// + /// The first color to subtract. + /// The second color to subtract + /// The difference of the two colors. + public static Color3 Subtract(Color3 left, Color3 right) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Modulates two colors. + /// + /// The first color to modulate. + /// The second color to modulate. + /// When the method completes, contains the modulated color. + public static void Modulate(ref readonly Color3 left, ref readonly Color3 right, out Color3 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Modulates two colors. + /// + /// The first color to modulate. + /// The second color to modulate. + /// The modulated color. + public static Color3 Modulate(Color3 left, Color3 right) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Scales a color. + /// + /// The color to scale. + /// The amount by which to scale. + /// When the method completes, contains the scaled color. + public static void Scale(ref readonly Color3 value, TScalar scale, out Color3 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Scales a color. + /// + /// The color to scale. + /// The amount by which to scale. + /// The scaled color. + public static Color3 Scale(Color3 value, TScalar scale) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Negates a color. + /// + /// The color to negate. + /// When the method completes, contains the negated color. + public static void Negate(ref readonly Color3 value, out Color3 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Negates a color. + /// + /// The color to negate. + /// The negated color. + public static Color3 Negate(Color3 value) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Restricts a value to be within a specified range. + /// + /// The value to clamp. + /// The minimum value. + /// The maximum value. + /// When the method completes, contains the clamped value. + public static void Clamp(ref readonly Color3 value, ref readonly Color3 min, ref readonly Color3 max, out Color3 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Restricts a value to be within a specified range. + /// + /// The value to clamp. + /// The minimum value. + /// The maximum value. + /// The clamped value. + public static Color3 Clamp(Color3 value, Color3 min, Color3 max) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Performs a linear interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// When the method completes, contains the linear interpolation of the two colors. + /// + /// This method performs the linear interpolation based on the following formula. + /// start + (end - start) * amount + /// Passing a value of 0 will cause to be returned; a value of 1 will cause to be returned. + /// + public static void Lerp(ref readonly Color3 start, ref readonly Color3 end, TScalar amount, out Color3 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Performs a linear interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// The linear interpolation of the two colors. + /// + /// This method performs the linear interpolation based on the following formula. + /// start + (end - start) * amount + /// Passing a value of 0 will cause to be returned; a value of 1 will cause to be returned. + /// + public static Color3 Lerp(Color3 start, Color3 end, TScalar amount) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Performs a cubic interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// When the method completes, contains the cubic interpolation of the two colors. + public static void SmoothStep(ref readonly Color3 start, ref readonly Color3 end, TScalar amount, out Color3 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Performs a cubic interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// The cubic interpolation of the two colors. + public static Color3 SmoothStep(Color3 start, Color3 end, TScalar amount) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Returns a color containing the smallest components of the specified colorss. + /// + /// The first source color. + /// The second source color. + /// When the method completes, contains an new color composed of the largest components of the source colorss. + public static void Max(ref readonly Color3 left, ref readonly Color3 right, out Color3 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Returns a color containing the largest components of the specified colorss. + /// + /// The first source color. + /// The second source color. + /// A color containing the largest components of the source colors. + public static Color3 Max(Color3 left, Color3 right) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Returns a color containing the smallest components of the specified colors. + /// + /// The first source color. + /// The second source color. + /// When the method completes, contains an new color composed of the smallest components of the source colors. + public static void Min(ref readonly Color3 left, ref readonly Color3 right, out Color3 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Returns a color containing the smallest components of the specified colors. + /// + /// The first source color. + /// The second source color. + /// A color containing the smallest components of the source colors. + public static Color3 Min(Color3 left, Color3 right) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Adjusts the contrast of a color. + /// + /// The color whose contrast is to be adjusted. + /// The amount by which to adjust the contrast. + /// When the method completes, contains the adjusted color. + public static void AdjustContrast(ref readonly Color3 value, TScalar contrast, out Color3 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Adjusts the contrast of a color. + /// + /// The color whose contrast is to be adjusted. + /// The amount by which to adjust the contrast. + /// The adjusted color. + public static Color3 AdjustContrast(Color3 value, TScalar contrast) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Adjusts the saturation of a color. + /// + /// The color whose saturation is to be adjusted. + /// The amount by which to adjust the saturation. + /// When the method completes, contains the adjusted color. + public static void AdjustSaturation(ref readonly Color3 value, TScalar saturation, out Color3 result) + where TScalar : IFloatingPointIeee754 + { + } + /// + /// Adjusts the saturation of a color. + /// + /// The color whose saturation is to be adjusted. + /// The amount by which to adjust the saturation. + /// The adjusted color. + public static Color3 AdjustSaturation(Color3 value, TScalar saturation) + where TScalar : IFloatingPointIeee754 + => default; + + } +``` ### Color4 +```csharp + [StructLayout(LayoutKind.Sequential, Pack = 4)] + public struct Color4 : IEquatable>, IFormattable where TScalar : IFloatingPointIeee754 + { + /// + /// The Black color (0, 0, 0, 1). + /// + public static readonly Color4 Black = new Color4(0.0f, 0.0f, 0.0f, 1.0f); + /// + /// The White color (1, 1, 1, 1). + /// + public static readonly Color4 White = new Color4(1.0f, 1.0f, 1.0f, 1.0f); + public TScalar R; + public TScalar G; + public TScalar B; + public TScalar A; + + /// + /// Initializes a new instance of the struct. + /// + /// The value that will be assigned to all components. + public Color4(TScalar value) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red component of the color. + /// The green component of the color. + /// The blue component of the color. + /// The alpha component of the color. + public Color4(TScalar red, TScalar green, TScalar blue, TScalar alpha = 1f) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red, green, blue, and alpha components of the color. + public Color4(Vector4F value) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red, green, and blue components of the color. + /// The alpha component of the color. + public Color4(Vector3F value, TScalar alpha = 1f) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// A packed integer containing all four color components in RGBA order. + public Color4(uint rgba) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// A packed integer containing all four color components in RGBA order. + public Color4(int rgba) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The values to assign to the red, green, blue, and alpha components of the color. This must be an array with four elements. + /// Thrown when is null. + /// Thrown when contains more or less than four elements. + public Color4(TScalar[] values) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// used to initialize the color. + public Color4(Color3 color) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// used to initialize the color. + public Color4(Color color) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// used to initialize the color. + public Color4(ColorBGRA color) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// used to initialize the color. + /// The alpha component of the color. + public Color4(Color3 color, TScalar alpha = 1f) + { + } + + /// + /// Gets or sets the component at the specified index. + /// + /// The value of the red, green, blue, and alpha components, depending on the index. + /// The index of the component to access. Use 0 for the alpha component, 1 for the red component, 2 for the green component, and 3 for the blue component. + /// The value of the component at the specified index. + /// Thrown when the is out of the range [0, 3]. + public TScalar this[int index] { get; set; } + + /// + /// Converts the color into a packed integer. + /// + /// A packed integer containing all four color components. + public int ToBgra() + => default; + + /// + /// Converts the color into a packed integer. + /// + public void ToBgra(out byte r, out byte g, out byte b, out byte a) + { + } + + /// + /// Converts the color into a packed integer. + /// + /// A packed integer containing all four color components. + public int ToRgba() + => default; + + /// + /// Converts the color into a three component vector. + /// + /// A three component vector containing the red, green, and blue components of the color. + public Vector3F ToVector3() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Converts the color into a four component vector. + /// + /// A four component vector containing all four color components. + public Vector4F ToVector4() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Creates an array containing the elements of the color. + /// + /// A four-element array containing the components of the color. + public TScalar[] ToArray() + => default; + + /// + /// Converts this color from linear space to sRGB space. + /// + /// A color3 in sRGB space. + public Color4 ToSRgb() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Converts this color from sRGB space to linear space. + /// + /// A color4 in linear space. + public Color4 ToLinear() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Adds two colors. + /// + /// The first color to add. + /// The second color to add. + /// The sum of the two colors. + public static Color4 operator +(Color4 left, Color4 right) + => default; + + /// + /// Assert a color (return it unchanged). + /// + /// The color to assert (unchanged). + /// The asserted (unchanged) color. + public static Color4 operator +(Color4 value) + => default; + + /// + /// Subtracts two colors. + /// + /// The first color to subtract. + /// The second color to subtract. + /// The difference of the two colors. + public static Color4 operator -(Color4 left, Color4 right) + => default; + + /// + /// Negates a color. + /// + /// The color to negate. + /// A negated color. + public static Color4 operator -(Color4 value) + => default; + + /// + /// Scales a color. + /// + /// The factor by which to scale the color. + /// The color to scale. + /// The scaled color. + public static Color4 operator *(TScalar scale, Color4 value) + => default; + + /// + /// Scales a color. + /// + /// The factor by which to scale the color. + /// The color to scale. + /// The scaled color. + public static Color4 operator *(Color4 value, TScalar scale) + => default; + + /// + /// Modulates two colors. + /// + /// The first color to modulate. + /// The second color to modulate. + /// The modulated color. + public static Color4 operator *(Color4 left, Color4 right) + => default; + + /// + /// Tests for equality between two objects. + /// + /// The first value to compare. + /// The second value to compare. + /// true if has the same value as ; otherwise, false. + public static bool operator ==(Color4 left, Color4 right) + => default; + + /// + /// Tests for inequality between two objects. + /// + /// The first value to compare. + /// The second value to compare. + /// true if has a different value than ; otherwise, false. + public static bool operator !=(Color4 left, Color4 right) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color3(Color4 value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Vector3F(Color4 value) + => default; + + /// + /// Performs an implicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static implicit operator Vector4F(Color4 value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color4(Vector3F value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color4(Vector4F value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator Color4(ColorBGRA value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator ColorBGRA(Color4 value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// + /// The result of the conversion. + /// + public static explicit operator int (Color4 value) + => default; + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// + /// The result of the conversion. + /// + public static explicit operator Color4(int value) + => default; + + /// + /// Converts this color to an equivalent , discarding the alpha channel. + /// + /// An equivalent , discarding the alpha channel. + public Color3 ToColor3() + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + => default; + + /// + /// Returns a that represents this instance. + /// + /// The format to apply to each channel (float). + /// + /// A that represents this instance. + /// + public string ToString(string format) + => default; + + /// + /// Returns a that represents this instance. + /// + /// The format provider. + /// + /// A that represents this instance. + /// + public string ToString(IFormatProvider formatProvider) + => default; + + /// + /// Returns a that represents this instance. + /// + /// The format to apply to each channel (float). + /// The format provider. + /// + /// A that represents this instance. + /// + public string ToString(string format, IFormatProvider formatProvider) + => default; + + /// + /// Returns a hash code for this instance. + /// + /// + /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + /// + public override int GetHashCode() + => default; + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public bool Equals(Color4 other) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Determines whether the specified is equal to this instance. + /// + /// The to compare with this instance. + /// + /// true if the specified is equal to this instance; otherwise, false. + /// + public override bool Equals(object value) + => default; + + /// + /// Deconstructs the vector's components into named variables. + /// + /// The R component + /// The G component + /// The B component + /// The A component + public void Deconstruct(out TScalar r, out TScalar g, out TScalar b, out TScalar a) + { + } + + } +``` +```csharp + public static class Color4 + { + /// + /// Adds two colors. + /// + /// The first color to add. + /// The second color to add. + /// When the method completes, completes the sum of the two colors. + public static void Add(ref readonly Color4 left, ref readonly Color4 right, out Color4 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Adds two colors. + /// + /// The first color to add. + /// The second color to add. + /// The sum of the two colors. + public static Color4 Add(Color4 left, Color4 right) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Subtracts two colors. + /// + /// The first color to subtract. + /// The second color to subtract. + /// WHen the method completes, contains the difference of the two colors. + public static void Subtract(ref readonly Color4 left, ref readonly Color4 right, out Color4 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Subtracts two colors. + /// + /// The first color to subtract. + /// The second color to subtract + /// The difference of the two colors. + public static Color4 Subtract(Color4 left, Color4 right) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Modulates two colors. + /// + /// The first color to modulate. + /// The second color to modulate. + /// When the method completes, contains the modulated color. + public static void Modulate(ref readonly Color4 left, ref readonly Color4 right, out Color4 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Modulates two colors. + /// + /// The first color to modulate. + /// The second color to modulate. + /// The modulated color. + public static Color4 Modulate(Color4 left, Color4 right) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Scales a color. + /// + /// The color to scale. + /// The amount by which to scale. + /// When the method completes, contains the scaled color. + public static void Scale(ref readonly Color4 value, TScalar scale, out Color4 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Scales a color. + /// + /// The color to scale. + /// The amount by which to scale. + /// The scaled color. + public static Color4 Scale(Color4 value, TScalar scale) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Negates a color. + /// + /// The color to negate. + /// When the method completes, contains the negated color. + public static void Negate(ref readonly Color4 value, out Color4 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Negates a color. + /// + /// The color to negate. + /// The negated color. + public static Color4 Negate(Color4 value) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Restricts a value to be within a specified range. + /// + /// The value to clamp. + /// The minimum value. + /// The maximum value. + /// When the method completes, contains the clamped value. + public static void Clamp(ref readonly Color4 value, ref readonly Color4 min, ref readonly Color4 max, out Color4 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Restricts a value to be within a specified range. + /// + /// The value to clamp. + /// The minimum value. + /// The maximum value. + /// The clamped value. + public static Color4 Clamp(Color4 value, Color4 min, Color4 max) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Performs a linear interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// When the method completes, contains the linear interpolation of the two colors. + /// + /// Passing a value of 0 will cause to be returned; a value of 1 will cause to be returned. + /// + public static void Lerp(ref readonly Color4 start, ref readonly Color4 end, TScalar amount, out Color4 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Performs a linear interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// The linear interpolation of the two colors. + /// + /// Passing a value of 0 will cause to be returned; a value of 1 will cause to be returned. + /// + public static Color4 Lerp(Color4 start, Color4 end, TScalar amount) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Performs a cubic interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// When the method completes, contains the cubic interpolation of the two colors. + public static void SmoothStep(ref readonly Color4 start, ref readonly Color4 end, TScalar amount, out Color4 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Performs a cubic interpolation between two colors. + /// + /// Start color. + /// End color. + /// Value between 0 and 1 indicating the weight of . + /// The cubic interpolation of the two colors. + public static Color4 SmoothStep(Color4 start, Color4 end, TScalar amount) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Returns a color containing the smallest components of the specified colors. + /// + /// The first source color. + /// The second source color. + /// When the method completes, contains an new color composed of the largest components of the source colors. + public static void Max(ref readonly Color4 left, ref readonly Color4 right, out Color4 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Returns a color containing the largest components of the specified colors. + /// + /// The first source color. + /// The second source color. + /// A color containing the largest components of the source colors. + public static Color4 Max(Color4 left, Color4 right) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Returns a color containing the smallest components of the specified colors. + /// + /// The first source color. + /// The second source color. + /// When the method completes, contains an new color composed of the smallest components of the source colors. + public static void Min(ref readonly Color4 left, ref readonly Color4 right, out Color4 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Returns a color containing the smallest components of the specified colors. + /// + /// The first source color. + /// The second source color. + /// A color containing the smallest components of the source colors. + public static Color4 Min(Color4 left, Color4 right) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Adjusts the contrast of a color. + /// + /// The color whose contrast is to be adjusted. + /// The amount by which to adjust the contrast. + /// When the method completes, contains the adjusted color. + public static void AdjustContrast(ref readonly Color4 value, TScalar contrast, out Color4 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Adjusts the contrast of a color. + /// + /// The color whose contrast is to be adjusted. + /// The amount by which to adjust the contrast. + /// The adjusted color. + public static Color4 AdjustContrast(Color4 value, TScalar contrast) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Adjusts the saturation of a color. + /// + /// The color whose saturation is to be adjusted. + /// The amount by which to adjust the saturation. + /// When the method completes, contains the adjusted color. + public static void AdjustSaturation(ref readonly Color4 value, TScalar saturation, out Color4 result) + where TScalar : IFloatingPointIeee754 + { + } + + /// + /// Adjusts the saturation of a color. + /// + /// The color whose saturation is to be adjusted. + /// The amount by which to adjust the saturation. + /// The adjusted color. + public static Color4 AdjustSaturation(Color4 value, TScalar saturation) + where TScalar : IFloatingPointIeee754 + => default; + + /// + /// Premultiplies the color components by the alpha value. + /// + /// The color to premultiply. + /// A color with premultiplied alpha. + public static Color4 PremultiplyAlpha(Color4 value) + where TScalar : IFloatingPointIeee754 + => default; + + } +``` + # Meeting Agenda/Notes +## TBD +* Started with an initial rough cut by copying the API of Stride color types. IF we want to move forward with these we can just copy and attribute. \ No newline at end of file From 34034942c7b1c9fcbef2dc17eeeea6a62e00cbd1 Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 30 Nov 2024 14:09:45 +1000 Subject: [PATCH 23/25] propsal - angle: change: add "in" modifier to some methods. --- .../proposals/Proposal - 3.0 Additional math types - Angle.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md index a834fb014f..375fbc8f96 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md @@ -197,11 +197,11 @@ public static class Angle where TScalar : IFloatingPointIeee754 => default; - public static Angle Between(Vector2F left, Vector2F right) + public static Angle Between(in Vector2F left, in Vector2F right) where TScalar : IFloatingPointIeee754 => default; - public static Angle Between(Vector3F left, Vector3F right) + public static Angle Between(in Vector3F left, in Vector3F right) where TScalar : IFloatingPointIeee754 => default; From 103d95b1b9b690e578496020434b845de649e9db Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 30 Nov 2024 14:11:03 +1000 Subject: [PATCH 24/25] proposal - collision: add more details for BoxExtentF and OrientedBoxF --- ...- 3.0 Additional math types - Collision.md | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md index c0c2cae23a..a5d2f094d5 100644 --- a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md +++ b/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md @@ -26,7 +26,7 @@ Where it is appropriate for a type in this proposal to have both integer and flo # Proposed API -`Silk.NET.Math` and the generic math proposal for 3.0 already contain "geometric types that would be suitable to use for collision/intersection types. i.e. Box3F. +`Silk.NET.Math` and the generic math proposal for 3.0 already contain "geometric types" that would be suitable to use for collision/intersection types. i.e. Box3F. This proposal is to add additional APIs for the purpose of intersection tests. @@ -177,11 +177,36 @@ public struct SphereF } ``` -### BoxFExtent +### BoxExtentF Access aligned box for fast frustum culling. Interface implementations not included for brevity. +* Must include the same members as mentioned in the Generic Math proposal in the `Geometric Types` section + ```csharp +public struct BoxExtentF + : IEquatable> + , IEqualityOperators, BoxExtentF, bool> + , IIntersectWithRay, TScalar> + , IIntersectWithPlane, TScalar> + , IColliderShape, TScalar> + , IContainPoint, TScalar> + , IIntersect, BoxExtentF> + //Implement IIntersect for other shapes + , IContain, BoxExtentF> + //Implement IContain for other shapes + , IFormattable + where TScalar : IBinaryFloatingPointIeee754 +{ + public Vector3F Center; + public Vector3F Extents; + + public BoxExtentF(BoxF box); + public BoxExtentF(Vector3F minimum, Vector3F maximum); + + public static explicit operator BoxF(BoxExtentF boxExtent); + public static explicit operator BoxExtentF(BoxF box) +} ``` @@ -189,6 +214,8 @@ Access aligned box for fast frustum culling. Interface implementations not inclu Box with orientation. Interface implementations not included for brevity. +* Must include the same members as mentioned in the Generic Math proposal in the `Geometric Types` section + ```csharp public struct OrientedBoxF : IEquatable> @@ -204,7 +231,11 @@ public struct OrientedBoxF , IFormattable where TScalar : IBinaryFloatingPointIeee754 { + public Vector3F Center; + public Vector3F Extents; + public Quaternion Orientation; + public OrientedBoxF(Vector3F center, Vector3F extents, Quaternion orientation); } ``` @@ -246,10 +277,4 @@ public static class Frustum ``` -### CollisionHelper - -```csharp - -``` - # Meeting Agenda/Notes \ No newline at end of file From ed05289ddb718a9f8c49afda9bd2a51a82cde27f Mon Sep 17 00:00:00 2001 From: Daniel Keenan Date: Sat, 30 Nov 2024 21:15:15 +1000 Subject: [PATCH 25/25] Rename additional math type proposals to WIP --- ...e.md => (WIP) Proposal - 3.0 Additional math types - Angle.md} | 0 ... => (WIP) Proposal - 3.0 Additional math types - Collision.md} | 0 ...r.md => (WIP) Proposal - 3.0 Additional math types - Color.md} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename documentation/proposals/{Proposal - 3.0 Additional math types - Angle.md => (WIP) Proposal - 3.0 Additional math types - Angle.md} (100%) rename documentation/proposals/{Proposal - 3.0 Additional math types - Collision.md => (WIP) Proposal - 3.0 Additional math types - Collision.md} (100%) rename documentation/proposals/{Proposal - 3.0 Additional math types - Color.md => (WIP) Proposal - 3.0 Additional math types - Color.md} (100%) diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Angle.md b/documentation/proposals/(WIP) Proposal - 3.0 Additional math types - Angle.md similarity index 100% rename from documentation/proposals/Proposal - 3.0 Additional math types - Angle.md rename to documentation/proposals/(WIP) Proposal - 3.0 Additional math types - Angle.md diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Collision.md b/documentation/proposals/(WIP) Proposal - 3.0 Additional math types - Collision.md similarity index 100% rename from documentation/proposals/Proposal - 3.0 Additional math types - Collision.md rename to documentation/proposals/(WIP) Proposal - 3.0 Additional math types - Collision.md diff --git a/documentation/proposals/Proposal - 3.0 Additional math types - Color.md b/documentation/proposals/(WIP) Proposal - 3.0 Additional math types - Color.md similarity index 100% rename from documentation/proposals/Proposal - 3.0 Additional math types - Color.md rename to documentation/proposals/(WIP) Proposal - 3.0 Additional math types - Color.md