當(dāng)前位置:
首頁 >
JAVA已知圆心经纬度和半径求圆周点的经纬度
發(fā)布時(shí)間:2024/3/13
66
豆豆
生活随笔
收集整理的這篇文章主要介紹了
JAVA已知圆心经纬度和半径求圆周点的经纬度
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
JAVA已知圓心經(jīng)緯度和半徑求圓周點(diǎn)的經(jīng)緯度
項(xiàng)目中遇到一個(gè)需求,需要根據(jù)傳入的圓心經(jīng)緯度和半徑參數(shù)獲得圓周點(diǎn)的經(jīng)緯度,在網(wǎng)上查詢了很多沒有找到能用的算法,從GPT中獲取到了一個(gè)簡潔的用java實(shí)現(xiàn)的算法,在此記錄一下,供大家參考。已親自在gis球上驗(yàn)證計(jì)算結(jié)果正確無誤。
/*** 根據(jù)圓心經(jīng)緯度和半徑求圓周點(diǎn)的經(jīng)緯度* @param lat 緯度(單位:度)* @param lon 經(jīng)度(單位:度)* @param radius 半徑(單位:千米)* @param numPoints 點(diǎn)的個(gè)數(shù)* @return*/public static List<Point> calculatePoints(double lat, double lon, double radius, int numPoints) {double d = radius / 6371.0; // convert radius from meters to radiansList<Point> points = new ArrayList<>();for (int i = 0; i < numPoints; i++) {double brng = 2 * Math.PI * i / numPoints;double latRad = Math.asin(Math.sin(Math.toRadians(lat)) * Math.cos(d) + Math.cos(Math.toRadians(lat)) * Math.sin(d) * Math.cos(brng));double lonRad = Math.toRadians(lon) + Math.atan2(Math.sin(brng) * Math.sin(d) * Math.cos(Math.toRadians(lat)), Math.cos(d) - Math.sin(Math.toRadians(lat)) * Math.sin(latRad));Point point = new Point(Math.toDegrees(lonRad), Math.toDegrees(latRad));points.add(point);}return points;}/*** 點(diǎn)*/@Data@NoArgsConstructor@AllArgsConstructorpublic static class Point {/*** 經(jīng)度*/private double longitude;/*** 緯度*/private double latitude;}總結(jié)
以上是生活随笔為你收集整理的JAVA已知圆心经纬度和半径求圆周点的经纬度的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AI小程序开放2个超级入口,还能分享朋友
- 下一篇: 【C语言练习——打印空心上三角及其变形】