lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


is there any library or facility in Lua for working with 2D euclidean vectors?
I think of functions for getting (euclidean) distance, sum of two vectors, scalar multiplication, scalar product, transformation to and from polar coordinates and such.
I know these are not particularly difficult to implement, but i'd rather not reinvent the wheel.

Also, how would a 2D vector be defined most efficiently?
As a table with two entries, "x" and "y" ?

In my C code i have this kind of data structures:
struct VECTOR {
and i need to pass them to Lua and back.

These are part of larger data structures.
Am i right that i would need to pass the vectors as tables (inside other tables, possibly inside other tables, ...)?

Lars R.