Created
January 13, 2017 14:58
-
-
Save kushalsahare/0864a590bbc5462ac5ad15596999e38b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Eigen/Geometry> | |
| #include <iostream> | |
| Eigen::Affine3d create_rotation_matrix(double ax, double ay, double az) { | |
| Eigen::Affine3d rx = | |
| Eigen::Affine3d(Eigen::AngleAxisd(ax, Eigen::Vector3d(1, 0, 0))); | |
| Eigen::Affine3d ry = | |
| Eigen::Affine3d(Eigen::AngleAxisd(ay, Eigen::Vector3d(0, 1, 0))); | |
| Eigen::Affine3d rz = | |
| Eigen::Affine3d(Eigen::AngleAxisd(az, Eigen::Vector3d(0, 0, 1))); | |
| return rz * ry * rx; | |
| } | |
| int main() { | |
| Eigen::Affine3d r = create_rotation_matrix(1.0, 1.0, 1.0); | |
| Eigen::Affine3d t(Eigen::Translation3d(Eigen::Vector3d(1,1,2))); | |
| Eigen::Matrix4d m = (t * r).matrix(); // Option 1 | |
| Eigen::Matrix4d m = t.matrix(); // Option 2 | |
| m *= r.matrix(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment