从点云中的质心绘制矢量 [英] Draw a vector from the centroid in point cloud
问题描述
我发现了一个簇的质心和特征向量. 如何在pcl可视化器中从质心绘制矢量.
I have found the centroid and the eigenvectors of a cluster. How can I draw the vector from the centroid in pcl visualizer.
Eigen::Vector4f centroid;
Eigen::Matrix3f covariance_matrix;
// Extract the eigenvalues and eigenvectors
Eigen::Vector3f eigen_values;
Eigen::Matrix3f eigen_vectors;
pcl::compute3DCentroid(*cloud_filtered,cluster_indices[i],centroid);
// Compute the 3x3 covariance matrix
pcl::computeCovarianceMatrix (*cloud_filtered, centroid, covariance_matrix);
pcl::eigen33 (covariance_matrix, eigen_vectors, eigen_values);
_viewer->addLine<pcl::PointXYZRGB> (centroid, eigen_vectors, "line");
推荐答案
3D中的线方程可以由一个点和一个矢量定义.只需插入质心作为点(x,y,z),然后将特征向量作为其向量(i,j,k)....例如
An equation of a line in 3D can be defined by a point and a vector. Just plug in your centroid as the point (x,y,z) and the eigenvector as its vector (i, j, k) .... For example
point1 at (3, 2, -5) # your centroid
vectorA of (7i, -6j, 2k) # your eigenvector
可以定义直线的方程式
r = (3i, 2j, -5k) + S(+7i, -6j, 2)
其中变量S自由连续变化(S = -4.9或S = 0.03的样本值)以确定沿线的各个点.例如,S为0会给您您的质心点,而S = 1会给您在(10i,-4j,-3k)的同一行上的另一个点
where variable S freely varies continuously (sample value of S = -4.9, or S = 0.03) to determine various points along your line. For example S of 0 gives you your centroid point, whereas S = 1 gives you another point on the same line of (10i, -4j, -3k)
这篇关于从点云中的质心绘制矢量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!