11 #include <simulation/dataobjects/MCParticleTrajectory.h>
28 v.SetXYZ(a.x - b.x, a.y - b.y, a.z - b.z);
38 if (distance_tolerance <= 0 ||
m_points.size() < 3)
return;
41 std::stack<std::pair<iterator, iterator>> stack;
47 iterator firstPoint, splitPoint, finalPoint;
51 while (!stack.empty()) {
53 std::tie(firstPoint, finalPoint) = stack.top();
57 setVector(n, *firstPoint, *finalPoint,
true);
59 double maxDistance(0);
60 for (
auto nextPoint = firstPoint + 1; nextPoint != finalPoint; ++nextPoint) {
62 setVector(pa, *firstPoint, *nextPoint);
64 const double dist = (pa - (pa * n) * n).Mag();
66 if (dist > maxDistance) {
67 splitPoint = nextPoint;
72 if (maxDistance > distance_tolerance) {
78 stack.push(make_pair(splitPoint, finalPoint));
79 stack.push(make_pair(firstPoint, splitPoint));
85 *(nextFreePoint++) = *finalPoint;