educelab / volume-cartographer

Volumetric processing toolkit and C++ libraries for the recovery and restoration of damaged cultural materials
GNU General Public License v3.0
63 stars 22 forks source link

Add generic interface for 3D transforms #65

Closed csparker247 closed 1 year ago

csparker247 commented 1 year ago

Adds vc/core/types/Transforms.hpp which provides a common interface for transforming meshes, point sets, and the values in PPMs. Currently only implements AffineTransform but more to come.

#include "vc/core/types/Transforms.hpp"

using namespace volcart;

// Compose an affine transform with multiple transformations
auto tfm = AffineTransform::New();
tfm->translate(1, 2, 3);
tfm->rotate(45, 0, 1, 0);
tfm->scale(1, 2, 3);

// Apply the transform to a point
auto pt = tfm->applyPoint({0,0,0});

// Apply the transform to a direction vector
auto vec = tfm->applyVector({0, 0, 1});

// Apply the transform to a mesh, point set, PPM
mesh = ApplyTransform(mesh, tfm);
points = ApplyTransform(points, tfm); // Supports PointSet<cv::Vec3d> and OrderedPointSet<cv::Vec3d>
ppm = ApplyTransform(ppm, tfm);

Other important changes