12 double dPhi = std::fabs(phi1 - phi2);
28 int nPts = intersections.size();
30 int idxL, idxR, idxMid;
38 while ((idxR - idxL) > 1) {
39 idxMid = (idxL + idxR) / 2;
40 pos = intersections[idxMid].position();
41 mom = intersections[idxMid].momentum();
43 if ((inputPos -
pos).dot(
mom) > 0) {
55 posL = intersections[0].position();
56 momL = intersections[0].momentum();
58 if (idxR == (nPts - 1)) {
59 posR = intersections[nPts - 1].position();
60 momR = intersections[nPts - 1].momentum();
63 float mag2L = (inputPos - posL).
mag2();
64 float mag2R = (inputPos - posR).
mag2();
65 nearestIdx = (mag2L < mag2R) ? idxL : idxR;
66 nearestPos = (mag2L < mag2R) ? posL : posR;
67 nearestMom = (mag2L < mag2R) ? momL : momR;