This is a discussion on Point Cloud Library...thanks for the answer, Victor lamoine and Anders Glent Buch and Matteo Munaro :)
source: http://www.pcl-users.org/Method-finding-plane-equation-crossing-3-points-tc4034211.html#a4034214
Does PCL provide function for finding plane crossing 3 given points in 3D?
Method should find plane coefficients A B C D from equation Ax+By+Cz+D=0 and it should save the found coefficients to pcl::ModelCoefficients class.
Does PCL have such functionality?
If you denote your 3D points p1, p2 and p3, take the cross product of the in-plane vectors (p2 - p1) x (p3 - p1) to get the normal vector, and normalize it. Now you have the A, B and C coefficients already by these three components. To get D, just take the negative dot product between this vector and p1.
void
threePointsToPlane (const PointT &point_a,
const PointT &point_b,
const PointT &point_c,
const pcl::ModelCoefficients::Ptr plane)
{
// Create Eigen plane through 3 points
Eigen::Hyperplane eigen_plane =
Eigen::Hyperplane::Through (point_a.getArray3fMap (),
point_b.getArray3fMap (),
point_c.getArray3fMap ());
plane->values.resize (4);
for (int i = 0; i < plane->values.size (); i++)
plane->values[i] = eigen_plane.coeffs ()[i];
}
source: http://www.pcl-users.org/Method-finding-plane-equation-crossing-3-points-tc4034211.html#a4034214
Does PCL provide function for finding plane crossing 3 given points in 3D?
Method should find plane coefficients A B C D from equation Ax+By+Cz+D=0 and it should save the found coefficients to pcl::ModelCoefficients class.
Does PCL have such functionality?
If you denote your 3D points p1, p2 and p3, take the cross product of the in-plane vectors (p2 - p1) x (p3 - p1) to get the normal vector, and normalize it. Now you have the A, B and C coefficients already by these three components. To get D, just take the negative dot product between this vector and p1.
void
threePointsToPlane (const PointT &point_a,
const PointT &point_b,
const PointT &point_c,
const pcl::ModelCoefficients::Ptr plane)
{
// Create Eigen plane through 3 points
Eigen::Hyperplane
Eigen::Hyperplane
point_b.getArray3fMap (),
point_c.getArray3fMap ());
plane->values.resize (4);
for (int i = 0; i < plane->values.size (); i++)
plane->values[i] = eigen_plane.coeffs ()[i];
}
// Ground plane estimation: Eigen::VectorXf ground_coeffs; ground_coeffs.resize(4); std::vector<int> clicked_points_indices; for (unsigned int i = 0; i < clicked_points_3d->points.size(); i++) clicked_points_indices.push_back(i); pcl::SampleConsensusModelPlane<PointT> model_plane(clicked_points_3d); model_plane.computeModelCoefficients(clicked_points_indices,ground_coeffs); std::cout << "Ground plane: " << ground_coeffs(0) << " " << ground_coeffs(1) << " " << ground_coeffs(2) << " " << ground_coeffs(3) << std::endl;
No comments:
Post a Comment