兩點云坐標點的轉(zhuǎn)化

兩點云坐標點的轉(zhuǎn)化

兩點云坐標點的轉(zhuǎn)化,就是把一個點云從自己的坐標系變換到另一個坐標系,配準,拼接都用得到。有點類似相機和激光外參的標定(將激光坐標系轉(zhuǎn)換到相機的坐標系。都是Rt變換)。

(1)基本知識

R為旋轉(zhuǎn)矩陣,X為原始點,t為平移量,X'為變換后的點(目標點)

R*X+t=X'? (Rt*X=X')

但是所求Rt矩陣用一個矩陣表示如下:

/* Reminder: how transformation matrices work :

|-------> This column is the translation

| 1 0 0 x |? \

| 0 1 0 y |?? }-> The identity 3x3 matrix (no rotation) on the left

| 0 0 1 z |? /

| 0 0 0 1 |??? -> We do not use this line (and it has to stay 0,0,0,1)

(2)舉例說明

將一個點(坐標系)繞自身z軸旋轉(zhuǎn)(正)M_PI/4,然后再沿著旋轉(zhuǎn)后得到的x軸方向(正)平移2.5。求Rt矩陣?

方法1:

直接數(shù)學(xué)方法得到并賦值:

METHOD #1: Using a Matrix4f

This is the "manual" method, perfect to understand but error prone !

*/

Eigen::Matrix4f transform_1 = Eigen::Matrix4f::Identity();

// Define a rotation matrix (see https://en.wikipedia.org/wiki/Rotation_matrix)

float theta = M_PI/4; // The angle of rotation in radians

transform_1 (0,0) = cos (theta); //第1行第1列個元素

transform_1 (0,1) = -sin(theta); //第1行第 2 列個元素

transform_1 (1,0) = sin (theta);

transform_1 (1,1) = cos (theta);

//??? (row, column)

// Define a translation of 2.5 meters on the x axis.

// transform_1 (0,3) = 2.5;

transform_1 (0,3) = 0;

// Print the transformation

printf ("Method #1: using a Matrix4f\n");

std::cout << transform_1 << std::endl;

方法2:

通過程序計算矩陣:

/*? METHOD #2: Using a Affine3f

This method is easier and less error prone

*/

Eigen::Affine3f transform_2 = Eigen::Affine3f::Identity();

// Define a translation of 2.5 meters on the x axis.

transform_2.translation() << 2.5, 0.0, 0.0;

// The same rotation matrix as before; theta radians arround Z axis

transform_2.rotate (Eigen::AngleAxisf (theta, Eigen::Vector3f::UnitZ()));

// Print the transformation

printf ("\nMethod #2: using an Affine3f\n");

std::cout << transform_2.matrix() << std::endl;

最后轉(zhuǎn)化:

pcl::transformPointCloud (*source_cloud, *transformed_cloud, transform_2);

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 手帳day7打卡,晚上和同學(xué)吃了火鍋,超級爽~ 唯一不爽的是就顧著吃了,沒拍照,回到家做手帳不知道怎么畫,菜單也沒...
    來自galaxy的叮叮鐺閱讀 1,033評論 0 3
  • 在一小院子中出生,不知父母,每天自己讀書,畫畫。 院外有樹,風(fēng)一動就簌簌作響,總會下雨,黑瓦白墻叮叮當當。 每到逢...
    想名字想半天閱讀 304評論 0 0
  • 我一直想養(yǎng)成每天記賬的習(xí)慣,不知算不算一種強迫癥?記賬,是為了了解每一筆開銷去了哪里,到月底一看,什么地方花費多少...
    安桐2016閱讀 1,262評論 1 1

友情鏈接更多精彩內(nèi)容