Exemplo n.º 1
0
vector<double> solve(vector2 here, vector2 dir, vector<vector2>& center, vector<double>& radius) {
	double n = center.size();
	dir = dir.normalize();
	vector<double> ret;
	double cnt=0;
	while (cnt < 100) {
		double circle = -1;
		double time = INF*0.5;

		for (double i = 0; i < n; ++i) {
			double cand = hitCircle(here, dir, center[i], radius[i] + 1);
			if (cand < time) {
				time = cand;
				circle = i;
			}
		}
		if (circle == -1) break;
		cnt++;
		ret.push_back(circle);
		vector2 contact = here + dir * time;

		dir = reflect(here, dir, center[circle], contact);
		here = contact;
	}
	return ret;
}
Exemplo n.º 2
0
	vector2 project(const vector2& rhs) const {
		vector2 r = rhs.normalize();
		return r * r.dot(*this);
	}