pyvista.DataSetFilters.align#

DataSetFilters.align(target, max_landmarks=100, max_mean_distance=1e-05, max_iterations=500, check_mean_distance=True, start_by_matching_centroids=True, return_matrix=False)[ソース]#

データセットを別のデータセットに位置合わせします.

2つのメッシュのポイントを揃えるために,反復的な最も近いポイントアルゴリズムを使用します.VTK クラス vtkIterativeClosestPointTransform を参照してください.

パラメータ:
targetpyvista.DataSet

位置合わせする対象のデータセット.

max_landmarksint, default: 100

ランドマークの最大数.

max_mean_distancefloat, default: 1e-5

収束のための最大平均距離.

max_iterationsint, default: 500

最大反復回数.

check_mean_distancebool, default: True

平均距離の収束を確認するかどうか.

start_by_matching_centroidsbool, default: True

重心のマッチングによって位置合わせを開始するかどうか.デフォルトはTrue.

return_matrixbool, default: False

変換行列と位置合わせされたメッシュを返します.

戻り値:
alignedpyvista.DataSet

ターゲットメッシュに位置合わせされたデータセット.

matrixnumpy.ndarray

入力データセットをターゲットデータセットに変換するための変換行列.

円柱を作成し,それを平行移動させ,反復的に最も近い点を使用してメッシュを元の位置に合わせます.

>>> import pyvista as pv
>>> import numpy as np
>>> source = pv.Cylinder(resolution=30).triangulate().subdivide(1)
>>> transformed = source.rotate_y(20).translate([-0.75, -0.5, 0.5])
>>> aligned = transformed.align(source)
>>> _, closest_points = aligned.find_closest_cell(
...     source.points, return_closest_point=True
... )
>>> dist = np.linalg.norm(source.points - closest_points, axis=1)

ソースメッシュ,変換されたメッシュ,位置合わせされたメッシュを可視化します.

>>> pl = pv.Plotter(shape=(1, 2))
>>> _ = pl.add_text('Before Alignment')
>>> _ = pl.add_mesh(
...     source, style='wireframe', opacity=0.5, line_width=2
... )
>>> _ = pl.add_mesh(transformed)
>>> pl.subplot(0, 1)
>>> _ = pl.add_text('After Alignment')
>>> _ = pl.add_mesh(
...     source, style='wireframe', opacity=0.5, line_width=2
... )
>>> _ = pl.add_mesh(
...     aligned,
...     scalars=dist,
...     scalar_bar_args={
...         'title': 'Distance to Source',
...         'fmt': '%.1E',
...     },
... )
>>> pl.show()
../../../_images/pyvista-DataSetFilters-align-1_00_00.png

ソースとターゲットの平均距離がほぼゼロであることを示します.

>>> np.abs(dist).mean()  
9.997635192915073e-05