| 319 | } |
| 320 | |
| 321 | void AddPointToCircle(std::vector<m2::PointD> & circle, m2::PointD const & point) |
| 322 | { |
| 323 | size_t iDist1 = 0; |
| 324 | size_t iDist2 = 0; |
| 325 | double dist1 = std::numeric_limits<double>::max(); |
| 326 | double dist2 = std::numeric_limits<double>::max(); |
| 327 | |
| 328 | for (size_t i = 0; i < circle.size(); ++i) |
| 329 | { |
| 330 | double const dist = DistanceOnPlain(circle[i], point); |
| 331 | if (dist < dist1) |
| 332 | { |
| 333 | dist2 = dist1; |
| 334 | iDist2 = iDist1; |
| 335 | |
| 336 | dist1 = dist; |
| 337 | iDist1 = i; |
| 338 | } |
| 339 | else if (dist < dist2) |
| 340 | { |
| 341 | dist2 = dist; |
| 342 | iDist2 = i; |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | if (iDist1 > iDist2) |
| 347 | std::swap(iDist1, iDist2); |
| 348 | |
| 349 | if (iDist1 == 0 && iDist2 == circle.size() - 1) |
| 350 | circle.push_back(point); |
| 351 | else |
| 352 | circle.insert(circle.begin() + iDist2, point); |
| 353 | } |
| 354 | } // namespace generator |