math3d-react
math3d-react copied to clipboard
Document and beautify cross product for vectors
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.
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..."
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!
More things I can't quite find:
- Any way to see something's type? (useful when things aren't working as expected and I want to see what's going on)
- 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.
- 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)
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.
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:
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.
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).
(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)