Skip to content

Generic Math.md: Restrict lerp function to F matrices. #2462

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update Proposal - Generic Math.md
  • Loading branch information
otac0n authored Jun 26, 2025
commit 40bd85e2c9f8e989e51a8e45a93a84fded59f0cd
5 changes: 3 additions & 2 deletions documentation/proposals/Proposal - Generic Math.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ This API aims to replace the existing implementation of Silk.NET.Maths.
- If any of the APIs contained herein are later deemed mathematically invalid in the context of their exposing primitive (e.g. a specific operation being inappropriate for a specific sized matrix), the Silk.NET team reserves the right to remove them at their own accord.

# **INFORMATIVE** Integer and Floating Point Types
While investigating the use of generic math we came to the conclusion that making types which supports both integer and floating point types would not be optimal. This was discussed at length on the discord [here](https://discord.com/channels/521092042781229087/587346162802229298/1167705816812498974). Ultimately it was decided to provide both an integer and floating point variant for each vector type and every type built from them. These types are generic where `Vector2I<T>` will be a 2D vector which takes any binary integer type for `T`. Similarly `Vector2F<T>` will be a 2D vector which takes any floating point type for `T`. By extension we get types like `BoxI<T>` and `RectangleF<T>`. The integer types are granted the bitwise operators `&`, `~`, `|`, and `^`. Floating point types will include some operations that require certain functions unavailable to integer types like `Length` which requires `Sqrt`.
While investigating the use of generic math we came to the conclusion that making types which supports both integer and floating point types would not be optimal. This was discussed at length on the discord [here](https://discord.com/channels/521092042781229087/587346162802229298/1167705816812498974). Ultimately it was decided to provide both an integer and floating point variant for each vector type and every type built from them. These types are generic where `Vector2I<T>` will be a 2D vector which takes any binary integer type for `T`. Similarly `Vector2F<T>` will be a 2D vector which takes any floating point type for `T`. The I/F types would share a common interface hierarchy. By extension we get types like `BoxI<T>` and `RectangleF<T>`. The integer types are granted the bitwise operators `&`, `~`, `|`, and `^`. Floating point types will include some operations that require certain functions unavailable to integer types like `GetLength` which requires `Sqrt`.
Whenever possible (e.g. other than operators), methods should be added via extension methods and these types should behave as simple containers. This allows users to properly extend the functionality when providing custom `INumber<T>` types.

# I types versus F Types
Each type in this proposal, aside from `Quaternion`, 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<T>`. On the other hand, floating point types **must** use a generic type argument `T` with the constraint of `IFloatingPointIeee754<T>`.
Expand All @@ -44,7 +45,7 @@ For each vector struct, the following requirements **must** fulfill the followin
- Constructors for 3 dimensions and up **must** include lower dimension variants that use the lower dimensions for their specific components (vector2 -> X,Y).
- A ref indexer that takes a int index and returns the corresponding component value (0 -> x, 1 -> y, etc.)
- An AsSpan function which returns this vector as a Span of the generic type
- A LengthSquared property which returns the dot product of the vector with itself.
- A GetLengthSquared extension method which returns the dot product of the vector with itself.
- A Dot extension method which takes another vector and returns the dot product with our original vector.
- For 3D Vectors, a Cross extension method which takes another vector and returns the cross product with our original vector.
- `+`, `-`, `*`, `/`, and `%` operators defined between two vectors of the same type which returns a vector which has had each operation applied component-wise.
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy