Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include "SDL/SDL.h"
  2. #include "Point.h"
  3. #include <map>
  4.  
  5. void calc_slope(vector<Point>& v, SDL_Surface* screen)
  6. {
  7. SDL_LockSurface(screen);
  8. for(auto p : v)
  9. {
  10. std::multimap<double, Point> m;
  11. for(auto t : v)
  12. {
  13. m.insert (make_pair(p.slopeTo(t),t));
  14. if(m.count(p.slopeTo(t)) > 2)
  15. {
  16. std::pair <std::multimap<double, Point>::iterator, std::multimap<double, Point>::iterator> ret;
  17. ret = m.equal_range(p.slopeTo(t));
  18. for(std::multimap<double, Point>::iterator it = ret.first; it!= ret.second; ++it)
  19. {
  20. p.lineTo(screen,t);
  21. }
  22. }
  23. }
  24. }
  25. SDL_FreeSurface(screen);
  26. SDL_Flip(screen); // display screen
  27. }
  28. /* typedef std::map<double, Point>::iterator it_type;
  29. for(it_type iterator = m.begin(); iterator != m.end(); iterator++)
  30. {
  31. if(!isinf(iterator->first))
  32. {
  33. if(m.count(iterator->first)>2)
  34. {
  35. auto ret = m.equal_range(iterator->first);
  36. //if(iterator->first == iterator++->first)
  37. for(auto i = ret.first ; i != ret.second ; ++i)
  38. {
  39. if(iterator->first == i->first)
  40. render_line(screen,iterator->second,i->second);
  41. }
  42. for(int i = 0; i < m.count(iterator->first)-1 ; ++i)
  43. {
  44. iterator++;
  45. }
  46. //std::cout << ret.first->second << '\t' << ret.second->second<<'\t'<<ret.first->first<<'\n';
  47. //std::cout<<m.count(iterator->first)<<" "<<iterator->first<<'\n';
  48. }
  49. }
  50. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement