Пример #1
0
int halfplane(lines &v, points &res) {
	sort(v.begin(), v.end(), cmpang);
	deque<line> q;
	deque<point> ans;
	q.push_back(v[0]);
	for (int i = 1; i < int(v.size()); i ++) {
		if (dcmp(v[i].ang - v[i - 1].ang) == 0) continue;
		while(ans.size() && !onleft(ans.back(), v[i])) {
			ans.pop_back();
			q.pop_back();
		}
		while(ans.size() && !onleft(ans.front(), v[i])) {
			ans.pop_front();
			q.pop_front();
		}
		ans.push_back(interpoint(q.back(), v[i]));
		q.push_back(v[i]);
	}
	while(ans.size() && !onleft(ans.back(), q.front())) {
		ans.pop_back();
		q.pop_back();
	}
	while(ans.size() && !onleft(ans.front(), q.back())) {
		ans.pop_front();
		q.pop_front();
	}
	ans.push_back(interpoint(q.back(), q.front()));
	res = points(ans.begin(), ans.end());
	return ans.size(); //you must use the size to assure an empty set, area dont has the accuracy we need
}
Пример #2
0
	void write() {
		fst outs;
		this->_open_write(outs);
		outs.seekg(0, std::ios::beg);
		for (lines::iterator iter = _content.begin(); iter != _content.end();
				++iter) {
			outs << (*iter) << "\n";
		}
	}
Пример #3
0
task4_6::solution::solution( const lines& calulator_lines )
{
	size_t i = 0;
	expressions exps;

	for(lines::const_iterator it = calulator_lines.begin(); it != calulator_lines.end(); it++, i++)
		rpn(*it, i, exps);

	make_values(exps);
}
Пример #4
0
task4_6::solution::solution( const lines& calculator_lines )
{
	line_index = 0;
	for( lines::const_iterator it = calculator_lines.begin(); it!= calculator_lines.end(); ++it, ++line_index )
		process_line( *it );
}