- distanceSquared = pow(point.h1.x() - p.x(), 2) + pow(point.h1.y() - p.y(), 2);
- if (distanceSquared < nearestDistanceSquared) {
- nearestIndex = i;
- nearestDistanceSquared = distanceSquared;
- selectedPoint = PTypeH1;
- }
- distanceSquared = pow(point.p.x() - p.x(), 2) + pow(point.p.y() - p.y(), 2);
- if (distanceSquared < nearestDistanceSquared) {
- nearestIndex = i;
- nearestDistanceSquared = distanceSquared;
- selectedPoint = PTypeP;
- }
- distanceSquared = pow(point.h2.x() - p.x(), 2) + pow(point.h2.y() - p.y(), 2);
- if (distanceSquared < nearestDistanceSquared) {
- nearestIndex = i;
- nearestDistanceSquared = distanceSquared;
- selectedPoint = PTypeH2;
+ for (int j = 0; j < 3; ++j) {
+ distanceSquared = pow(point[j].x() - p.x(), 2) + pow(point[j].y() - p.y(), 2);
+ if (distanceSquared < nearestDistanceSquared) {
+ nearestIndex = i;
+ nearestDistanceSquared = distanceSquared;
+ selectedPoint = (point_types)j;
+ }