Math library for c-externals

maybites's icon

Hi

I need to do some higher math with quaternions, vectors and matrices inside a C-external. Is there a recommended library for this purpose? Or maybe even an example that uses it?

cheers - Martin

Antoine Villeret's icon

Hi Martin,

if you're looking for some geometric tools, then there is the so-called geomtrictools library.
It's a wide range of mathematical functions applied to geometric.

cheers

antoine

maybites's icon

Hi Antoine

thanks for the link. It would have all the tools I am looking for, but

  • its a C++ library, though it probably can be used with min-dev but I don't have any experience with it - until now I developed with the max-sdk, and

  • there is no library for OSX and I am looking for a cross platform solution.

I might considering to switch to C++ development with my externals, though.

cheers

martin

jasch's icon

Hi Martin,

No need to write the entire external in C++. You can use C++ libraries in C, essentially keeping the entire external code in C and calling into the C++ library from there.

You need to wrap your external declarations (the .h file) in the extern "C" directive, then the compiler will do the right thing, i.e., compile everything as C++, except the external-code in C. ( fwiw, you need to rename the sourcefiles to *.cpp for that to work).

Then you also need a C API to interact with the C++-classes (see SO-link below).

You may ask Christian Schweizer (@zhdk) for details, and I might have some code that mixes the two lying around somewhere as well.

hth

/*j

extern "C" {
/* your external declarations here */
}