MCPcopy Create free account
hub / github.com/PDAL/PDAL / computeCentroid

Function computeCentroid

pdal/private/MathUtils.cpp:137–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137Eigen::Vector3d computeCentroid(const PointView& view,
138 const PointIdList& ids)
139{
140 using namespace Eigen;
141
142 double mx, my, mz;
143 mx = my = mz = 0.0;
144 point_count_t n(0);
145 for (auto const& j : ids)
146 {
147 auto update = [&n](double value, double average)
148 {
149 double delta, delta_n;
150 delta = value - average;
151 delta_n = delta / n;
152 return average + delta_n;
153 };
154 n++;
155 mx = update(view.getFieldAs<double>(Dimension::Id::X, j), mx);
156 my = update(view.getFieldAs<double>(Dimension::Id::Y, j), my);
157 mz = update(view.getFieldAs<double>(Dimension::Id::Z, j), mz);
158 }
159
160 Vector3d centroid;
161 centroid << mx, my, mz;
162
163 return centroid;
164}
165
166Eigen::Matrix3d computeCovariance(const PointView& view,
167 const PointIdList& ids)

Callers 7

TESTFunction · 0.85
runMethod · 0.85
setPlaneFitMethod · 0.85
icpMethod · 0.85
teaserMethod · 0.85
demeanPointViewFunction · 0.85
computeCovarianceFunction · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68