MCPcopy Create free account
hub / github.com/JeremyBYU/polylidar / DownSampleNormals

Function DownSampleNormals

examples/cpp/polylidar-full-example.cpp:13–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include "open3d/Open3D.h"
12
13FastGA::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
31Polylidar::Matrix<double> ConvertMatX3dtoMatrix(FastGA::MatX3d& matrix)
32{

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected