[Sharing] Vector Math with Lua

mark2e's icon

Hi everyone

Max Patch
Copy patch and select New From Clipboard in Max.

I was always searching for a simpler way to do vector operations (cross product, dot, length, normalize). And today I found my answer lying within lua. This is my first lua script and (as others already pointed out), it was way easier than I first expected.
I also added an identifier for easy routing. So I hope this might be useful for someone out there and I finally can give back a little something to this great community! :)

3917.vectorMath.lua
lua
maybites's icon

thank you, I was just searching for a clever way to do the same thing. my coding preferences are a bit different, so I used you patch unaltered and created the following:

Max Patch
Copy patch and select New From Clipboard in Max.

create a vector:

Max Patch
Copy patch and select New From Clipboard in Max.

getting a cross out of two vectors:

Max Patch
Copy patch and select New From Clipboard in Max.

calc the length of a vector:

get the normalized vector:

Max Patch
Copy patch and select New From Clipboard in Max.
Max Patch
Copy patch and select New From Clipboard in Max.

and last but not least a dot product out of two vectors:

jamesson's icon

I was also looking for something like this. Is it possible to get angle/direction?

Many thanks in advance