PCL點雲旋轉(平面引數)

2021-10-05 13:36:57 字數 2229 閱讀 8452

實現根據輸入平面引數(標準式),基於旋轉矩陣 旋轉點雲到xy面的功能

旋轉矩陣

#include

"stdafx.h"

#include

#include

#include

#include

#include

#include

#include

/*輸入輸入點雲,輸出點雲位址和分割平面方程,返回旋轉完的點雲,可直接xy面z軸0值分割*/

pcl::pointcloud<:pointxyzrgba>

rotate

(pcl::pointcloud<:pointxyzrgba> input,

double a,

double b,

double c, pcl::pointcloud<:pointxyzrgba>

&transformed_cloud)

-> 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)

method #1: using a matrix4f

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

*/ eigen::matrix4f transform_x = eigen::matrix4f::

identity()

;/* x轉移矩陣

|1 0 0 |

|0 cos -sin |

|0 sin cos |

*/double cosx, sinx;

double dis =

sqrt

(pow

(a,2)+

pow(b,2)

+pow

(c,2))

; cosx =

sqrt

(pow

(a,2)+

pow(c,2)

)/dis;

sinx = b / dis;

transform_x(1

,1)= cosx;

transform_x(1

,2)=

-sinx;

transform_x(2

,1)= sinx;

transform_x(2

,2)= cosx;

eigen::matrix4f transform_y = eigen::matrix4f::

identity()

;/* y轉移矩陣

PCL點雲庫 平面模型分割

平面模型分割是採用隨機取樣一致性對點雲擬合出乙個平面,將點到該平面的距離小於 距離閾值 的點都作為內點,大於 距離閾值 的點都作為外點。可以通過設定引數選擇保留內點還是外點。平面模型分割 include include include include intmain int argc,char ar...

PCL將點向平面投影

include include include include include include int main int argc,char ar system pause return 0 這個 就是實現的是 將已知點向指定平面投影,可以計算出投影之後的點的座標 pcl projectinlier...

PCL點雲索引

點雲索引其實就是將點雲中不同點加上標籤,方便後面的分類提取。有了點雲的索引值可以方便的對點雲進行不同操作 以下舉例說明 1.儲存一點雲中某些特定的點 pcl pointcloudcloud new pcl pointcloud 輸入點雲 pcl io loadpcdfile pcd cloud pc...