根据一点计算六边形

问题描述 投票:0回答:1

这是我的问题:

我需要确定六边形/多边形的正确坐标(纬度、经度)。 我有输入:

  • 纬度(双)
  • 经度(双)
  • 半径(圆的)(整数)

采取的步骤:

  1. 给定的点平移半径的长度,得到第一个点:lat = lat + radius

  2. 获得新的坐标(rad是以弧度为单位的角度theta)

    result.x = Math.cos(rad) * lat + Math.sin(rad) * lon;
    结果.y = Math.cos(rad) * lon - Math.sin(rad) * lat ;

问题:将半径设置为 1 会返回一个巨大的结果,一个比我想要的大得多的六边形(从某种意义上说,它们几乎是整个地球:( ), 谁能告诉我为什么会发生这种情况以及如何发生我修好了吗

all code here

and here 如您所见,对于输入 -71.24 43.06,我得到一个坐标为 2 83 的顶点,它很大

enter image description here

java geometry coordinates geography rotational-matrices
1个回答
0
投票

我在一个 flutter 项目中也需要它,经过一些研究我发现了turf.js 目标方法

通过使用它,你可以得到围绕一个中心点的六边形的6个点,基于一定的半径:

Point center = Point(coordinates: Position(latitude, longitude)); // Your center point

Point p1 = destination(center, radius, 0, Unit.meters); // top
Point p2 = destination(center, radius, 60, Unit.meters); // top left
Point p3 = destination(center, radius, 120, Unit.meters);  // bottom left
Point p4 = destination(center, radius, 180, Unit.meters); // bottom
Point p5 = destination(center, radius, 240, Unit.meters); // bottom right
Point p6 = destination(center, radius, 300, Unit.meters); // top right

对此不确定,但 Turf 似乎也正在移植到 Java here

© www.soinside.com 2019 - 2024. All rights reserved.