From efba4fa09b585b36a2f9d534ed0639d263008733 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 2 May 2012 15:52:56 +0200 Subject: [PATCH] [Positioner] Fix Autocalibration::sort_reference_aps() Fix the angle calculation in sort_reference_aps() and better comment the code. --- owlps-positioner/src/autocalibration.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/owlps-positioner/src/autocalibration.cc b/owlps-positioner/src/autocalibration.cc index cbfed8f..3f1427d 100644 --- a/owlps-positioner/src/autocalibration.cc +++ b/owlps-positioner/src/autocalibration.cc @@ -115,29 +115,39 @@ void Autocalibration::sort_reference_aps() if (ref == rx) continue ; - // Skip the AP if it is not at the same floor than the - // receiver AP: + /* Skip the AP if it is not at the same floor than the + * receiver AP */ const Point3D &ref_coord = ref->second.get_coordinates() ; if (ref_coord.get_z() != rx_coord.get_z()) continue ; - // Skip the AP if it is not in coverage with the receiver AP: + /* Skip the AP if it is not in coverage with the receiver AP */ float coverage = rx->second.received_calibration_from_ap(ref->second) ; if (coverage < 1) // Less than 1% coverage is ridiculous! continue ; - Point3D ref_coord_r(ref_coord) ; - ref_coord_r.rotate_2d(rx_coord, angle_p) ; + /* Angle P-RX-REF */ + double angle = rx_coord.angle_2d(point, ref_coord) ; - double angle = rx_coord.angle_2d(point, ref_coord_r) ; + /* Weight in the APs' list according to coverage and angle */ double weight = angle / coverage ; + /* Note: this weight is used only to sort the APs, it has nothing + to do with the angle weight (see weight_aps()) used to compute + the SSs. */ + + /* Create the list entry */ pair::const_iterator> angle_ap(angle, ref) ; pair::const_iterator> > weight_angle_ap(weight, angle_ap) ; + + /* Rotate the AP's coordinates to know the angle direction */ + Point3D ref_coord_r(ref_coord) ; + ref_coord_r.rotate_2d(rx_coord, angle_p) ; + // Insert the AP in the right list, according to the direction: if (ref_coord_r.get_y() < rx_coord.get_y()) sorted_negative_angles.insert(weight_angle_ap) ; else