Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The order of matrix multiplication is different in ign-math4 and ign-math6 #190

Closed
erdisayar opened this issue Feb 11, 2021 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@erdisayar
Copy link

Hello,
I tested matrix multiplication operator in both math4 and math6 library and I obtained 2 different results.
image
image

The the first test is in Gazebo9(Ubuntu 18.04) using math4 library. Here is my result.
image

I think it is wrong because it is not the calculation of MatrixA x MatrixB instead MatrixB x Matrix A. However the intention is MatrixA x Matrix B

If I test the same code in Gazebo11(Ubuntu 20) using math6 library. Here is the result
image
The result is correct.

summary from my investigation is(maybe I am wrong)

If I want to calculate the matrix multiplication of AB,

  • math4 library calculates BA instead of AB
  • math6 library calculates AB

Here is the code in the picture.

std::cout << "Matrix A " << std::endl;
WORLD_POSE MatrixA = WORLD_POSE(1, 0, 0, 0, 0, 0);
std::cout << "Matrix A Pos:" << MatrixA.Pos() << std::endl;
std::cout << "Matrix A Rot:" << MatrixA.Rot() << std::endl;
std::cout << "Matrix B" << std::endl;
WORLD_POSE MatrixB = WORLD_POSE(0, 0, 0, 0, 0, 1);
std::cout << "Matrix B Pos:" << MatrixB.Pos() << std::endl;
std::cout << "Matrix B Rot:" << MatrixB.Rot() << std::endl;
std::cout << "----------" << std::endl;
std::cout << "Matrix C = A * B " << std::endl;

WORLD_POSE MatrixC = MatrixA * MatrixB;
std::cout << "Matrix C Pos:" << MatrixC.Pos() << std::endl;
std::cout << "Matrix C Pos:" << MatrixC.Rot() << std::endl;
std::cout << "----------" << std::endl;
@erdisayar erdisayar added the bug Something isn't working label Feb 11, 2021
@erdisayar
Copy link
Author

Here is the image for comparison
image

@chapulina
Copy link
Contributor

I wrote a quick test to check Matrix4 multiplication in #191 and I couldn't see any inconsistencies between ign-math4 and ign-math6.

Note that your example is using ignition::math::Pose3d, not ignition::math::Matrix4d. The behaviour of the * operator for Pose3 has been changed (fixed) from ign-math4 to ign-math5, as documented on the migration guide. I believe that's the underlying reason for what you're seeing.

@erdisayar
Copy link
Author

erdisayar commented Feb 11, 2021

Thanks for enlightening the issue. What kind of behavior did you implemented before (for ign-math4) ? and what was the its logic?

As you see from my calculations for ign-math4 , the behavior I saw is basically same as reverse order matrix multiplication for ignition::math::Pose3d.

In other words, What was the use case before?

@scpeters
Copy link
Member

I don't know why it was this way. You can read more of the history in #60 and bitbucket PR 301. I'm closing since this is not a bug, but feel free to continue the discussion if you like

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants