lundi 9 septembre 2019

How to multiply a matrix by a vector in c++ library gmtl

I'm trying to multiply a matrix by a vector in the C++ library GMTL.

The code for the multiplication is this:

  Matrix33f alpha = Matrix33f();
  Vec3f beta = Vec3f(0, 0, 0);
  for(Vertex* vertex : V){
    alpha += gmtl::make<Matrix33f>(gmtl::make<gmtl::Matrix33f>(vertex->position) * gmtl::makeTrans<gmtl::Matrix33f>(vertex->coarser->position));

    alpha += gmtl::make<Matrix33f>(gmtl::make<gmtl::Matrix33f>(vertex->coarser->position) * gmtl::makeTrans<gmtl::Matrix33f>(vertex->position));

    beta += vertex->position;
  }

positions are of type Vec3f. alpha is a Matrix33f. beta is a Vec3f.

I don't know whether my math is wrong, and I'm trying to perform an invalid operation, or if the library is wrong, and I'm working with bad tools.

Unfortunately, documentation and examples seem to be kinda scant, so I haven't had much luck looking for examples of gmtl code in action.

Could someone point me to a solid Math library featuring Matrix and Vector operations? Or tell me how to use gmtl in this case?

The error I'm getting here is

src/LayoutGraph.cpp:349:11: error: no viable overloaded '+='
    alpha += gmtl::make<Matrix33f>(gmtl::make<gmtl::Matrix33f>(vertex->position) * gmtl::makeTrans<gmtl::Vec3f>(vertex->coarser->position));
    ~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I've also tried switching up the parameters in the gmtl::makeTrans template function.

Aucun commentaire:

Enregistrer un commentaire