注釈
Go to the end をクリックすると完全なサンプルコードをダウンロードできます.
測地パス#
Dijkstraのアルゴリズムを使用して2つの頂点間の測地パスを計算します
from __future__ import annotations
import pyvista as pv
from pyvista import examples
# Load a global topography surface and decimate it
land = examples.download_topo_land().triangulate().decimate(0.98)
測地線パスを新しい pyvista.PolyData
オブジェクトとして取得します.
cape_town = land.find_closest_point((0.790801, 0.264598, -0.551942))
dubai = land.find_closest_point((0.512642, 0.745898, 0.425255))
bangkok = land.find_closest_point((-0.177077, 0.955419, 0.236273))
rome = land.find_closest_point((0.718047, 0.163038, 0.676684))
a = land.geodesic(cape_town, dubai)
b = land.geodesic(cape_town, bangkok)
c = land.geodesic(cape_town, rome)
ランドサーフェスに沿ってパスをレンダリングします
p = pv.Plotter()
p.add_mesh(a + b + c, line_width=10, color='red', label='Geodesic Path')
p.add_mesh(land, show_edges=True)
p.add_legend()
p.camera_position = [
(3.5839785524183934, 2.3915238111304924, 1.3993738227478327),
(-0.06842917033182638, 0.15467201157962263, -0.07331693636555875),
(-0.34851770951584765, -0.04724188391065845, 0.9361108965066047),
]
p.show()

その道はどのくらいの長さですか.
np.float64(1.9910068513865529)
Total running time of the script: (0 minutes 9.299 seconds)