// CHECK void ExpBinning(const TFltPrV& deg, TFltPrV& degSparse, const int& BinRadix){ TFlt maxDeg(deg[deg.Len()-1].Val1.Val), minDeg(deg[0].Val1.Val); bool maxPowerReached = false; // idx - index of border, previdx - index of previous border int power = 0, previdx = 0, idx, binSize; TFltPr val; double binBorder = 0.0; while (binBorder <= minDeg) binBorder = pow(static_cast<double>(BinRadix), power++); TFltPr v(minDeg, deg[0].Val2.Val); degSparse.Add(v); bool isExact = false; while (!maxPowerReached){ if (binBorder >= maxDeg){ // when last element of deg was previous bin border if (previdx == deg.Len() - 1) break; // if we have another elements binBorder = maxDeg; maxPowerReached = true; } // find next element idx = FindVal1Elem(deg, binBorder, isExact); // if bin size == 0 if (previdx + 1 == idx && !isExact) continue; if (!isExact) idx = idx - 1; double sum = 0.0; binSize = idx - previdx; for (int i = previdx + 1; i <= idx; i++){ sum += deg[i].Val2.Val; } sum /= binSize; // if prevBinBorder was the smallest degree, it can be more than binBorder / BinRadix double SumBinBorder = previdx > 0 ? binBorder + static_cast<double>(binBorder) / BinRadix : binBorder + static_cast<double>(minDeg); double avgDeg = SumBinBorder / 2.0; val.Val1 = avgDeg; val.Val2 = sum; degSparse.Add(val); previdx = idx; binBorder = pow(static_cast<double>(BinRadix), power++); } }
void DriverRadarPositioner::update() { if (startingNewLap && driverData && driverData->getLastLap().getSectorTime(3).isValid()) { currSector = 1; currentLapTime = 0; currentDeg = 0; calculateAvgs(); startingNewLap = false; } // else { if (EventData::getInstance().getEventType() == LTPackets::RACE_EVENT && driverData->getLastLap().getSectorTime(3).isValid() && EventData::getInstance().getCompletedLaps() == EventData::getInstance().getEventInfo().laps && (finished || fabs(maxDeg() - currentDeg) < 5)) { currentDeg = 0; finished = true; inPits = true; calculatePitPosition(); } else if (driverData->isInPits() || driverData->isRetired() || (EventData::getInstance().getEventType() == LTPackets::RACE_EVENT && EventData::getInstance().getFlagStatus() == LTPackets::RED_FLAG)) { inPits = true; finished = false; calculatePitPosition(); } else { if (inPits) calculatePitOutPosition(); inPits = false; finished = false; calculatePosition(); } } if (!driverData->getLastLap().getSectorTime(3).isValid()) { startingNewLap = true; } }