Skip to content

Surface-fitting functionality #670

Answered by marcomusy
jkissi asked this question in Q&A
Discussion options

You must be logged in to vote

Yes :)
You can use warp:

from vedo import Grid, Points, Arrows, show
import numpy as np
np.random.seed(2)

surf = Grid([0,0,0], res=[25,25])
idxs = np.random.randint(0, surf.npoints, 10)  # pick 10 indices
pts = surf.points(idxs)

ptsource, pttarget = [], []
for pt in pts:
    pt1 = pt + [0, 0, np.random.randn(1)[0] * 0.1]
    pt2 = surf.closest_point(pt1)
    ptsource.append(pt2)
    pttarget.append(pt1)

warped = surf.warp(ptsource, pttarget, mode='2d')
warped.color("b4").lc('light blue').wireframe(False).lw(1)

apts = Points(pttarget, r=15, c="r")
arrs = Arrows(ptsource, pttarget, c='k')

show(warped, apts, arrs, axes=1, viewup="z").close()

Note that this is more of a "splining" than …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by marcomusy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants