math3d-react icon indicating copy to clipboard operation
math3d-react copied to clipboard

Document and beautify cross product for vectors

Open NeatNit opened this issue 5 years ago • 5 comments

Maybe I'm missing something, but I can't find a way to get the cross-product of 2 vectors. Couldn't find any mention of it anywhere, either.

NeatNit avatar Jun 25 '19 15:06 NeatNit

Well, it's not pretty, but you can do cross(a, b) where a and b are three-component vectors (e.g., [1,2,3]).

Math3d definitely needs better docs for this sort of thing (and it should be prettier!).

Edit: Let me know if this doesn't work for you. Also, I'm going to change the issue title to "Document and beautify..."

ChristopherChudzicki avatar Jun 25 '19 15:06 ChristopherChudzicki

Oh. Damn. When I typed "cross" and it didn't even change font to look like a function, I just assumed it wasn't defined.

Shouldn't the "recognized functions become non-italic" thing be universal? I wouldn't expect it to have to be coded separately from where functions are defined.

So yup - document and beautify!

NeatNit avatar Jun 25 '19 16:06 NeatNit

More things I can't quite find:

  1. Any way to see something's type? (useful when things aren't working as expected and I want to see what's going on)
  2. Any way to get a vector's length, other than sqrt(dot(V,V))? I've tried len[gth], size - none seem to be it.
  3. Speaking of which, what does size give? It is recognized but I can't figure out what it outputs (again, seeing something's type would help here)

NeatNit avatar Jun 25 '19 16:06 NeatNit

Shouldn't the "recognized functions become non-italic" thing be universal?

Probably. I'll try to explore that soon...I made #194 to track it.

Any way to see something's type? (useful when things aren't working as expected and I want to see what's going on)

That's a great idea. Do you have an idea for a user interface for that feature? Maybe just adding it to the tooltip messages? Something like "Expected function to return a number, but it returned a WHATEVER TYPE". That probably wouldn't be too hard. Screen Shot 2019-06-25 at 12 42 24 PM

Any way to get a vector's length, other than sqrt(dot(V,V))? I've tried length], size - none seem to be it.

I believe that norm(V) will get you what you want.

Most of Math3d's function scope comes directly from mathJS, so almost anything they define is available.

There should definitely, definitely be a more friendly way of doing this (really, that's the whole point of Math3d.org) but if you're curious, you can open your browser's developer console (Option+Command+I in chrome on macs) and type math to see the available functions: Screen Shot 2019-06-25 at 12 50 56 PM

So size does whatever MathJS's size function does. Apparently it gives the dimensions of a matrix. So size([[1,2,3], [4,5,6]]) gives [2, 3] for 2 rows and 3 columns.

ChristopherChudzicki avatar Jun 25 '19 16:06 ChristopherChudzicki

Thank you, that helps a ton.

That's a great idea. Do you have an idea for a user interface for that feature? Maybe just adding it to the tooltip messages? Something like "Expected function to return a number, but it returned a WHATEVER TYPE". That probably wouldn't be too hard.

Well, the main (only?) place this would be useful is to see the type of a "Variable or Function". Once it's defined, you can either have it written somewhere in the box (see the horrible mock-up) or make it show the type when you mouse over the box (very convenient on PC since there's less clutter, but bad for mobile and tablets where it's inaccessibly).

image

(I randomly guessed that "vector[3]" is how the type is called, I don't care what it actually says as long as it helps me debug my stuff)

NeatNit avatar Jun 25 '19 18:06 NeatNit