-
Notifications
You must be signed in to change notification settings - Fork 24
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
No matrix multiplication? #27
Comments
Thanks for bringing this up. I did look at this when implementing it, the issue is that we want to provide a consistent API so splitting the method into two wasn't a very nice solution. I never revisited this after the initial work so it never got resolved. I'd be happy to look at a PR with this. It should probably be part of in with |
Yes, I see the reasoning behind that. I can work up a PR that uses the same method for both vectors and matrices; dispatching based on the argument type. |
Upon closer inspection, vectors and matrices are just generic objects, which makes it difficult to distinguish between them. Any reason why they haven't been implemented as prototype-based JavaScript objects? |
I think a suitable way of checking for a matrix would be something like this: function isMatrix(obj) {
if (
!obj.size
|| obj.size.length !== 2
|| !obj.data
) {
return false;
}
return obj.size[0] === obj.data.length
&& obj.size[1] === obj.data[0].length;
} If the size property matches what we expect in data, I think we can treat it as a matrix. |
To answer your question, no, there's no real reason. They are attached to the p5 prototype, so you can create them with Feel free to take a look at the interface shown in the TS source |
Why does the library not provide matrix multiplication? It seems kind of fundamental. Here is a simple implementation:
The text was updated successfully, but these errors were encountered: