Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "SDL/SDL.h"
- #include "Point.h"
- #include <map>
- void calc_slope(vector<Point>& v, SDL_Surface* screen)
- {
- SDL_LockSurface(screen);
- for(auto p : v)
- {
- std::multimap<double, Point> m;
- for(auto t : v)
- {
- m.insert (make_pair(p.slopeTo(t),t));
- if(m.count(p.slopeTo(t)) > 2)
- {
- std::pair <std::multimap<double, Point>::iterator, std::multimap<double, Point>::iterator> ret;
- ret = m.equal_range(p.slopeTo(t));
- for(std::multimap<double, Point>::iterator it = ret.first; it!= ret.second; ++it)
- {
- p.lineTo(screen,t);
- }
- }
- }
- }
- SDL_FreeSurface(screen);
- SDL_Flip(screen); // display screen
- }
- /* typedef std::map<double, Point>::iterator it_type;
- for(it_type iterator = m.begin(); iterator != m.end(); iterator++)
- {
- if(!isinf(iterator->first))
- {
- if(m.count(iterator->first)>2)
- {
- auto ret = m.equal_range(iterator->first);
- //if(iterator->first == iterator++->first)
- for(auto i = ret.first ; i != ret.second ; ++i)
- {
- if(iterator->first == i->first)
- render_line(screen,iterator->second,i->second);
- }
- for(int i = 0; i < m.count(iterator->first)-1 ; ++i)
- {
- iterator++;
- }
- //std::cout << ret.first->second << '\t' << ret.second->second<<'\t'<<ret.first->first<<'\n';
- //std::cout<<m.count(iterator->first)<<" "<<iterator->first<<'\n';
- }
- }
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement