4

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.

Andrew Wagner
  • 22,677
  • 21
  • 86
  • 100

1 Answers1

2

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.

Catree
  • 2,477
  • 1
  • 17
  • 24
  • Thanks! I'm not using PCL anymore (that was 2 years ago), but I'm just going to assume that that works. – Andrew Wagner Jan 30 '17 at 10:36
  • Some kind of reference: [Vector in 3D PCL](http://www.pcl-users.org/Vector-in-3D-PCL-tp4034437p4034442.html). – Catree Jan 30 '17 at 13:57