Advertisement
Guest User

Untitled

a guest
May 28th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. //For each choice, need to scan through all plants
  2. //that have not been visited for first ccw one
  3. for(int j = 1; j <= numPlants; ++j) {
  4. if(!plants[j].visited) {
  5. double angle = getRelativeAngle(plants[curr], plants[j]);
  6. //cout << "curr: " << curr << " next: " << j << " angle: " << angle << endl << endl;
  7. if(angle < smallestAngle
  8. || (angle == smallestAngle
  9. && getDistance(plants[curr], plants[j]) < closestDistance)) {
  10.  
  11. smallestAngle = angle;
  12. nextPlant = j;
  13. plants[nextPlant].angle = angle;
  14. closestDistance = getDistance(plants[curr], plants[j]);
  15. }
  16. }
  17. }
  18. //Now we have the plant that is the first ccw from curr
  19. solution.push_back(nextPlant);
  20. plants[nextPlant].visited = true;
  21. curr = nextPlant;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement