I have some code like this:
vector<double> Saved;
for(int i = 0; i<10; i++)
{
if(some condition on i)
Saved.push_back(i);
}
Then I want to see what order the things were saved... so naturally I do
cout << Saved.at(0) << endl << Saved.at(1) << endl;
But to my surprise they aren't in the right order!! Pretty odd if you ask me...
I would expect the first thing output there to always be less than the second thing... correct??
The actual code follows, but relies on a bunch of stuff so I don't think it will be very helpful:
for(int scancounter = 0; scancounter < NumScans; scancounter++) //alpha loop
{
for(int concentriccol = 0; concentriccol < ColsPerScan; concentriccol++) //beta loop
{
B.clear();
V1.clear();
V2.clear();
B = LiDARGrid.ConcentricScans.at(scancounter).getColumn(concentriccol);
double Penalty = CreateComparableVectors(A,B,V1,V2);
double distance = VectorDistance(V1,V2) + Penalty;
if(distance < 100) //distance bigger than this is unreliable
{
if(distance <= BestDistance)
{
BestDistance = distance;
BestScanPositions.push_back(scancounter);
BestCols.push_back(concentriccol);
}
}
}//end col loop
}//end scanner loop
cout << "Input Scan: " << CorrectPosition << " Col: " << CorrectCol << endl
<< "Matching Scans: " << endl
<< BestScanPositions.at(0) << " Col: " << BestCols.at(0) << endl
<< BestScanPositions.at(1) << " Col: " << BestCols.at(1) << endl
<< "Best Distance: " << BestDistance << endl
<< "There were " << BestScanPositions.size() << " good matches." << endl << endl;
An example is BestScanPositions.at(0) is 0 and BestScanPositions.at(1) is also 0. Then BestCols.at(0) is 19 and BestCols.at(1) is 16!!! Weird, eh?
Please let me know if I'm doing something wrong..
Thanks,
Dave