hdu 4773 Problem of Apollonius

莫名其妙就AC了……

圆的反演……

神马是反演?

快去恶补奥数……

#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-9;
int dcmp(double x){return fabs(x)<eps?0:x<0?-1:1;}  
struct dot
{
    double x,y;
    dot(){}
    dot(double a,double b){x=a;y=b;}
    dot operator +(dot a){return dot(x+a.x,y+a.y);}
    dot operator -(dot a){return dot(x-a.x,y-a.y);}
    dot operator *(double a){return dot(x*a,y*a);}
    double operator *(dot a){return x*a.y-y*a.x;}
    dot operator /(double a){return dot(x/a,y/a);}
    double operator /(dot a){return x*a.x+y*a.y;}
    bool operator ==(dot a){return x==a.x&&y==a.y;}
    void in(){scanf("%lf%lf",&x,&y);}
    void out(){printf("%f %f\n",x,y);}
    dot norv(){return dot(-y,x);}
    dot univ(){double a=mod();return dot(x/a,y/a);}
    dot ro(double a){return dot(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a));}
    double mod(){return sqrt(x*x+y*y);}
    double dis(dot a){return sqrt(pow(x-a.x,2)+pow(y-a.y,2));}
};
struct cir
{
    dot o;
    double r;
    cir(){}
    cir(dot a,double b){o=a;r=b;}
    void in(){o.in();scanf("%lf",&r);}
};
struct seg
{
    dot s,e;
    seg(){}
    seg(dot a,dot b){s=a;e=b;}
};
cir sivs(dot a,dot b,dot c)  
{  
    dot dir,a1,b1;
    double t,d,w;
    t=fabs((b-a)*(c-a));   
    d=a.dis(b);  
    t/=d;
    w=0.5/t;
    dir=(b-a).norv();  
    a1=c+dir*(w/d);  
    b1=c-dir*(w/d);  
    if(fabs((b-a)*(a1-a))<fabs((b-a)*(b1-a)))  
        return cir(a1,w);
    else  
        return cir(b1,w);  
}  
cir civs(cir a,dot b)  
{  
    cir c;
    double t,x,y,s;  
    t=a.o.dis(b);  
    x=1.0/(t-a.r);  
    y=1.0/(t+a.r);  
    c.r=(x-y)/2.0;  
    s=(x+y)/2.0;  
    c.o=b+(a.o-b)*(s/t);  
    return c;  
}
seg se[2];
void comseg(dot a,double r1,dot b,double r2)  
{   
    double ang;   
    ang=acos((r1-r2)/a.dis(b));  
    se[0].s=a+(b-a).ro(ang).univ()*r1;  
    se[1].s=a+(b-a).ro(-ang).univ()*r1;  
    ang=pi-ang;  
    se[0].e=b+(a-b).ro(-ang).univ()*r2;  
    se[1].e=b+(a-b).ro(ang).univ()*r2;  
}  
int main()
{
    int T,cnt,i;
    cir a,b,a1,b1,ans[2];
    dot c;
    scanf("%d",&T);
    while(T--)
    {
        a.in();
        b.in();
        c.in();
        a1=civs(a,c);
        b1=civs(b,c);
        comseg(a1.o,a1.r,b1.o,b1.r);
        cnt=0;
        for(i=0;i<2;i++)
            if(dcmp((a1.o-se[i].s)*(se[i].e-se[i].s))==dcmp((c-se[i].s)*(se[i].e-se[i].s)))
                if(dcmp((b1.o-se[i].s)*(se[i].e-se[i].s))==dcmp((c-se[i].s)*(se[i].e-se[i].s)))
					ans[cnt++]=sivs(se[i].s,se[i].e,c);
        printf("%d\n",cnt);
        for(i=0;i<cnt;i++)
            printf("%.8f %.8f %.8f\n",ans[i].o.x,ans[i].o.y,ans[i].r);
    }
}

Problem of Apollonius

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 551    Accepted Submission(s): 124
Special Judge


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&nbsp;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
This problem is special judged.
 

Source
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值