MCPcopy Create free account
hub / github.com/comaps/comaps / SmoothUniform

Function SmoothUniform

libs/geometry/smoothing.cpp:48–69  ·  view source on GitHub ↗

The same as SmoothGeneric but optimized for alpha == 0.0.

Source from the content-addressed store, hash-verified

46
47// The same as SmoothGeneric but optimized for alpha == 0.0.
48void SmoothUniform(m2::PointD const & pt0, m2::PointD const & pt1, m2::PointD const & pt2, m2::PointD const & pt3,
49 size_t pointsCount, std::vector<m2::PointD> & path)
50{
51 if (pt0.EqualDxDy(pt1, kEps) || pt1.EqualDxDy(pt2, kEps) || pt2.EqualDxDy(pt3, kEps))
52 return;
53
54 for (size_t i = 1; i < pointsCount; ++i)
55 {
56 double const t = static_cast<double>(i) / pointsCount;
57 double const t2 = t * t;
58 double const t3 = t2 * t;
59
60 double const k0 = -t + 2 * t2 - t3;
61 double const k1 = 2 - 5 * t2 + 3 * t3;
62 double const k2 = t + 4 * t2 - 3 * t3;
63 double const k3 = t3 - t2;
64
65 auto const pt = (pt0 * k0 + pt1 * k1 + pt2 * k2 + pt3 * k3) * 0.5;
66 if (!path.back().EqualDxDy(pt, kEps) && !pt2.EqualDxDy(pt, kEps))
67 path.push_back(pt);
68 }
69}
70} // namespace
71
72void SmoothPaths(GuidePointsForSmooth const & guidePoints, size_t newPointsPerSegmentCount, double smoothAlpha,

Callers 1

SmoothPathsFunction · 0.85

Calls 3

backMethod · 0.80
EqualDxDyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected