rotation - 特征,链接平移和旋转
问题描述
在 Eigen3 中,我需要先进行旋转,然后再进行平移。
请注意,转换设置为身份以正确重置其值。
我可以这样做,但旋转改变了参考轴,我的翻译是错误的。
auto transform_rotation ( Transform <double, 3, Affine> &t, const double rotate_x, const double rotate_y, const double rotate_z )->void {
if ( rotate_x ){
auto p = AngleAxisd( rotate_x, Vector3d::UnitX() );
t *= p.matrix();
}
if ( rotate_y ){
auto p = AngleAxisd( rotate_y, Vector3d::UnitY() );
t *= p.matrix();
}
if ( rotate_z ){
auto p = AngleAxisd( rotate_z, Vector3d::UnitZ() );
t.rotate( p.matrix() );
}
}
auto transform_translation ( Transform <double, 3, Affine> &t, const double translate_x, const double translate_y, const double translate_z )-> void {
auto n = Translation3d( translate_x, translate_y, translate_z );
// t.translate( n.translation() );
t *= n;
}
当旋转发生时,对应于该点的新旋转进行以下平移。
我想要一致的 x、y 和 z 轴。我认为我的旋转功能把一切都搞砸了。
我想要什么:如果我需要应用 az 旋转,比如 90°,然后在 x 轴上平移 5 个单位,我应该有以下代码:
...
Transform<double,3,Affine> t;
t.setidentity();
transform_rotation(t, 0,0,(90 * M_PI / 180);
transform_translation(t, 5,0,0);// right now, I must do (t, 0,-5,0);
..
Vector3d point{1,1,0};
point *= t;
...
我怎样才能做到这一点 ?我错过了什么?谢谢
2021 年 10 月 29 日更新
好的,我终于得到了这样的代码:
auto y = Translation3d(vector1.x(), vector1.y(), 0);
auto z = AngleAxisd( angle, Vector3d::UnitZ() );
t = y * z;
它有效。没有我想的那么干净,但就是这样。。
解决方案
推荐阅读
- android - 有没有办法直接通知服务器设备注册 ID 的更改?
- javascript - 无法使用角度从资产文件夹中检索 json 数据
- php - 如果一个变量不为空,则将两个 PHP 变量合二为一
- javascript - react-ga:在执行“ReactGA.pageview”或“ReactGA.event”之前,每次都需要运行“ReactGA.initialize”
- android - WebRTC android-PeerConnectionFactory.createPeerConnection 总是返回 null
- node.js - 如何在电子更新器中下载期间在窗口中显示进度条
- android - 如何使用 GoogleMap 颤振在 2 个标记之间绘制路径 *不使用 MapView* 使用 GoogleMap 颤振
- build.gradle - 从 Teamcity 发布到 Artifactory 后 RPM 包名称更改
- spring - RuntimeException:必须提供 MemberAccess 实现
- c# - 如何并行化这个 C# 算法?