Article From:

Transmission gate

In the plane, there is a circle, there is a point, ask to circle the center of the largest circle coordinates and radius in this circle. It is required that the maximum circle do not contain this point.

Train of thought: the computational geometry based on comparison should be divided into three parts. The first is the point outside the circle. The second is in the circle. The third is the coincidence of this point and the center of the circle.



#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iterator>
#include <cmath>
using namespace std;

#define lson (l , mid , rt << 1)
#define rson (mid + 1 , r , rt << 1 | 1)
#define debug(x) cerr << #x << " = " << x << "\n";
#define pb push_back
#define pq priority_queue

#define Pll pair<ll,ll>
#define Pii pair<int,int>

#define fi first
#define se second

#define OKC ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
const double espp = 0.0000000001;

/*-----------------show time----------------*/
double R,x,y,x2,y2;
double dis(double a,double b,double x,double y)
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
int main(){
    scanf("%lf%lf%lf%lf%lf", &R, &x, &y, &x2, &y2);
    double d = dis(x,y,x2,y2);
    if(d > R ||abs(d-R) < espp)
        printf("%lf %lf %lf\n",x,y,R);
        double r1 = (R + d)/2;  
        double dx = 1.0*(x-x2)*(x-x2) + 1.0*(y-y2)*(y-y2);
        dx = sqrt(dx);  
        double ans1,ans2;
             ans1 = x2 + (x-x2)/dx*r1;
             ans2 = y2 + (y-y2)/dx*r1;
            ans1 = x;
            ans2 = y+R/2; 
        printf("%.9lf %.9lf %.9lf\n",ans1,ans2,r1);
    return 0;



Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *