首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将特征Affine3d转换为Affine2d

将特征Affine3d转换为Affine2d
EN

Stack Overflow用户
提问于 2013-04-23 20:50:44
回答 1查看 3.2K关注 0票数 2

我有一个3D格式的affine transform,我希望丢弃中的任何z轴信息。有没有一种从Affine3dAffine2d的便捷转换方法

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-23 22:34:54

尝试以下操作:

代码语言:javascript
运行
复制
Affine2d S2d = Translation2d(S3d.translation().topRows<2>()) *
               S3d.linear().topLeftCorner<2,2>();

演示:

代码语言:javascript
运行
复制
#include <Eigen/Dense>
#include <iostream>
#include <string>

int main()
{
    using namespace Eigen;
    using namespace std;

    Vector3d p3d(1.,2.,3.);
    cout << p3d << endl << endl;
    Affine3d S3d = Translation3d(2.,2.,2.)*Scaling(3.,2.,5.);
    Vector3d scalled = S3d*p3d;
    cout << S3d.matrix() << endl << endl;
    cout << scalled << endl << endl;

    cout << string(16,'_') << endl;

    Vector2d p2d = p3d.topRows<2>();
    cout << p2d << endl << endl;
    Affine2d S2d = Translation2d(S3d.translation().topRows<2>()) *
                   S3d.linear().topLeftCorner<2,2>();
    Vector2d scalled2d = S2d*p2d;
    cout << S2d.matrix() << endl << endl;
    cout << scalled2d << endl << endl;
}

输出:

代码语言:javascript
运行
复制
1
2
3

3 0 0 2
0 2 0 2
0 0 5 2
0 0 0 1

5
6
17

________________
1
2

3 0 2
0 2 2
0 0 1

5
6
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16169811

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档