# Easy3DMatchAlign

| Support            | ![](assets/images/sample_programs/applies_to/cpp.svg) ![](assets/images/sample_programs/applies_to/cs.svg) ![](assets/images/sample_programs/applies_to/qt.svg)   |
|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Required licenses  | **Easy3DMatch**                                                                                                                                                   |
| Recommended images | The images from the folder `Sample Images/3D/Easy3DMatch/Align/object 1`                                                                                          |
| Location           | `3D Processing/Easy3DMatchAlign`                                                                                                                                  |

## Purpose

This sample program demonstrates how to:

- Align a sample (point cloud or ZMap) on a reference (3D mesh, point cloud or ZMap).

![](assets/images/sample_programs/3d_processing_easy3dmatchalign.webp)

## Code highlights

Use the recommended images:

- Reference: `object1_cad.stl` or `object1_goldenScan_top_ensenso.ply`.
- Sample: `object1_top_ensenso.ply`.

1. Set the reference mesh with its viewpoint (azimuth and elevation angle).
   ```c++
   Aligner_.SetReference(referenceMesh_, azimuthReference_, elevationReference_);
   ```
2. Perform an alignment for the given sample point cloud with its viewpoint and retrieve the result.
   ```c++
   alignment_ = aligner_.Align(samplePointCloud_, azimuthSample_, elevationSample_);
   ```
3. Retrieve the pose from the alignment and apply it to the sample point cloud to align it on the reference.
   ```c++
   EAffineTransformer.ApplyMatrix(alignment_.Pose, samplePointCloud_, resultPointCloud_);
   ```
