Doing math with PCL PointXYZ structs?

◇◆丶佛笑我妖孽 提交于 2020-04-13 06:11:13

问题


What is the usual way to do math, addition, subtraction, on PCL (Point Cloud Library) data types, i.e. PointXYZ? There don't seem to be operators defined even for the basics.

I thought maybe the PCL way was to convert to Eigen vectors, but there doesn't seem to be a constructor for that either.


回答1:


For anyone who wants to do basic math with PointXYZ, here a quick example:

  pcl::PointXYZ a(0, 1, 2), b(10, 20, 30), c;
  c.getArray3fMap() = a.getArray3fMap() + b.getArray3fMap();
  std::cout << "c=" << c << std::endl;
  //c=(10,21,32)

  c.getArray3fMap() = a.getArray3fMap() * b.getArray3fMap();
  std::cout << "c=" << c << std::endl;
  //c=(0,20,60)

Maybe there is a better way but at least it works.



来源:https://stackoverflow.com/questions/33363587/doing-math-with-pcl-pointxyz-structs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!