[Sharing] Vector Math with Lua

May 22, 2012 at 1:13pm

[Sharing] Vector Math with Lua

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
#63176
May 26, 2012 at 2:03pm

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. –
#227936
May 26, 2012 at 2:13pm

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

Many thanks in advance

#227937

You must be logged in to reply to this topic.