summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1b8158f)
raw | patch | inline | side by side (parent: 1b8158f)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Sun, 18 Nov 2007 11:10:42 +0000 (11:10 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Sun, 18 Nov 2007 11:10:42 +0000 (11:10 +0000) |
src/snap.cpp | patch | blob | history |
diff --git a/src/snap.cpp b/src/snap.cpp
index a6b91e07447a70ae60b306574516f22729e933b9..28b0664c74930b3491212ebede09616a7f17066a 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
/* The current best metric for the best transformation; lower is better, NR_HUGE
** means that we haven't snapped anything.
*/
- double best_metric = NR_HUGE;
+ NR::Coord best_metric = NR_HUGE;
+ NR::Coord best_second_metric = NR_HUGE;
+ bool best_at_intersection = false;
std::vector<NR::Point>::const_iterator j = transformed_points.begin();
- // std::cout << std::endl;
+ //std::cout << std::endl;
for (std::vector<NR::Point>::const_iterator i = points.begin(); i != points.end(); i++) {
NR::Point result;
NR::Coord metric;
+ NR::Coord second_metric;
if (snapped.getDistance() < NR_HUGE) {
/* We snapped. Find the transformation that describes where the snapped point has
* and not to the intersection itself!
*/
metric = snapped.getDistance(); //used to be: metric = NR::L2(result);
+ second_metric = NR::L2(*j - snapped.getPoint());
break;
case SCALE:
{
g_assert_not_reached();
}
+
+
/* Note it if it's the best so far */
- if ((metric < best_metric) || ((metric == best_metric) && snapped.getAtIntersection() == true)) {
+ bool const c1 = metric < best_metric;
+ bool const c2 = metric == best_metric && snapped.getAtIntersection() == true && best_at_intersection == false;
+ bool const c3a = metric == best_metric && snapped.getAtIntersection() == true && best_at_intersection == true;
+ bool const c3b = second_metric < best_second_metric;
+
+ if (c1 || c2 || c3a && c3b) {
best_transformation = result;
+ //if (c1) {std::cout << "c1 ";}
+ //if (c2) {std::cout << "c2 ";}
+ //if (c3a && c3b) {std::cout << "c3 ";}
best_metric = metric;
- // std::cout << "SEL ";;
+ best_second_metric = second_metric;
+ best_at_intersection = snapped.getAtIntersection();
+ //std::cout << "SEL ";
} //else { std::cout << " ";}
}
- // std::cout << "P_orig = " << (*i) << " | metric = " << metric << " | distance = " << snapped.getDistance() << " | P_snap = " << snapped.getPoint() << std::endl;
+ //std::cout << "P_orig = " << (*i) << " | metric = " << metric << " | distance = " << snapped.getDistance() << " | second metric = " << second_metric << " | P_snap = " << snapped.getPoint() << std::endl;
j++;
}