p5.dimensions.js
p5.dimensions.js copied to clipboard
Running list of p5.dimensions Errors
Current Errors:
nVector function: "P5JS ERROR: Too many dimensions were entered!" nCross function: "P5JS ERROR: Vectors must be 3 dimensional!"
I had a look at the source and I have a couple questions about the errors above.
- I see that the number of dimensions are limited by the length of the array
dimensionalSymbols
, is the 52 dimension limit arbitrarily decided by this length? Is there some way to make it truly n-dimensional? I'm just curious since I doubt anyone would need that many dimensions. - For
nCross
, I looked at the source and it seemed to be only doing cross product of 3 dimensional vectors? Are cross product of higher dimension not possible?
-
It is indeed. We picked that without much consideration (being larger than 99% of use cases will need), but I can see a better format which would work for any number of dimensions. This would change the naming format of the dimensions, so maybe that is best left for v2.0.0. My idea is to use a constructor function which takes in a number and gives an object with dimensions named x,y,z,a... aa, ab, ac... aaa, aab etc.
-
I realised after writing the function that currently there is no definition for cross products in n dimensions. Well documented in 3 dimensions, though. Strange that. Because of that I thought I should remove it, but haven't decided which is worse: obsolescence or lack of consistency.
Yea, I remember writing the constructor function (or rewriting it, I think?), I tried to implement the infinite dimensions, but it was too much of a hassle. And just recently I was looking at the code, and I thought about doing infinite dimensions. But, a lot of code depends on the dimensionSymbols variable. I may implement it later.
Yeah, let's consider it for v2.0.0 since it will change (and potentially break) how people might use v1.
Interesting, I had no idea cross product is a 3 dimension only thing! I personally think if that is the case then it probably should be removed here, not only is it already covered by p5.js (which could cause confusion I think), it isn't really benefitting from what this library is doing (which is providing useful n dimensional maths where cross is only 3 dimensions). People using this library might come to expect the nVector
object created can be used with all of the provided functions.
Yes, I agree with your point. I will remove it.
Technically you can also do cross product in 7 diemensions. When I was writing in I actually though about adding 7d cross products, but the formula is quite huge.
Here it is, 7d cross product: https://wikimedia.org/api/rest_v1/media/math/render/svg/ea0c8e2dcf0bae8fcece1f46080d88db9b447eb7
Hmm interesting! Does it work in 5?
If it works in all odd dimensions it makes it still useful and out of the scope of p5's cross function.
http://math.stackexchange.com/questions/706011/why-is-cross-product-only-defined-in-3-and-7-dimensions
I have no idea what they are saying, but they are proving that it is only defined in 3 and 7 dimensional space.
Interesting... If it gives a complex result in other dimensions it might still be useful. In which case we should probably also think about introducing complex numbers.