Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //For each choice, need to scan through all plants
- //that have not been visited for first ccw one
- for(int j = 1; j <= numPlants; ++j) {
- if(!plants[j].visited) {
- double angle = getRelativeAngle(plants[curr], plants[j]);
- //cout << "curr: " << curr << " next: " << j << " angle: " << angle << endl << endl;
- if(angle < smallestAngle
- || (angle == smallestAngle
- && getDistance(plants[curr], plants[j]) < closestDistance)) {
- smallestAngle = angle;
- nextPlant = j;
- plants[nextPlant].angle = angle;
- closestDistance = getDistance(plants[curr], plants[j]);
- }
- }
- }
- //Now we have the plant that is the first ccw from curr
- solution.push_back(nextPlant);
- plants[nextPlant].visited = true;
- curr = nextPlant;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement