求两个相交圆的交点的公式

半径为R的圆心为A,坐标为(x,y)  半径为S的圆心为B,坐标为(a,b)  两圆交点为C,D   AB与CD的交点为E,坐标为(X0,Y0)  过C点垂线与过E点水平线交点为F   令L为AB长度,K1为线AB的斜率,K2为线CD的斜率 

 则L=√[(a-x)²+(b-y)²]   K1=(b-y)/(a-x)   K2=-1/K1   CE²=R²-AE²    CE²=S²-EB²=S²-(AB-AE)²=S²-(L-AE)²=S²-L²-AE²+2L*AE    故AE=(R²-S²+L²)/2L    AE/L=(R²-S²+L²)/2L²      X0=x+(a-x)AE/L=x+(a-x)(R²-S²+L²)/(2L²)     Y0=y+K1(X0-x)      R2=CE²=R²-(X0-x)²-(Y0-y)²     R2=CF²+EF²=(K2EF)²+EF²=(1+K2²)EF²      故EF=√[R2/(1+K2²)]  


所以,C,D坐标计算公式为  Xc=X0-EF=X0-√[R2/(1+K2²)]     Yc=Y0+K2(Xc-X0) 

                                           Xd=X0+EF=X0+√[R2/(1+K2²)]   Yd=Y0+K2(Xd-X0)

  • 5
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
这个问题需要用到一些基本的地理学知识和公式,以下是一个简单的 Java 实现: ```java public class IntersectionPoint { // 地球半径,单位为米 private static final double EARTH_RADIUS = 6378137; // 计算两点间的距离,返回单位为米 private static double distance(double lat1, double lng1, double lat2, double lng2) { double radLat1 = Math.toRadians(lat1); double radLat2 = Math.toRadians(lat2); double a = radLat1 - radLat2; double b = Math.toRadians(lng1) - Math.toRadians(lng2); double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); return s * EARTH_RADIUS; } // 计算方向角,返回值为角度数 private static double direction(double lat1, double lng1, double lat2, double lng2) { double dx = Math.cos(Math.toRadians(lat2)) * Math.sin(Math.toRadians(lng2 - lng1)); double dy = Math.cos(Math.toRadians(lat1)) * Math.sin(Math.toRadians(lat2)) - Math.sin(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.cos(Math.toRadians(lng2 - lng1)); double angle = Math.atan2(dx, dy); return (Math.toDegrees(angle) + 360) % 360; } // 计算交点坐标,返回值为经纬度数组 private static double[] intersection(double lat1, double lng1, double dir1, double lat2, double lng2, double dir2) { double d = distance(lat1, lng1, lat2, lng2); double radDir1 = Math.toRadians(dir1); double radDir2 = Math.toRadians(dir2); double radLat1 = Math.toRadians(lat1); double radLat2 = Math.toRadians(lat2); double radLng1 = Math.toRadians(lng1); double radLng2 = Math.toRadians(lng2); double x = Math.sin(radDir1) * Math.cos(radDir2) * Math.sin(radLat2 - radLat1); double y = Math.sin(radDir1) * Math.cos(radDir2) * Math.cos(radLat2 - radLat1) * Math.sin(radLng2 - radLng1); double z = Math.cos(radDir1) * Math.sin(radDir2) * Math.sin(radLat2 - radLat1) * Math.cos(radLng2 - radLng1); double a = Math.pow(x, 2) + Math.pow(y, 2) + Math.pow(z, 2); double b = 2 * EARTH_RADIUS * (x * (radLng2 - radLng1) + y * (radLat2 - radLat1) + z * (Math.PI / 2 - radLat2)); double c = Math.pow(EARTH_RADIUS, 2) * Math.pow(d, 2) - Math.pow(x * EARTH_RADIUS * (radLng2 - radLng1), 2) - Math.pow(y * EARTH_RADIUS * (radLat2 - radLat1), 2) - Math.pow(z * EARTH_RADIUS * (Math.PI / 2 - radLat2), 2); double delta = Math.pow(b, 2) - 4 * a * c; if (delta < 0) { return null; } double t = (-b + Math.sqrt(delta)) / (2 * a); double lat = Math.asin(Math.sin(radLat1) * Math.cos(t) + Math.cos(radLat1) * Math.sin(t) * Math.cos(radDir1)); double lng = radLng1 + Math.atan2(Math.sin(t) * Math.sin(radDir1) * Math.sin(radLat1), Math.cos(t) - Math.sin(radLat1) * Math.sin(lat)); return new double[]{Math.toDegrees(lat), Math.toDegrees(lng)}; } public static void main(String[] args) { double lat1 = 39.9042; double lng1 = 116.4074; double dir1 = 30; double lat2 = 31.2304; double lng2 = 121.4737; double dir2 = 220; double[] intersection = intersection(lat1, lng1, dir1, lat2, lng2, dir2); if (intersection == null) { System.out.println("No intersection point."); } else { System.out.printf("Intersection point: (%f, %f)\n", intersection[0], intersection[1]); } } } ``` 以上代码假设输入的经纬度为 WGS84 坐标系下的经纬度,计算结果也是 WGS84 坐标系下的经纬度。如果需要用其他坐标系,需要进行转换。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值