Math library for c-externals


    Oct 23 2020 | 1:42 pm
    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

    • Oct 26 2020 | 10:32 pm
      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
    • Oct 27 2020 | 9:02 am
      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
    • Dec 12 2020 | 9:36 am
      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 */ }