Smilebags / p5.dimensions.js

An addon for p5.js which adds support for higher dimensional calculations.
72 stars 24 forks source link

Running list of p5.dimensions Errors #13

Open max0410 opened 7 years ago

max0410 commented 7 years ago

Current Errors:

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

limzykenneth commented 7 years ago

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?
Smilebags commented 7 years ago
  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.

max0410 commented 7 years ago

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.

Smilebags commented 7 years ago

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

limzykenneth commented 7 years ago

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.

Smilebags commented 7 years ago

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

max0410 commented 7 years ago

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 commented 7 years ago

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

Smilebags commented 7 years ago

Hmm interesting! Does it work in 5?

Smilebags commented 7 years ago

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

max0410 commented 7 years ago

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.

Smilebags commented 7 years ago

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.