Published
Edited
Oct 12, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
distance(113.11529, 23.015409, 113.119871, 23.015425) // 季华园宽度,约为 460m
Insert cell
Insert cell
Insert cell
move(vec2.create(), [113.115299, 23.015409], 460, 0)
Insert cell
distance(113.115353, 23.017379, 113.1114501953125, 23.017377853393555)
Insert cell
# 计算目标点相对起点的方位(仅支持正负 90 度内)

设地心为点 O,根据起点 A、目标点 D ,得目标点方位 radCompass,东方为 0°

1. 用 OA 为法线,以 A 为起点定义平面,求 OD 与平面交点 OD'
2. 设 uAD = normalize(AD'),用两次 cross 算得北方位和东方位,用 uAD' 分别与这两个方位做映射得 x,y
3. 通过 atan2 算得方位

直线与平面交点算法:
https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-plane-and-ray-disk-intersection
Insert cell
Insert cell
(getCompass(113.108885, 23.017363, 113.149273, 23.033727) * 180) / Math.PI
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more