This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Problem multiplying two Rotation2Ds

Tags: None
(comma "," separated)
avimosher
Registered Member
Posts
3
Karma
0

Problem multiplying two Rotation2Ds

Sun Dec 28, 2014 3:18 am
Hello all,
I'm trying to write some code that needs to multiply two Rotation2D<float> variables and store the result in another Rotation2D<float>. A sample piece of code is

Code: Select all
    Eigen::Rotation2D<float> r1;                                               
    Eigen::Rotation2D<float> r2;                                               
    Eigen::Rotation2D<float> r3;                                               
    r3=r1*r2;   


However, compiling this results in the error

Code: Select all
./Eigen/src/Geometry/Rotation2D.h:78:28: error: could not convert ‘(((Eigen::Rotation2D<float>::Scalar)((const Eigen::Rotation2D<float>*)this)->Eigen::Rotation2D<float>::m_angle) + ((Eigen::Rotation2D<float>::Scalar)other.Eigen::Rotation2D<float>::m_angle))’ from ‘Eigen::Rotation2D<float>::Scalar {aka float}’ to ‘Eigen::Rotation2D<float>’
   { return m_angle + other.m_angle; }


Note that if you replace the Rotation2Ds with Quaternions, the code compiles without issue. Is this a bug, or am I doing something incorrect?

Thanks,
-Avi
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Works for me with Eigen 3.2.3 and the devel branch. I did not check with older versions.
avimosher
Registered Member
Posts
3
Karma
0
That's odd, I just downloaded 3.2.3 and tested it and get the same error. Could it be a g++ version issue? I've tried it with g++ 4.8.2 and 4.6. The command I'm running is
Code: Select all
g++ -I. test.cpp

from within the top level of the Eigen directory, and the full contents of test.cpp are

Code: Select all
#include <Eigen/Geometry>

int main()
{
    Eigen::Rotation2D<float> r1;                                               
    Eigen::Rotation2D<float> r2;                                               
    Eigen::Rotation2D<float> r3;                                               
    r3=r1*r2;   
    return 0;
}



Regards,
-Avi
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Works for me with GCC 4.6, 4.7, 4.8, 4.9 and clang. Make sure that you are really using Eigen 3.2 and not a system-wide installed version with -I path/to/eigen3.2
avimosher
Registered Member
Posts
3
Karma
0
I think I may see what's going on. In the 3.2.3 version available for download, the function "operator*" for Rotation2D is defined as follows:
Code: Select all
  inline Rotation2D operator*(const Rotation2D& other) const
  { return m_angle + other.m_angle; }


This definition won't work for my example, because the constructor that takes a Scalar as the parameter is defined as "explicit". However, in the current development source that same function is defined as
Code: Select all
  inline Rotation2D operator*(const Rotation2D& other) const
  { return Rotation2D(m_angle + other.m_angle); }

which does indeed work. Thank you for looking into this!

-Avi
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
arf, right. this has been fixed just after the 3.2.3 release, and I only tested with the 3.2 branch, not the exact 3.2.3 release. (changeset 5d9e54445535).


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]