AngleAxisToRotationMatrix and AngleAxisRotatePoint give different results?

300 views
Skip to first unread message

Mike Wu

unread,
May 14, 2018, 8:40:38 PM5/14/18
to Ceres Solver
I have the following code

int main(int argc, char **argv) {
    double angle = 60 * M_PI / 180;
    double axis[3] = {0, 0, 1 / angle};
    double r[9];
    ceres::AngleAxisToRotationMatrix(axis, r);

    double pt[3] = {1,1,1};
    double pt_rotate[3];
    ceres::AngleAxisRotatePoint(axis, pt, pt_rotate);

    double pt_rotate_matrix[3];
    for (int i = 0; i < 3; ++i) {
        pt_rotate_matrix[i] = pt[0] * r[i * 3] + pt[1] * r[i * 3 + 1] + pt[2] * r[i * 3 + 2];
        LOG(INFO) << "diff i: " << pt_rotate_matrix[i] - pt_rotate[i];
    }
}

and they output 

I0514 17:21:13.835876  6115 localizer.cpp:230] diff i: 1.63255
I0514 17:21:13.836115  6115 localizer.cpp:230] diff i: -1.63255
I0514 17:21:13.836140  6115 localizer.cpp:230] diff i: 0

Is this a bug or I'm not using the functions correctly?

Sameer Agarwal

unread,
May 14, 2018, 8:51:13 PM5/14/18
to ceres-...@googlegroups.com
The rotation matrix is column major, you are interpreting it as row-major.
Sameer


--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/4ac44c3e-c71c-421d-bb04-89f5537c74ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Wu

unread,
May 14, 2018, 11:39:14 PM5/14/18
to Ceres Solver
Ah that explains it. Thanks for the reply. BTW is it documented anywhere?

Sameer Agarwal

unread,
May 14, 2018, 11:40:23 PM5/14/18
to ceres-...@googlegroups.com
It is documented in the header file, but the docs can be better.

Reply all
Reply to author
Forward
0 new messages