p5.dimensions.js icon indicating copy to clipboard operation
p5.dimensions.js copied to clipboard

Running list of p5.dimensions Errors

Open max0410 opened this issue 8 years ago • 12 comments

Current Errors:

nVector function: "P5JS ERROR: Too many dimensions were entered!" nCross function: "P5JS ERROR: Vectors must be 3 dimensional!"

max0410 avatar Jan 15 '17 16:01 max0410

I had a look at the source and I have a couple questions about the errors above.

  1. 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.
  2. 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?

limzykenneth avatar Feb 13 '17 07:02 limzykenneth

  1. 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.

  2. 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.

Smilebags avatar Feb 13 '17 10:02 Smilebags

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.

max0410 avatar Feb 13 '17 21:02 max0410

Yeah, let's consider it for v2.0.0 since it will change (and potentially break) how people might use v1.

Smilebags avatar Feb 13 '17 22:02 Smilebags

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.

limzykenneth avatar Feb 15 '17 10:02 limzykenneth

Yes, I agree with your point. I will remove it.

Smilebags avatar Feb 15 '17 10:02 Smilebags

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.

max0410 avatar Feb 15 '17 19:02 max0410

Here it is, 7d cross product: https://wikimedia.org/api/rest_v1/media/math/render/svg/ea0c8e2dcf0bae8fcece1f46080d88db9b447eb7

max0410 avatar Feb 15 '17 19:02 max0410

Hmm interesting! Does it work in 5?

Smilebags avatar Feb 15 '17 22:02 Smilebags

If it works in all odd dimensions it makes it still useful and out of the scope of p5's cross function.

Smilebags avatar Feb 16 '17 11:02 Smilebags

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.

max0410 avatar Feb 17 '17 03:02 max0410

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.

Smilebags avatar Feb 17 '17 03:02 Smilebags