lua-users home
lua-l archive

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


Panagiotis Vossos wrote:
> Has anybody written a srfi-4-like
> (http://srfi.schemers.org/srfi-4/srfi-4.html) 
> library for lua?
> 
> Some more context:
> 
> I have already embedded lua in one C++ project and the results were
> stellar. 
> After trying out guile, chicken, mzscheme, gambit-c, tcl, python and
> ruby, it was refreshing to find a language that doesn't suck _and_ is
> easy to embed.  
> PiL2 is such a joy to read, full of great ideas on language design,
> in some ways it reminds me the scsh manual. 
> 
> I am now trying to use the lua repl as the glue between various
> numeric / geometric libraries.   While writing bindings, I came to
> realize that it would be great if there was a semi-standard way to
> manipulate homogeneous vectors from lua.  Such a library should be
> accessible from both lua and C and would simplify the writing of glue
> code.   
> 
> Possible solutions I've already thought of:
> 
> 1) Avoid homogeneous vectors, just convert before and after the C
> function to lua tables.  This method works, but is not optimal when
> you're writing a binding for BLAS/LAPACK and you have *huge* vectors.
> 
> 2) Writing such a srfi-4 like library is easy, just go ahead and
> write it.  In that case, it would be nice to avoid duplication.  I am
> thinking of starting such a project, should not take much time to
> wrap the 10 datatypes from srfi-4 and provide both C & lua apis. 
> Would anybody be interested in such code?    
> 
> 3)  A library like that already exists / there is a better way.  In
> that case, can you share some pointers / ideas ? 

I wrote a geometric datatype library for Lua. It includes 3D vectors, 3D homogeneous vectors, quaternions, 3D matrices and 3D homogeneous matrices, with some operations between these types (conversions, tranformation application), and import/export from/to tables or lists (à la unpack). It does only have a single underlying datatype (currently float, but it started as double, so it should be easy to use yet another type). It does have some preliminary animation/interpolation functions too.

I use it for a little 3D game engine, and various data generation/analysis tools. If you don't find anything better and want to have a look I can give you the source code.