-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[p5.js 2.0] Vector n-dimentional and Matrix Interface #7405
Conversation
@limzykenneth @davepagurek my previous PRs were very outdated and getting lots of conflicts with the recent refactors, so I created a clean one updated with my latest changes, I'm also experimenting with an abstract class implementation for the |
I only have one test error that I can't figure out when doing the abstraction: It might be because the new Matrix abstraction has no access to p5, but I don't see why the 'connect' method would be related.
|
@holomorfo It cannot read |
Test seems to pass on CI still so perhaps it's not a problem at this stage. |
@davepagurek @limzykenneth I also simplified the API (I believe its simpler, let me know) in the sense that we don't need to have an extra static for identity, I believe is simpler if the user specifies Also now we don't need to specify 'mat3' or 'mat4' in the constructor, we can just specifiy the desired dimention, this is great for generalization. In the consuming components like renderer, camera or geometry I have kept access to mat3 and mat4 only as a getter. |
@holomorfo Is this ready for merge? I can fix the conflicts so don't worry about that, just that all your work has been pushed here. Also do we still need #7277? |
Hi Ken, yes, this PR is ready for merging, I have added a tentative inline documentation, we can continue working on that. Also I have closed #7277 since all changes are here now. I have fixed the test and all pass in local also, even the parameters one that was failing before. |
Resolves #6765
Related conversation on closed PR #7277
@davepagurek @limzykenneth @ksen0
Summary of Changes
This pull request introduces significant improvements to matrix handling in p5.js, enabling more generalized and flexible n-dimensional matrix operations.
Generalized Matrix Class
Matrix
class to replacemat3
andmat4
, supporting matrices of any dimensionality.New
MatrixInterface
FileEnhanced Functionality
add
, for manipulating matrices in n-dimensional space.Integration with p5.js
mat3
andmat4
, enabling scalable matrix support.These changes establish a robust foundation for advanced matrix operations in p5.js and improve its versatility for mathematical and graphical applications.
I have added new inline documentation for the new methods. Here I share the analysis of the pending methods to update and some questions/challenges I'm facing:
Vector Class Changes
Support for N-Dimensional Vectors
New Features
Code Refactoring
Vector methods details
Some vector methods remain 4 or 3 dimensional to retain compatibility with the existing api.
Check dimensions?YESComment from Ken regarding serializationDONE Pending more general serialization.Need to set dimension also?Yes, DONEOnly 3D for now
Updated working for scalar, vector and array, question about different dimension vectors, how should it be handled? should we only divide what is possible and leave the rest unchanged? For example, what to do in this case
[1,2,3]/[8,9]
should it be:[1/8,2/9,3]
or in the other case[8,9]/[1,2,3] =? [8/1, 9/2]
? I've not seen this implementation or inference in any other mathematics library or in general. @limzykenneth @davepagurekNeeds determinantOnly 2D for nowwhy is it call setMag?
maybe because it does it in place
Check
_fromRadians
Only for 2D
Only for 2D
needsonly 3D for nowcross
to be nDProblem with inference of last value being amount for NDOnly 3d for NowProblem with inference of last value being amount for NDOnly 3d for NowIn theory this should return only
this.values
however, this breaks some functionality on the test " p5.RendererGL > color interpolation > geometry with stroke colors use their colors" because of the default always returning a 3 elements array, will retain ad 3D for now but will re-visit_clampToZero
Static methods
Needs module NDOnly 3D for nowneeds rotate NdOnly 3D for nowSee comments in the non static method.
PR Checklist
npm run lint
passes