你可以从

C code获得帮助.把它移植到JAVA不应该是具有挑战性的.说明是

here.搜索/滚动到:两个圆的交点

使用此方法,找到任意两个圆的交点..让我们说(x,y).现在,只有当中心与点x,y之间的距离等于r时,第三个圆将在点x,y处相交.

情况1)如果距离(中心,点)== r,则x,y是交点.

情况2)如果距离(中心,点)!= r,则不存在这样的点.

代码(从[这里!所有学分转移到原作者):

private boolean calculateThreeCircleIntersection(double x0, double y0, double r0,

double x1, double y1, double r1,

double x2, double y2, double r2)

{

double a, dx, dy, d, h, rx, ry;

double point2_x, point2_y;

/* dx and dy are the vertical and horizontal distances between

* the circle centers.

*/

dx = x1 - x0;

dy = y1 - y0;

/* Determine the straight-line distance between the centers. */

d = Math.sqrt((dy*dy) + (dx*dx));

/* Check for solvability. */

if (d > (r0 + r1))

{

/* no solution. circles do not intersect. */

return false;

}

if (d < Math.abs(r0 - r1))

{

/* no solution. one circle is contained in the other */

return false;

}

/* 'point 2' is the point where the line through the circle

* intersection points crosses the line between the circle

* centers.

*/

/* Determine the distance from point 0 to point 2. */

a = ((r0*r0) - (r1*r1) + (d*d)) / (2.0 * d) ;

/* Determine the coordinates of point 2. */

point2_x = x0 + (dx * a/d);

point2_y = y0 + (dy * a/d);

/* Determine the distance from point 2 to either of the

* intersection points.

*/

h = Math.sqrt((r0*r0) - (a*a));

/* Now determine the offsets of the intersection points from

* point 2.

*/

rx = -dy * (h/d);

ry = dx * (h/d);

/* Determine the absolute intersection points. */

double intersectionPoint1_x = point2_x + rx;

double intersectionPoint2_x = point2_x - rx;

double intersectionPoint1_y = point2_y + ry;

double intersectionPoint2_y = point2_y - ry;

Log.d("INTERSECTION Circle1 AND Circle2:", "(" + intersectionPoint1_x + "," + intersectionPoint1_y + ")" + " AND (" + intersectionPoint2_x + "," + intersectionPoint2_y + ")");

/* Lets determine if circle 3 intersects at either of the above intersection points. */

dx = intersectionPoint1_x - x2;

dy = intersectionPoint1_y - y2;

double d1 = Math.sqrt((dy*dy) + (dx*dx));

dx = intersectionPoint2_x - x2;

dy = intersectionPoint2_y - y2;

double d2 = Math.sqrt((dy*dy) + (dx*dx));

if(Math.abs(d1 - r2) < EPSILON) {

Log.d("INTERSECTION Circle1 AND Circle2 AND Circle3:", "(" + intersectionPoint1_x + "," + intersectionPoint1_y + ")");

}

else if(Math.abs(d2 - r2) < EPSILON) {

Log.d("INTERSECTION Circle1 AND Circle2 AND Circle3:", "(" + intersectionPoint2_x + "," + intersectionPoint2_y + ")"); //here was an error

}

else {

Log.d("INTERSECTION Circle1 AND Circle2 AND Circle3:", "NONE");

}

return true;

}

调用此方法如下:

calculateThreeCircleIntersection(-2.0, 0.0, 2.0, // circle 1 (center_x, center_y, radius)

1.0, 0.0, 1.0, // circle 2 (center_x, center_y, radius)

0.0, 4.0, 4.0);// circle 3 (center_x, center_y, radius)

此外,将EPSILON定义为适合您的应用程序要求的小值

private static final double EPSILON = 0.000001;

注意:也许有人应该测试并验证结果是否正确.我找不到任何简单的方法.我尝试过的基本案例的工作

Java如何定义三个圆_java – 以编程方式查找三个圆的交叉点相关推荐

  1. java 高并发第三阶段实战_JAVA多线程编程实战视频-第三阶段(共80节)

    高并发编程第三阶段01讲 AtomicInteger多线程下测试讲解 高并发编程第三阶段02讲 AtomicInteger API详解,以及CAS算法详细介绍 高并发编程第三阶段03讲 利用CAS构造 ...

  2. Java8新的异步编程方式 CompletableFuture(三)

    前面两篇文章已经整理了CompletableFuture大部分的特性,本文会整理完CompletableFuture余下的特性,以及将它跟RxJava进行比较. 3.6 Either Either 表 ...

  3. java中定义一个栈容器_Java 容器之 Connection栈队列及一些常用

    集合家族图 ---|Collection: 单列集合 ---|List: 有存储顺序 , 可重复 ---|ArrayList: 数组实现 , 查找快 , 增删慢 ---|LinkedList: 链表实 ...

  4. java里break的使用方法_Java中break的第三种用法说明

    在Java中,break语句有三种用法,第一种是用于终止switch语句中的语句序列,第二种是用于退出循环,然而第三种是用作goto语句的"文明"形式! 我们知道,goto语句会破 ...

  5. java如何定义一个字符栈_Java性能优化之字符串优化处理

    本文来源于: https://blog.csdn.net/xlgen157387/article/details/51870322 1.String对象 String对象是java中重要的数据类型,在 ...

  6. java中三种方法_Java文件I/O的三种方法

    Java文件I/O的三种方法 RandomAccessFile是不属于InputStream和OutputStream类系的.实际上,除了实现DataInput和DataOutput接口之外(Data ...

  7. java对象赋值给另一个对象_java面向对象编程

    对象,从字面意思来看就是我们面对的物象.由此便可以知道,万事万物皆为对象.比如:一台电脑,一辆汽车,一部手机等等都是对象. 比如我们想要买一部手机,我们想要内存大一点的,最新款的,CPU 运算快一点的 ...

  8. java主类与源代码名称_Java高级编程基础:类文件结构解析,看穿Class代码背后的秘密...

    类文件结构 在说完了JVM内部结构后,接下来我们需要说一下另外一个非常重要的基础概念Class类结构. 我们既然知道了开发的Java源代码会首先被编译成字节码文件保存,JVM的类加载器会读取这些文件内 ...

  9. java对象不会被改变_Java 并发编程(二)对象的不变性和安全的公布对象

    二.安全公布 到眼下为止,我们重点讨论的是怎样确保对象不被公布,比如让对象封闭在线程或还有一个对象的内部.当然,在某些情况下我们希望在多个线程间共享对象,此时必须确保安全地进行共享.然而,假设仅仅是像 ...

最新文章

  1. linux脚本case语句,shell中的case语句,数组及函数
  2. ERP顾问在甲方好还是乙方好?
  3. BizTalk开发系列(三十一)配置和使用HTTP适配器
  4. 强化学习4——无模型预测(蒙特卡洛法和TD法)
  5. 【Java 笔记】 java 格式化输出
  6. 数学--数论---P4718 Pollard-Rho算法 大数分解
  7. 爱奇艺怎么看不了电视剧和视频
  8. 盘一盘 synchronized (一)—— 从打印Java对象头说起
  9. linux部署Oracle数据库--安装篇
  10. tensorflow实现对彩色图像的均值滤波
  11. 【sklearn第四讲】数据集变换
  12. Struts2出现的问题:
  13. 怎么判断前轮左右的位置_老司机教你如何用方向盘,判断左右车轮位置,新手司机一看就会!...
  14. Gephi入学教程基础记录
  15. 将数据与OpenLayers结合在一起
  16. 什么是a站、b站、c站、d站、e站、f站、g站、h站、i站、j站、k站、l站、m站、n站…z站?
  17. CATIA V5 R24 2014安装教程
  18. package ‘gdm‘ has no installation candidate
  19. 手机ppi排行测试软件,2018主流厂商旗舰手机屏幕测试数据汇总和子项排名统计...
  20. 关于软件功能点评估的问题(一)

热门文章

  1. IF_BSP_WD_HISTORY_STATE_DESCR~IS_RESTORABLE的用法
  2. 使用Java操作汉字编码的一个例子
  3. WebSocket服务器和客户端的一对多连接
  4. SAP专家通过调试的方式解决过的SAP UI5问题列表
  5. 指纹图谱相似度评价软件_基于指纹图谱和网络药理学对当归四逆汤中桂枝的Qmarker预测分析...
  6. linux非权限安装bioperl,BioPerl安装指南:Unix/Linux/Windows下的安装
  7. Redis的Linux单机版安装
  8. 张洪斌 html css,网页设计与制作教学课件作者HTML+CSS+JavaScript张洪斌教学资源KC11120100008_设计文档课件.doc...
  9. 是不是一个东西_迷你世界:一个金币就能买到稀有武器?这么良心的售货机在哪领...
  10. 程序员新动向!大龄困惑详解!