Last active
December 18, 2020 14:59
-
-
Save shspage/51e35ae87bd76cfc413268466f991ab5 to your computer and use it in GitHub Desktop.
グリッド上の選択点を元に曲面を補完するテスト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import numpy as np | |
from scipy.interpolate import griddata | |
def func(): | |
bpy.ops.object.mode_set(mode='OBJECT') | |
grid = bpy.data.objects['Grid'] | |
vs = grid.data.vertices | |
points = [] | |
values = [] | |
for v in [v for v in vs if v.select]: | |
points.append(v.co.xy) | |
values.append(v.co.z) | |
xi = np.array([v.co.xy for v in vs]) | |
zi = griddata(np.array(points), np.array(values), | |
xi, method='cubic') | |
for v,z in zip(vs, zi): | |
v.co.z = z | |
func() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment