Forums > MaxMSP

[Sharing] Vector Math with Lua

May 22, 2012 | 1:13 pm

Hi everyone

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! :)

– Pasted Max Patch, click to expand. –
Attachments:
  1. vectorMath.lua

May 26, 2012 | 2:03 pm

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:

create a vector:

– Pasted Max Patch, click to expand. –

getting a cross out of two vectors:

– Pasted Max Patch, click to expand. –

calc the length of a vector:

– Pasted Max Patch, click to expand. –

get the normalized vector:

– Pasted Max Patch, click to expand. –

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

– Pasted Max Patch, click to expand. –

May 26, 2012 | 2:13 pm

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

Many thanks in advance


Viewing 3 posts - 1 through 3 (of 3 total)