| 11 | #include "open3d/Open3D.h" |
| 12 | |
| 13 | FastGA::MatX3d DownSampleNormals(Polylidar::Matrix<double>& triangle_normals, double down_sample_fraction = 0.20) |
| 14 | { |
| 15 | int starting_normals = static_cast<int>(triangle_normals.rows); |
| 16 | int ds_normals = static_cast<int>(static_cast<double>(starting_normals) * down_sample_fraction); |
| 17 | |
| 18 | // Create random sampling |
| 19 | std::mt19937 rng(0); |
| 20 | std::uniform_int_distribution<int> gen(0, starting_normals); // uniform, unbiased |
| 21 | |
| 22 | FastGA::MatX3d new_normals(ds_normals); |
| 23 | for (int i = 0; i < ds_normals; ++i) |
| 24 | { |
| 25 | int r = gen(rng); |
| 26 | new_normals[i] = {triangle_normals(r, 0), triangle_normals(r, 1), triangle_normals(r, 2)}; |
| 27 | } |
| 28 | return new_normals; |
| 29 | } |
| 30 | |
| 31 | Polylidar::Matrix<double> ConvertMatX3dtoMatrix(FastGA::MatX3d& matrix) |
| 32 | { |