HDU4773: Problem of Apollonius

Problem Description

  Apollonius of Perga (ca. 262 BC - ca. 190 BC) was a Greek geometer and astronomer. In his noted work Epaphai, he posed and solved such a problem: constructing circles that are tangent to three given circles in a plane. Two tangent circles can be internally or externally tangent to each other, thus Apollonius’s problem generically have eight solutions.
  Now considering a simplified case of Apollonius’s problem: constructing circles that are externally tangent to two given circles, and touches a given point(the given point must be on the circle which you find, can’t be inside the circle). In addition, two given circles have no common points, and neither of them are contained by the other, and the given point is also located strictly outside the given circles. You should be thankful that modern mathematics provides you with plenty of useful tools other than euclidean geometry that help you a lot in this problem.
  

Input

  The first line of input contains an integer T (T ≤ 200), indicating the number of cases.
  Each ease has eight positive integers x1, y1, r1, x2, y2, r2, x3, y3 in a single line, stating two circles whose centres are (x1, y1), (x2, y2) and radius are r1 and r2 respectively, and a point located at (x3, y3). All integers are no larger than one hundred.

Output

  For each case, firstly output an integer S, indicating the number of solutions.
  Then output S lines, each line contains three float numbers x, y and r, meaning that a circle, whose center is (x, y) and radius is r, is a solution to this case. If there are multiple solutions (S > 1), outputing them in any order is OK. Your answer will be accepted if your absolute error for each number is no more than 10-4.

Sample Input

1
12 10 1 8 10 1 10 10

Sample Output

2
10.00000000 8.50000000 1.50000000
10.00000000 11.50000000 1.50000000

HINT

我们不难发现本题的做法其实就是你以p为反演中心,随便一个r为反演半径,然后我们再把两个圆反演一波,求一波过p的外公切线,然后再把这个切线反演回来就好。

CODE

#include <bits/stdc++.h>

#define eps 0.00000001
double x_0, y_0;
double a[5], b[5], c[5];
double ansx[5], ansy[5], ansr[5];
int flag[5];

void exchange(double &x, double &y)
{
     double tmp = x;
     x = y;
     y = tmp;
     return ;
}

double dis(double x_1, double y_1, double x_2, double y_2)
{
     return sqrt((x_1 - x_2) * (x_1 - x_2) + (y_1 - y_2) * (y_1 - y_2));
}

void changepoint(double x, double y, double &ex, double &ey) 
{
     double d = dis(x, y, x_0, y_0);
     ey = y_0 + (y - y_0) / (d * d);
     ex = x_0 + (x - x_0) / (d * d);
     return ;
}

void changecircle(double x, double y, double r, double &ex, double &ey, double &er) 
{
     double x_1, y_1, x_2, y_2;
     if(fabs(x - x_0) < eps)
     {
          changepoint(x, y + r, x_1, y_1);
          changepoint(x, y- r, x_2, y_2);
     }
     else
     {
          double k = (y - y_0) / (x - x_0);
          double tmp = sqrt(r * r / (1 + k * k));
          changepoint(tmp + x, k * tmp + y, x_1, y_1);
          changepoint(-tmp + x, -k * tmp + y, x_2, y_2);
     }
     ex = (x_1 + x_2) / 2;
     ey = (y_1 + y_2) / 2;
     er = dis(x_1, y_1, x_2, y_2) / 2;
     return ;
}

void rotate(double s, double t, double &aa, double &bb, double &cc, double sinct, double cosct) 
{
     double tmpa = aa, tmpb = bb, tmpc = cc;
     aa = tmpa * cosct - tmpb * sinct;
     bb = tmpa * sinct + tmpb * cosct;
     cc = tmpc + tmpa * s * cosct + tmpa * t * sinct - tmpa * s
          - tmpb * s * sinct + tmpb * t * cosct - tmpb * t;
     return ;
}

void getline(double x_1, double y_1, double r_1, double x_2, double y_2, double r_2)
{
     double tmpa, tmpb, tmpc;
     tmpa = y_2 - y_1;
     tmpb = x_1 - x_2;
     tmpc = y_1 * (x_1 - x_2) - x_1 * (y_1 - y_2);
     double d, detr;
     d = dis(x_1, y_1, x_2, y_2);
     detr = r_2 - r_1;
     double sinct = fabs(detr) / d;
     double cosct = sqrt(d * d - detr * detr) / d;
     double aa = tmpa, bb = tmpb, cc = tmpc;
     rotate(x_1, y_1, aa, bb, cc, sinct, cosct);
     a[0] = aa;
     b[0] = bb;
     c[0] = cc - r_1 * sqrt(a[0] * a[0] + b[0] * b[0]);
     aa = tmpa, bb = tmpb, cc = tmpc;
     rotate(x_1, y_1, aa, bb, cc, -sinct, cosct);
     a[1] = aa;
     b[1] = bb;
     c[1] = cc + r_1 * sqrt(a[1] * a[1] + b[1] * b[1]);
     return ;
}

void getcircle(double aa, double bb, double cc, int k) 
{
     if(fabs(aa * x_0 + bb * y_0 - cc) < eps)
     {
          flag[k] = 0;
          return ;
     }
     double s, t, ex, ey;
     s = (aa * cc + x_0 * bb * bb - aa * bb * y_0) / (aa * aa + bb * bb);
     t = (bb * cc - x_0 * aa * bb + aa * aa * y_0) / (aa * aa + bb * bb);
     changepoint(s, t, ex, ey);
     ansx[k] = (x_0 + ex) / 2;
     ansy[k] = (y_0 + ey) / 2;
     ansr[k] = dis(x_0, y_0, ex, ey) / 2;
     return ;
}

double x_00,y_00,x_11,y_11,x_22,y_22,r_11,r_22;
bool check(double x, double y, double r)
{
     if (fabs(dis(x,y,x_00,y_00) - r) < eps)
     if (fabs(dis(x,y,x_11,y_11) - r - r_11) < eps)
     if (fabs(dis(x,y,x_22,y_22) - r - r_22) < eps)
          return true;
     return false;
}

double get_dis(double aa, double bb, double cc,double x, double y)
{
     return fabs((aa*x + bb*y - cc)/sqrt(aa*aa + bb*bb));
}

int main()
{

     int T = 100;
     double x_1, y_1, r_1, x_2, y_2, r_2;
     scanf("%d", &T);
     while(T--)
     {
          scanf("%lf%lf%lf", &x_1, &y_1, &r_1);
          scanf("%lf%lf%lf", &x_2, &y_2, &r_2);
          scanf("%lf%lf", &x_0, &y_0);
          x_00 = x_0;
          y_00 = y_0;
          x_11 = x_1;
          y_11 = y_1;
          x_22 = x_2;
          y_22 = y_2;
          r_11 = r_1;
          r_22 = r_2;

          double ex_1, ex_2, ey_1, ey_2, er_1, er_2;

          changecircle(x_1, y_1, r_1, ex_1, ey_1, er_1);
          changecircle(x_2, y_2, r_2, ex_2, ey_2, er_2);
          if(er_1 > er_2)
          {
               exchange(ex_1, ex_2);
               exchange(ey_1, ey_2);
               exchange(er_1, er_2);
          }
          getline(ex_1, ey_1, er_1, ex_2, ey_2, er_2);
          memset(flag, -1, sizeof(flag));
          getcircle(a[0], b[0], c[0], 0);
          getcircle(a[1], b[1], c[1], 1);
          int ans = 0;
          for (int i=0; i < 2;i++)
          {
               if (check(ansx[i],ansy[i],ansr[i])){
                    ans++;
                    flag[i] = 1;
               }
          }

          printf("%d\n", ans);

          for(int i = 0; i < 2; i++)
          {
               if(flag[i] == 1){
                    printf("%.8lf %.8lf %.8lf\n", ansx[i], ansy[i], ansr[i]);
               }
          }
     }
     return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Foreword By Andrew Glassner xvii Preface xix Mathematical Notation xxi Pseudo-Code xxiii Contributors xxviii I I I I I I I I I IMAGE PROCESSING MAGE PROCESSING MAGE PROCESSING MAGE PROCESSING MAGE PROCESSING Introduction 3 1. Fast Bitmap Stretching C 4 Tomas Möller 2. General Filtered Image Rescaling C 8 Dale Schumacher 3. Optimization of Bitmap Scaling Operations 17 Dale Schumacher 4. A Simple Color Reduction Filter C 20 Dennis Braggviii CONTENTS 5. Compact Isocontours from Sampled Data 23 Douglas Moore and Joseph Warren 6. Generating Isovalue Contours from a Pixmap C 29 Tim Feldman 7. Compositing Black-and-White Bitmaps 34 David Salesin and Ronen Barzel 8. 2 1 2 -D Depth-of-Field Simulation for Computer 36 Animation Cary Scofield 9. A Fast Boundary Generator for Composited 39 Regions C Eric Furman II II II II II N N N N NUMERICAL AND PROGRAMMING UMERICAL AND PROGRAMMING UMERICAL AND PROGRAMMING UMERICAL AND PROGRAMMING UMERICAL AND PROGRAMMING T T T T TECHNIQUES ECHNIQUES ECHNIQUES ECHNIQUES ECHNIQUES Introduction 47 1. IEEE Fast Square Root C 48 Steve Hill 2. A Simple Fast Memory Allocator C 49 Steve Hill 3. The Rolling Ball C 51 Andrew J. Hanson 4. Interval Arithmetic C 61 Jon Rokne 5. Fast Generation of Cyclic Sequences C 67 Alan W. Paeth 6. A Generic Pixel Selection Mechanism 77 Alan W. Paethix CONTENTS 7. Nonuniform Random Points Sets via Warping 80 Peter Shirley 8. Cross Product in Four Dimensions and Beyond 84 Ronald N. Goldman 9. Face-Connected Line Segment Generation in an n-Dimensional Space C 89 Didier Badouel and Charles A. Wüthrich III III III III III M M M M MODELING AND TRANSFORMATIONS ODELING AND TRANSFORMATIONS ODELING AND TRANSFORMATIONS ODELING AND TRANSFORMATIONS ODELING AND TRANSFORMATIONS Introduction 95 1. Quaternion Interpolation with Extra Spins C 96 Jack Morrison 2. Decomposing Projective Transformations 98 Ronald N. Goldman 3. Decomposing Linear and Affine Transformations 108 Ronald N. Goldman 4. Fast Random Rotation Matrices C 117 James Arvo 5. Issues and Techniques for Keyframing Transformations 121 Paul Dana 6. Uniform Random Rotations C 124 Ken Shoemake 7. Interpolation Using Bézier Curves C 133 Gershon Elber 8. Physically Based Superquadrics C 137 A. H. Barrx CONTENTS I I I I IV V V V V 2-D 2-D 2-D 2-D 2-D GEOMETRY AND ALGORITHMS GEOMETRY AND ALGORITHMS GEOMETRY AND ALGORITHMS GEOMETRY AND ALGORITHMS GEOMETRY AND ALGORITHMS Introduction 163 1. A Parametric Elliptical Arc Algorithm C 164 Jerry Van Aken and Ray Simar 2. Simple Connection Algorithm for 2-D Drawing C 173 Claudio Rosati 3. A Fast Circle Clipping Algorithm C 182 Raman V. Srinivasan 4. Exact Computation of 2-D Intersections C 188 Clifford A. Shaffer and Charles D. Feustel 5. Joining Two Lines with a Circular Arc Fillet C 193 Robert D. Miller 6. Faster Line Segment Intersection C 199 Franklin Antonio 7. Solving the Problem of Apollonius and Other 203 Related Problems Constantina Sevici V V V V V 3-D 3-D 3-D 3-D 3-D GEOMETRY AND ALGORITHMS GEOMETRY AND ALGORITHMS GEOMETRY AND ALGORITHMS GEOMETRY AND ALGORITHMS GEOMETRY AND ALGORITHMS Introduction 213 1. Triangles Revisited 215 Fernando J. López-López 2. Partitioning a 3-D Convex Polygon with an 219 Arbitrary Plane C Norman Chin 3. Signed Distance from Point to Plane C 223 Príamos Georgiadesxi CONTENTS 4. Grouping Nearly Coplanar Polygons into Coplanar Sets C 225 David Salesin and Filippo Tampieri 5. Newell’s Method for Computing the Plane Equation of a Polygon C 231 Filippo Tampieri 6. Plane-to-Plane Intersection C 233 Príamos Georgiades 7. Triangle-Cube Intersection C 236 Douglas Voorhies 8. Fast n-Dimensional Extent Overlap Testing C 240 Len Wanger and Mike Fusco 9. Subdividing Simplices C 244 Doug Moore 10.Understanding Simploids 250 Doug Moore 11. Converting Bézier Triangles into Rectangular Patches C 256 Dani Lischinski 12.Curve Tesselation Criteria through Sampling 262 Terence Lindgren, Juan Sanchez, and Jim Hall Vl Vl Vl Vl Vl R R R R RAY TRACING AND RADIOSITY AY TRACING AND RADIOSITY AY TRACING AND RADIOSITY AY TRACING AND RADIOSITY AY TRACING AND RADIOSITY Introduction 269 1. Ray Tracing with the BSP Tree C 271 Kelvin Sung and Peter Shirley 2. Intersecting a Ray with a Quadric Surface C 275 Joseph M. Cychosz and Warren N. Waggenspack, Jr.xii CONTENTS 3. Use of Residency Masks and Object Space Partitioning to Eliminate Ray-Object Intersection Calculations 284 Joseph M. Cychosz 4. A Panoramic Virtual Screen for Ray Tracing C 288 F. Kenton Musgrave 5. Rectangular Bounding Volumes for Popular Primitives C 295 Ben Trumbore 6. A Linear-Time Simple Bounding Volume Algorithm 301 Xiaolin Wu 7. Physically Correct Direct Lighting for Distribution Ray Tracing C 307 Changyaw Wang 8. Hemispherical Projection of a Triangle C 314 Buming Bian 9. Linear Radiosity Approximation Using Vertex-to-Vertex Form Factors 318 Nelson L. Max and Michael J. Allison 10. Delta Form-Factor Calculation for the Cubic Tetrahedral Algorithm C 324 Jeffrey C. Beran-Koehn and Mark J. Pavicic 11. Accurate Form-Factor Computation C 329 Filippo Tampieri VII VII VII VII VII R R R R RENDERING ENDERING ENDERING ENDERING ENDERING Introduction 337 1. The Shadow Depth Map Revisited 338 Andrew Wooxiii CONTENTS 2. Fast Linear Color Rendering C 343 Russell C. H. Cheng 3. Edge and Bit-Mask Calculations for Anti-Aliasing C 349 Russell C. H. Cheng 4. Fast Span Conversion: Unrolling Short Loops C 355 Thom Grace 5. Progressive Image Refinement Via Gridded Sampling C 358 Steve Hollasch 6. Accurate Polygon Scan Conversion Using Half-Open Intervals C 362 Kurt Fleischer and David Salesin 7. Darklights 366 Andrew S. Glassner 8. Anti-Aliasing in Triangular Pixels 369 Andrew S. Glassner 9. Motion Blur on Graphics Workstations C 374 John Snyder, Ronen Barzel and Steve Gabriel 10. The Shader Cache: A Rendering Pipeline Accelerator 383 James Arvo and Cary Scofeld References 611 Index
未来社区的建设背景和需求分析指出,随着智能经济、大数据、人工智能、物联网、区块链、云计算等技术的发展,社区服务正朝着数字化、智能化转型。社区服务渠道由分散向统一融合转变,服务内容由通用庞杂向个性化、服务导向转变。未来社区将构建数字化生态,实现数据在线、组织在线、服务在线、产品智能和决策智能,赋能企业创新,同时注重人才培养和科研平台建设。 规划设计方面,未来社区将基于居民需求,打造以服务为中心的社区管理模式。通过统一的服务平台和应用,实现服务内容的整合和优化,提供灵活多样的服务方式,如推送式、订阅式、热点式等。社区将构建数据与应用的良性循环,提高服务效率,同时注重生态优美、绿色低碳、社会和谐,以实现幸福民生和产业发展。 建设运营上,未来社区强调科学规划、以人为本,创新引领、重点突破,统筹推进、整体提升。通过实施院落+社团自治工程,转变政府职能,深化社区自治法制化、信息化,解决社区治理中的重点问题。目标是培养有活力的社会组织,提高社区居民参与度和满意度,实现社区治理服务的制度机制创新。 未来社区的数字化解决方案包括信息发布系统、服务系统和管理系统。信息发布系统涵盖公共服务类和社会化服务类信息,提供政策宣传、家政服务、健康医疗咨询等功能。服务系统功能需求包括办事指南、公共服务、社区工作参与互动等,旨在提高社区服务能力。管理系统功能需求则涉及院落管理、社团管理、社工队伍管理等,以实现社区治理的现代化。 最后,未来社区建设注重整合政府、社会组织、企业等多方资源,以提高社区服务的效率和质量。通过建立社区管理服务综合信息平台,提供社区公共服务、社区社会组织管理服务和社区便民服务,实现管理精简、高效、透明,服务快速、便捷。同时,通过培育和发展社区协会、社团等组织,激发社会化组织活力,为居民提供综合性的咨询和服务,促进社区的和谐发展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值