Tyler Shellberg
Tyler Shellberg

Reputation: 1356

Boost rotation matrix no match for operator *

I am trying to rotate a vector based on another orientation vector. Elsewhere in the code, this works fine. But here, it fails and Boost complains about an operator error.

  // (Assume these vectors are filled with useful values)
  boost::qvm::vec<double, 3> aspectVec;
  boost::qvm::vec<double, 3> orientation;

  // Rotate aspect into world coords
  // Note, orientation already in radians
  auto rot = boost::qvm::rot_mat_zyx<3>( orientation.a[2],
                                         orientation.a[1],
                                         orientation.a[0]);

  boost::qvm::vec<double, 3> aspectRotated;
  aspectRotated = boost::qvm::normalized(rot * aspectVec);

The specific error I get is:

myfile.cpp:391: error: no match for ‘operator*’ (operand types are ‘boost::qvm::qvm_detail::rot_mat_<3, double>’ and ‘boost::qvm::vec<double, 3>’)
  391 |   aspectRotated = boost::qvm::normalized(rot * aspectVec);
      |                                          ~~~ ^ ~~~~~~~~~
      |                                          |     |
      |                                          |     boost::qvm::vec<double, 3>
      |                                          boost::qvm::qvm_detail::rot_mat_<3, double>

But I don't understand why. In another file, I have an identical line and it works flawlessly. I'm wondering if it's somehow a missing include? I have both ones I thought were relevant:

#include <boost/qvm/mat_operations.hpp>
#include <boost/qvm/vec_operations.hpp>

Upvotes: 1

Views: 165

Answers (1)

Tyler Shellberg
Tyler Shellberg

Reputation: 1356

The issue was the includes. I noticed they were the only difference in the code between the two files. I swapped out:

#include <boost/qvm/mat_operations.hpp>
#include <boost/qvm/vec_operations.hpp>

For:

#include <boost/qvm/all.hpp>

And the problem went away. I'm not really sure why, but it did. I don't like including more than necessary, so if anyone knows a sub-set of this that is more appropriate, please let me know.

Upvotes: 2

Related Questions