# java中已知两圆坐标及半径，求两圆外切线的坐标

`````` public static List<Point> getPointLocations(Point p1, Point p2){
List<Point> pointList = new LinkedList<>();
double k = (double)(p2.y-p1.y)/(double) (p2.x-p1.x);//求出斜率
double c = p1.y-k*p1.x;//求出p1点的常数系数
double k2 = -(1/k);//垂直于这条线的斜率
double c2 = p1.y+p1.x/k;//垂直线的斜率常数系数
int size = 45;//半径
double c3 = size * (Math.sqrt(k*k+1))+c;
double c4 = c - size * Math.sqrt(k*k+1);

Log.e(TAG, "getPointLocations: k:"+k+"  c:"+c+"   k2:"+k2+"  c2:"+c2+"   c3:"+c3+"  c4:"+c4);

double x1 = (c2 - c3)/(k+k2);
double y1 = k*x1+c3;

double x2 = (c2 - c4)/(k+k2);
double y2 = k*x2+c4;

double p2c = p2.y-k*p2.x;
double p2c2 = p2.y+p2.x/k;
double p2c3 = size * Math.sqrt(k*k+1)+p2c;
double p2c4 = p2c - size * (Math.sqrt(k*k+1));

double x3 = (p2c2 - p2c3)/(k+k2);
double y3 = k*x3+p2c3;

double x4 = (p2c2 - p2c4)/(k+k2);
double y4 = k*x4+p2c4;

Log.e("TAG", "getPointLocations: "+"  size   "+size+"   "+pointList.toString() );

return pointList;
}
``````
• 写回答

#### 2条回答默认 最新

• 摺耳喵 2019-11-02 09:58
关注

没理解你的意思，怎么会有四个点呢

评论

#### 悬赏问题

• ¥15 如何用matlab实现PSO算法与两种智能优化算法在30维和50维问题上的性能比较？
• ¥15 在qt的QGraphicsView和QGraphicsScene中遇到的问题
• ¥50 如何完美解决谷歌礼品卡支付不被检测
• ¥15 nslt的可用模型，或者其他可以进行推理的现有模型
• ¥15 arduino上连sim900a实现连接mqtt服务器