コード例 #1
0
ファイル: 3007.cpp プロジェクト: miskcoo/oicode
bool solve()
{
	int N;
	std::scanf("%d", &N);
	if(N == 0) return false;
	for(int i = 0; i != N; ++i)
		std::scanf("%lf %lf", &pt[i].x, &pt[i].y);
	std::random_shuffle(pt, pt + N);
	point_t c = pt[0];
	double r = 0.0;
	for(int i = 1; i != N; ++i)
	{
		if(dist(pt[i], c) <= r + eps)
			continue;
		c = pt[i], r = 0.0;
		for(int j = 0; j != i; ++j)
		{
			if(dist(pt[j], c) <= r + eps)
				continue;
			c = middle_point(pt[i], pt[j]);
			r = dist(c, pt[i]);
			for(int k = 0; k != j; ++k)
			{
				if(dist(pt[k], c) <= r + eps)
					continue;
				c = incenter(pt[i], pt[j], pt[k]);
				r = dist(c, pt[i]);
			}
		}
	}

	std::printf("%.2lf %.2lf %.2lf\n", c.x, c.y, std::sqrt(r));
	return true;
}
コード例 #2
0
ファイル: sketch_tess.cpp プロジェクト: cogitokat/brlcad
/* create a biarc for a bezier curve.
 *
 * extends the tangent lines to the bezier curve at its first and last control
 * points, and intersects them to find a third point.
 * the biarc passes through the first and last control points, and the incenter
 * of the circle defined by the first, last and intersection points.
 */
HIDDEN ON_Arc
make_biarc(const ON_BezierCurve& bezier)
{
    ON_2dPoint isect, arc_pt;
    ON_2dPoint p_start(bezier.PointAt(0)), p_end(bezier.PointAt(1.0));
    ON_2dVector t_start(bezier.TangentAt(0)), t_end(bezier.TangentAt(1.0));
    ON_Ray r_start(p_start, t_start), r_end(p_end, t_end);

    r_start.IntersectRay(r_end, isect);
    arc_pt = incenter(p_start, p_end, isect);

    return ON_Arc(p_start, arc_pt, p_end);
}