Uva 12304 2D Geometry 110 in 1!(圆综合题)

62 篇文章 0 订阅
11 篇文章 0 订阅

题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3726

思路:居然错在了求内切圆gg。


1.求外接圆:

求出任意两条垂直平分线,求交点即可。


2.求内切圆:

设三角形三点坐标分别为(x1, y1), (x2, y2), (x3, y3),则三角形的内心坐标(X, Y)为: 

X = (BC*x1 + AC*x2 + AB*x3)/(BC + AC + AB) 

Y = (BC*y1 + AC*y2 + AB*y3)/(BC + AC + AB)

3.求过定点圆的切线:设定点为p,切点为q,圆心为c。则先求出pq的距离和pc的夹角ang,则向量pc的极角加减ang就是两条切线的极角,可求出切线。

4.过定点p且与直线(x1,y1)-----(x2,y2)相切且半径为r的圆:

圆心到直线距离为r,圆心的轨迹为两条直线,可将直线顺时针(逆时针)旋转90度得到向量l,其方向向量为v。以直线上两点为端点,以v为方向向量求出两模为r的向量,其两端点即为圆心所在直线上两点。据此,可求出圆心所在直线L。

(1)可以根据圆心到定点p的距离为r,列方程求解圆心。

(2)圆心同时在以p为圆心,以r为半径的圆C上。所以可以求出圆C与直线L的交点,即为圆心。

5.半径为r且与两条直线相切的圆:

与4类似,求出圆心所在直线,两两求交点即为圆心坐标。

6.与两圆相外切半径为r的圆:

根据两圆得到以C1为圆心,以C1.r+R为半径的圆和以C2为圆心,以C2.r+R为半径的圆,求其交点即为所求圆心。

lrj code:

// UVa12304 2D Geometry 110 in 1!
// Rujia Liu
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<vector>
#include<cassert>
using namespace std;

const double eps = 1e-6;
int dcmp(double x)
{
    if(fabs(x) < eps) return 0;
    else return x < 0 ? -1 : 1;
}

const double PI = acos(-1);

struct Point
{
    double x, y;
    Point(double x=0, double y=0):x(x),y(y) { }
};

typedef Point Vector;

Vector operator + (Vector A, Vector B)
{
    return Vector(A.x+B.x, A.y+B.y);
}
Vector operator - (Point A, Point B)
{
    return Vector(A.x-B.x, A.y-B.y);
}
Vector operator * (Vector A, double p)
{
    return Vector(A.x*p, A.y*p);
}
Vector operator / (Vector A, double p)
{
    return Vector(A.x/p, A.y/p);
}

bool operator < (const Point& a, const Point& b)
{
    return a.x < b.x || (a.x == b.x && a.y < b.y);
}

bool operator == (const Point& a, const Point &b)
{
    return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0;
}

double Dot(Vector A, Vector B)
{
    return A.x*B.x + A.y*B.y;
}
double Length(Vector A)
{
    return sqrt(Dot(A, A));
}
double Angle(Vector A, Vector B)
{
    return acos(Dot(A, B) / Length(A) / Length(B));
}
double Cross(Vector A, Vector B)
{
    return A.x*B.y - A.y*B.x;
}

Vector Rotate(Vector A, double rad)
{
    return Vector(A.x*cos(rad)-A.y*sin(rad), A.x*sin(rad)+A.y*cos(rad));
}

Vector Normal(Vector A)
{
    double L = Length(A);
    return Vector(-A.y/L, A.x/L);
}

Point GetLineIntersection(Point P, Point v, Point Q, Point w)
{
    Vector u = P-Q;
    double t = Cross(w, u) / Cross(v, w);
    return P+v*t;
}

Point GetLineProjection(Point P, Point A, Point B)
{
    Vector v = B-A;
    return A+v*(Dot(v, P-A) / Dot(v, v));
}

double DistanceToLine(Point P, Point A, Point B)
{
    Vector v1 = B - A, v2 = P - A;
    return fabs(Cross(v1, v2)) / Length(v1); // 如果不取绝对值,得到的是有向距离
}

struct Line
{
    Point p;
    Vector v;
    Line(Point p, Vector v):p(p),v(v) { }
    Point point(double t)
    {
        return p + v*t;
    }
    Line Move(double d)
    {
        return Line(p + Normal(v)*d, v);
    }
};

struct Circle
{
    Point c;
    double r;
    Circle(Point c, double r):c(c),r(r) {}
    Point point(double a)
    {
        return Point(c.x + cos(a)*r, c.y + sin(a)*r);
    }
};

Point GetLineIntersection(Line a, Line b)
{
    return GetLineIntersection(a.p, a.v, b.p, b.v);
}

double angle(Vector v)
{
    return atan2(v.y, v.x);
}

int getLineCircleIntersection(Line L, Circle C, double& t1, double& t2, vector<Point>& sol)
{
    double a = L.v.x, b = L.p.x - C.c.x, c = L.v.y, d = L.p.y - C.c.y;
    double e = a*a + c*c, f = 2*(a*b + c*d), g = b*b + d*d - C.r*C.r;
    double delta = f*f - 4*e*g; // 判别式
    if(dcmp(delta) < 0) return 0; // 相离
    if(dcmp(delta) == 0)   // 相切
    {
        t1 = t2 = -f / (2 * e);
        sol.push_back(L.point(t1));
        return 1;
    }
    // 相交
    t1 = (-f - sqrt(delta)) / (2 * e);
    sol.push_back(L.point(t1));
    t2 = (-f + sqrt(delta)) / (2 * e);
    sol.push_back(L.point(t2));
    return 2;
}

int getCircleCircleIntersection(Circle C1, Circle C2, vector<Point>& sol)
{
    double d = Length(C1.c - C2.c);
    if(dcmp(d) == 0)
    {
        if(dcmp(C1.r - C2.r) == 0) return -1; // 重合,无穷多交点
        return 0;
    }
    if(dcmp(C1.r + C2.r - d) < 0) return 0;
    if(dcmp(fabs(C1.r-C2.r) - d) > 0) return 0;

    double a = angle(C2.c - C1.c);
    double da = acos((C1.r*C1.r + d*d - C2.r*C2.r) / (2*C1.r*d));
    Point p1 = C1.point(a-da), p2 = C1.point(a+da);

    sol.push_back(p1);
    if(p1 == p2) return 1;
    sol.push_back(p2);
    return 2;
}

/******************* Problem 1 **********************/

Circle CircumscribedCircle(Point p1, Point p2, Point p3)
{
    double Bx = p2.x-p1.x, By = p2.y-p1.y;
    double Cx = p3.x-p1.x, Cy = p3.y-p1.y;
    double D = 2*(Bx*Cy-By*Cx);
    double cx = (Cy*(Bx*Bx+By*By) - By*(Cx*Cx+Cy*Cy))/D + p1.x;
    double cy = (Bx*(Cx*Cx+Cy*Cy) - Cx*(Bx*Bx+By*By))/D + p1.y;
    Point p = Point(cx, cy);
    return Circle(p, Length(p1-p));
}

/******************* Problem 2 **********************/

Circle InscribedCircle(Point p1, Point p2, Point p3)
{
    double a = Length(p2-p3);
    double b = Length(p3-p1);
    double c = Length(p1-p2);
    Point p = (p1*a+p2*b+p3*c)/(a+b+c);
    return Circle(p, DistanceToLine(p, p1, p2));
}

/******************* Problem 3 **********************/

// 过点p到圆C的切线。v[i]是第i条切线的向量。返回切线条数
int getTangents(Point p, Circle C, Vector* v)
{
    Vector u = C.c - p;
    double dist = Length(u);
    if(dist < C.r) return 0;
    else if(dcmp(dist - C.r) == 0)   // p在圆上,只有一条切线
    {
        v[0] = Rotate(u, PI/2);
        return 1;
    }
    else
    {
        double ang = asin(C.r / dist);
        v[0] = Rotate(u, -ang);
        v[1] = Rotate(u, +ang);
        return 2;
    }
}

/******************* Problem 4 **********************/

vector<Point> CircleThroughPointTangentToLineGivenRadius(Point p, Line L, double r)
{
    vector<Point> ans;
    double t1, t2;
    getLineCircleIntersection(L.Move(-r), Circle(p, r), t1, t2, ans);
    getLineCircleIntersection(L.Move(r), Circle(p, r), t1, t2, ans);
    return ans;
}

/******************* Problem 5 **********************/

vector<Point> CircleTangentToLinesGivenRadius(Line a, Line b, double r)
{
    vector<Point> ans;
    Line L1 = a.Move(-r), L2 = a.Move(r);
    Line L3 = b.Move(-r), L4 = b.Move(r);
    ans.push_back(GetLineIntersection(L1, L3));
    ans.push_back(GetLineIntersection(L1, L4));
    ans.push_back(GetLineIntersection(L2, L3));
    ans.push_back(GetLineIntersection(L2, L4));
    return ans;
}

/******************* Problem 6 **********************/

vector<Point> CircleTangentToTwoDisjointCirclesWithRadius(Circle c1, Circle c2, double r)
{
    vector<Point> ans;
    Vector v = c2.c - c1.c;
    double dist = Length(v);
    int d = dcmp(dist - c1.r -c2.r - r*2);
    if(d > 0) return ans;
    getCircleCircleIntersection(Circle(c1.c, c1.r+r), Circle(c2.c, c2.r+r), ans);
    return ans;
}

// formatting
double lineAngleDegree(Vector v)
{
    double ang = angle(v)*180.0/PI;
    while(dcmp(ang) < 0) ang += 360.0;
    while(dcmp(ang-180) >= 0) ang -= 180.0;
    return ang;
}

void format(Circle c)
{
    printf("(%.6lf,%.6lf,%.6lf)\n", c.c.x, c.c.y, c.r);
}

void format(vector<double> ans)
{
    int n = ans.size();
    sort(ans.begin(), ans.end());
    printf("[");
    if(n)
    {
        printf("%.6lf", ans[0]);
        for(int i = 1; i < n; i++) printf(",%.6lf", ans[i]);
    }
    printf("]\n");
}

void format(vector<Point> ans)
{
    int n = ans.size();
    sort(ans.begin(), ans.end());
    printf("[");
    if(n)
    {
        printf("(%.6lf,%.6lf)", ans[0].x, ans[0].y);
        for(int i = 1; i < n; i++) printf(",(%.6lf,%.6lf)", ans[i].x, ans[i].y);
    }
    printf("]\n");
}

Line getLine(double x1, double y1, double x2, double y2)
{
    Point p1(x1,y1);
    Point p2(x2,y2);
    return Line(p1, p2-p1);
}

int main()
{
    //freopen("in.txt","r",stdin);
    string cmd;
    while(cin >> cmd)
    {
        double x1, y1, x2, y2, x3, y3, x4, y4, xp, yp, xc, yc, r1, r2, r;
        if(cmd == "CircumscribedCircle")
        {
            cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
            format(CircumscribedCircle(Point(x1,y1), Point(x2,y2), Point(x3,y3)));
        }
        if(cmd == "InscribedCircle")
        {
            cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
            format(InscribedCircle(Point(x1,y1), Point(x2,y2), Point(x3,y3)));
        }
        if(cmd == "TangentLineThroughPoint")
        {
            cin >> xc >> yc >> r >> xp >> yp;
            Vector v[2];
            vector<double> ans;
            int cnt = getTangents(Point(xp, yp), Circle(Point(xc, yc), r), v);
            for(int i = 0; i < cnt; i++) ans.push_back(lineAngleDegree(v[i]));
            format(ans);
        }
        if(cmd == "CircleThroughAPointAndTangentToALineWithRadius")
        {
            cin >> xp >> yp >> x1 >> y1 >> x2 >> y2 >> r;
            format(CircleThroughPointTangentToLineGivenRadius(Point(xp, yp), getLine(x1, y1, x2, y2), r));
        }
        if(cmd == "CircleTangentToTwoLinesWithRadius")
        {
            cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4 >> r;
            format(CircleTangentToLinesGivenRadius(getLine(x1, y1, x2, y2), getLine(x3, y3, x4, y4), r));
        }
        if(cmd == "CircleTangentToTwoDisjointCirclesWithRadius")
        {
            cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2 >> r;
            format(CircleTangentToTwoDisjointCirclesWithRadius(Circle(Point(x1, y1), r1), Circle(Point(x2, y2), r2), r));
        }
    }
    return 0;
}


my code:

#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define debug
using namespace std;
const double eps=1e-10;
const double PI=acos(-1.0);
const int INF=0x3f3f3f3f;

struct Equ
{
    double x,y;
};

struct Point
{
    double x,y;
    Point(double x=0,double y=0):x(x),y(y) {}
    void read()
    {
        scanf("%lf%lf",&x,&y);
    }
    void print()
    {
        printf("%.6f %.6f",x,y);
    }
};

struct Line
{
    Point p1,p2;
    Line(Point p1=NULL,Point p2=NULL):p1(p1),p2(p2) {}
    void read()
    {
        p1.read();
        p2.read();
    }
};

struct Circle
{
    Point c;
    double r;
    Circle(Point c=NULL,double r=0.0):c(c),r(r) {}
    Point point(double a)
    {
        return Point(c.x+cos(a)*r,c.y+sin(a)*r);
    }
    void read()
    {
        c.read();
        scanf("%lf",&r);
    }
    void print()
    {
        c.print();
        printf(" %f",r);
    }
};

typedef Point Vector;

Vector operator + (Vector A,Vector B)
{
    return Vector(A.x+B.x,A.y+B.y);
}

Vector operator - (Point A,Point B)
{
    return Vector(A.x-B.x,A.y-B.y);
}

Vector operator * (Vector A,double p)
{
    return Vector(A.x*p,A.y*p);
}

Vector operator / (Vector A,double p)
{
    return Vector(A.x/p,A.y/p);
}

bool operator < (const Point &a,const Point &b)
{
    return a.x<b.x||(a.x==b.x&&a.y<b.y);
}

int dcmp(double x)
{
    if(fabs(x)<eps) return 0;
    else return x<0?-1:1;
}

bool operator == (const Point &a,const Point &b)
{
    return dcmp(a.x-b.x)==0&&dcmp(a.y-b.y)==0;
}

double Dot(Vector A,Vector B)
{
    return A.x*B.x+A.y*B.y;
}

double Length(Vector A)
{
    return sqrt(Dot(A,A));
}

double changeAngle(double ang)
{
    double tmp=180.0*ang/PI;
    if(tmp>=180) tmp-=180;
    if(tmp<0) tmp+=180;
    return tmp;
}

double Angle(Vector A,Vector B)
{
    return acos(Dot(A,B)/Length(A)/Length(B));
}

double polarAngle(Vector v)
{
    return atan2(v.y,v.x);
}

Vector Normal(Vector A)
{
    double L=Length(A);
    return Vector(-A.y/L,A.x/L);
}

Vector changeLen(Vector v,double l)
{
    double len=Length(v);
    if(dcmp(len)==0) return v;
    l/=len;
    return Vector(v.x*l,v.y*l);
}

Vector Rotate(Vector A,double rad)
{
    return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
}

double Cross(Vector A,Vector B)
{
    return A.x*B.y-A.y*B.x;
}

Point GetLineIntersection(Point P,Vector v,Point Q,Vector w)
{
    Vector u=P-Q;
    double t=Cross(w,u)/Cross(v,w);
    return P+v*t;
}

bool SegmentProperIntersection(Point a1,Point a2,Point b1,Point b2)
{
    double c1=Cross(a2-a1,b1-a1),c2=Cross(a2-a1,b2-a1),
           c3=Cross(b2-b1,a1-b1),c4=Cross(b2-b1,a2-b1);
    return dcmp(c1)*dcmp(c2)<0&&dcmp(c3)*dcmp(c4)<0;
}

bool OnSegment(Point p,Point a1,Point a2)
{
    return dcmp(Cross(a1-p,a2-p))==0&&dcmp(Dot(a1-p,a2-p))<0;
}

double DistanceToSegment(Point P,Point A,Point B)
{
    if(A==B) return Length(P-A);
    Vector v1=B-A,v2=P-A,v3=P-B;
    if(dcmp(Dot(v1,v2))<0) return Length(v2);
    else if(dcmp(Dot(v1,v3))>0) return Length(v3);
    else return fabs(Cross(v1,v2))/Length(v1);
}

int getCircleCircleIntersection(Circle C1,Circle C2,vector<Point> &sol)
{
  double d=Length(C1.c-C2.c);
  if(dcmp(d)==0)
  {
    if(dcmp(C1.r-C2.r)==0) return -1;
    return 0;
  }

  if(dcmp(C1.r+C2.r-d)<0) return 0;
  if(dcmp(fabs(C1.r-C2.r)-d)>0) return 0;

  double a=polarAngle(C2.c-C1.c);
  double da=acos((C1.r*C1.r+d*d-C2.r*C2.r)/(2*C1.r*d));
  Point p1=C1.point(a-da),p2=C1.point(a+da);

  sol.push_back(p1);
  if(p1==p2) return 1;
  sol.push_back(p2);
  return 2;
}

void CircumscribedCircle(Point p1,Point p2,Point p3,Point &P,double &R)
{
    Vector u=p2-p1;
    Vector v=p3-p1;
    Vector norU=Normal(u);
    Vector norV=Normal(v);

    P=GetLineIntersection((p1+p2)/2,norU,(p1+p3)/2,norV);
    R=Length(p1-P);

    printf("(%.6f,%.6f,%.6f)\n",P.x,P.y,R);
}


double DistanceToLine(Point P,Point A,Point B)
{
  Vector v1=B-A,v2=P-A;
  return fabs(Cross(v1,v2))/Length(v1);
}

void InscribedCircle(Point p1,Point p2,Point p3)
{
    double a = Length(p2-p3);
    double b = Length(p3-p1);
    double c = Length(p1-p2);
    Point p = (p1*a+p2*b+p3*c)/(a+b+c);
    printf("(%.6f,%.6f,%.6f)\n",p.x,p.y,DistanceToLine(p,p1,p2));
}


int getTangents(Point p,Circle C,Vector *v,vector<double> &ans)
{
    Vector u=C.c-p;
    double dist=Length(u);

    if(dist<C.r)
    {

    }
    else if(dcmp(dist-C.r)==0)
    {
        v[0]=Rotate(u,PI/2);
        ans.push_back(changeAngle(polarAngle(v[0])));
    }
    else
    {
        double ang=asin(C.r/dist);
        v[0]=Rotate(u,-ang);
        v[1]=Rotate(u,ang);
        ans.push_back(changeAngle(polarAngle(v[0])));
        ans.push_back(changeAngle(polarAngle(v[1])));
    }

    sort(ans.begin(),ans.end());
    printf("[");
    for(int i=0; i<ans.size(); i++)
    {
        if(i==0) printf("%.6f",ans[i]);
        else printf(",%.6f",ans[i]);
    }
    printf("]\n");

}

int solveEqu(double a,double b,double c,vector<double>& sol)
{
    double t1,t2;
    double delta=b*b-4*a*c;
    if(dcmp(delta)<0) return 0;
    if(dcmp(delta)==0)
    {
        t1=t2=-b/(2*a);
        sol.push_back(t1);
        return 1;
    }
    else
    {
        t1=(-b+sqrt(delta))/(2*a);
        t2=(-b-sqrt(delta))/(2*a);
        sol.push_back(t1);
        sol.push_back(t2);
        return 2;
    }
}

int cmp(Equ a,Equ b)
{
    if(dcmp(a.x-b.x)==0) return dcmp(a.y-b.y)<0;
    else return dcmp(a.x-b.x)<0;
}

void CircleThroughAPointAndTangentToALineWithRadius(Point p,Line l,double r)
{
    vector<double>sol;
    vector<Equ> ans;

    double k,b,kk,bb;

    Vector p1=l.p1+(changeLen(Rotate(l.p1-l.p2,-PI/2),r));
    Vector p2=l.p2+(changeLen(Rotate(l.p1-l.p2,-PI/2),r));

    if(dcmp(p1.x-p2.x)==0)
    {
        sol.clear();
        solveEqu(1,-2*p.y,p.y*p.y+(p1.x-p.x)*(p1.x-p.x)-r*r,sol);
        for(int i=0; i<sol.size(); i++)
        {
            ans.push_back((Equ){l.p1.x,sol[i]});
        }
    }
    else
    {
        k=(p2.y-p1.y)/(p2.x-p1.x);
        b=p2.y-k*p2.x;

        double A=1+k*k;
        double B=-2*p.x+2*k*b-2*k*p.y;
        double C=p.x*p.x+b*b-2*b*p.y+p.y*p.y-r*r;

        sol.clear();

        solveEqu(A,B,C,sol);
        for(int i=0; i<sol.size(); i++)
        {
            ans.push_back((Equ){sol[i],sol[i]*k+b});
        }

    }

    Vector p3=l.p1+(changeLen(Rotate(l.p1-l.p2,PI/2),r));
    Vector p4=l.p2+(changeLen(Rotate(l.p1-l.p2,PI/2),r));

    if(dcmp(p3.x-p4.x)==0)
    {
        sol.clear();
        solveEqu(1,-2*p.y,p.y*p.y+(p3.x-p.x)*(p3.x-p.x)-r*r,sol);
        for(int i=0; i<sol.size(); i++)
        {
            ans.push_back((Equ){p3.x,sol[i]});
        }
    }
    else
    {
        kk=(p3.y-p4.y)/(p3.x-p4.x);
        bb=p3.y-kk*p3.x;

        double AA=1+kk*kk;
        double BB=-2*p.x+2*kk*bb-2*kk*p.y;
        double CC=p.x*p.x+bb*bb-2*bb*p.y+p.y*p.y-r*r;

        sol.clear();

        solveEqu(AA,BB,CC,sol);
        for(int i=0; i<sol.size(); i++)
        {
            ans.push_back((Equ){sol[i],sol[i]*kk+bb});
        }
    }

    sort(ans.begin(),ans.end(),cmp);

    printf("[");
    for(int i=0; i<ans.size(); i++)
    {
        if(i!=0) printf(",");
        printf("(%.6f,%.6f)",ans[i].x,ans[i].y);
    }
    printf("]\n");

}

void CircleTangentToTwoLinesWithRadius(Line l1,Line l2,double r)
{
    vector<Point> ans;

    Vector p1=l1.p1+(changeLen(Rotate(l1.p1-l1.p2,-PI/2),r));
    Vector p2=l1.p2+(changeLen(Rotate(l1.p1-l1.p2,-PI/2),r));
    Vector p3=l1.p1+(changeLen(Rotate(l1.p1-l1.p2,PI/2),r));
    Vector p4=l1.p2+(changeLen(Rotate(l1.p1-l1.p2,PI/2),r));

    Vector pp1=l2.p1+(changeLen(Rotate(l2.p1-l2.p2,-PI/2),r));
    Vector pp2=l2.p2+(changeLen(Rotate(l2.p1-l2.p2,-PI/2),r));
    Vector pp3=l2.p1+(changeLen(Rotate(l2.p1-l2.p2,PI/2),r));
    Vector pp4=l2.p2+(changeLen(Rotate(l2.p1-l2.p2,PI/2),r));

    ans.push_back(GetLineIntersection(p1,p2-p1,pp1,pp2-pp1));
    ans.push_back(GetLineIntersection(p1,p2-p1,pp3,pp4-pp3));

    ans.push_back(GetLineIntersection(p3,p4-p3,pp1,pp2-pp1));
    ans.push_back(GetLineIntersection(p3,p4-p3,pp3,pp4-pp3));

    sort(ans.begin(),ans.end());

    printf("[");
    for(int i=0;i<ans.size();i++)
    {
      if(i!=0) printf(",");
      printf("(%.6f,%.6f)",ans[i].x,ans[i].y);
    }
    printf("]\n");
}

void CircleTangentToTwoDisjointCirclesWithRadius(Circle c1,Circle c2,double r)
{
   Point p1=c1.c,p2=c2.c;
   Circle C1=Circle(p1,c1.r+r),C2=Circle(p2,c2.r+r);


   vector<Point> sol;
   getCircleCircleIntersection(C1,C2,sol);

   sort(sol.begin(),sol.end());
   printf("[");
   for(int i=0;i<sol.size();i++)
   {
      if(i!=0) printf(",");
      printf("(%.6f,%.6f)",sol[i].x,sol[i].y);
   }
   printf("]\n");
}

int main()

{
#ifdef debu
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // debug
    string cmd;
    while(cin>>cmd)
    {
        if(cmd=="CircumscribedCircle")
        {
            double r;
            Point p1,p2,p3,p;
            p1.read(),p2.read(),p3.read();
            CircumscribedCircle(p1,p2,p3,p,r);
        }
        if(cmd=="InscribedCircle")
        {
            Point p1,p2,p3;
            p1.read(),p2.read(),p3.read();
            InscribedCircle(p1,p2,p3);
        }
        if(cmd=="TangentLineThroughPoint")
        {
            Point p;
            Circle C;
            C.read();
            p.read();

            Vector v[2];
            vector<double> ans;
            getTangents(p,C,v,ans);
        }
        if(cmd=="CircleThroughAPointAndTangentToALineWithRadius")
        {
            Point p;
            p.read();
            Line l;
            l.read();
            double r;
            scanf("%lf",&r);
            CircleThroughAPointAndTangentToALineWithRadius(p,l,r);
        }
        if(cmd=="CircleTangentToTwoLinesWithRadius")
        {
          Line l1,l2;
          l1.read();l2.read();
          double r;
          scanf("%lf",&r);
          CircleTangentToTwoLinesWithRadius(l1,l2,r);
        }
        if(cmd=="CircleTangentToTwoDisjointCirclesWithRadius")
        {
          Circle c1,c2;
          c1.read();c2.read();
          double r;
          scanf("%lf",&r);
          CircleTangentToTwoDisjointCirclesWithRadius(c1,c2,r);
        }
    }

}



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值