两个圆的交点面积 [英] Area of Intersection between Two Circles

查看:23
本文介绍了两个圆的交点面积的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定两个圆圈:

  • C1 at (x1, y1) 与 radius1
  • C2 at (x2, y2) 与 radius2
  • C1 at (x1, y1) with radius1
  • C2 at (x2, y2) with radius2

你如何计算他们相交的面积?当然,所有标准数学函数(sincos 等)都可用.

How do you calculate the area of their intersection? All standard math functions (sin, cos, etc.) are available, of course.

推荐答案

好的,使用 Wolfram 链接和 Misnomer 的提示查看方程 14,我使用我列出的变量和中心之间的距离推导出了以下 Java 解决方案(可以很容易地从中派生出来):

Okay, using the Wolfram link and Misnomer's cue to look at equation 14, I have derived the following Java solution using the variables I listed and the distance between the centers (which can trivially be derived from them):

Double r = radius1;
Double R = radius2;
Double d = distance;
if(R < r){
    // swap
    r = radius2;
    R = radius1;
}
Double part1 = r*r*Math.acos((d*d + r*r - R*R)/(2*d*r));
Double part2 = R*R*Math.acos((d*d + R*R - r*r)/(2*d*R));
Double part3 = 0.5*Math.sqrt((-d+r+R)*(d+r-R)*(d-r+R)*(d+r+R));

Double intersectionArea = part1 + part2 - part3;

这篇关于两个圆的交点面积的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆