morphing a surface over 3D data
14 views (last 30 days)
Show older comments
Hi everyone!
I have a set of 3D data (nodes identified by x,y,z coordinates) that define a sort of irregular "dome/cupola".
I have to find a surface that fits that nodes (in other words a sort of morphing of a plane over the points).
I've tried "Curve fitting toolbox", but the provided fittings are too simple and cannot fit the data...do you have any suggestions?
Thank you in advance! ;)
5 Comments
Walter Roberson
on 29 Oct 2022
That is a completely different question.
https://www.mathworks.com/help/matlab/ref/triangulation.html
https://www.mathworks.com/help/matlab/ref/delaunaytriangulation.html
Answers (3)
Walter Roberson
on 29 Oct 2022
I have to find a surface that fits that nodes
Suppose there was a unique way of finding a surface given a set of nodes -- a way of finding "the" one and only surface that fit the nodes, that (by hypothesis) there is only exactly one such surface. So apply that hypothetical function
S0 = fit_a_unique_surface(x, y, z)
Now construct
r = rand(2, 3);
S1 = fit_a_unique_surface([x, r(1,1)], [y, r(1,2)], [z, r(1,3)])
S2 = fit_a_unique_surface([x, r(2,1)], [y, r(2,2)], [z, r(2,3)])
That is, S1 is the hypothetical unique surface that fits all of the original points and as well one additional point, and S2 is the hypothetical unique surface that fits all of the original points and as well a different additional point. By hypothesis, S1 and S2 are unique surfaces, but they would have to be different surfaces because they fit a different set of points. But all of S0, S1, and S2 all to through all of the original points exactly, because otherwise the function has no managed to fit a surface to the points. We then have the situation that there is a surface S0 that goes through a set of points x y z exactly, and a different surface S1 that goes through x y z exactly (and as well an additional point), and a different surface yet S2 that goes through x y z exactly (and as well a different additional point.) This is a contradiction on the hypothesis that there is a unique surface that fits a set of points exactly, and shows that if there is a mechanical algorithm that can fit some surface through x y z exactly, then it follows that there are an infinite number of other surfaces that could also be generated that fit through x y z exactly -- each also going through any of an infinite number of specified additional points.
We have a contradiction, and we are now faced with two possibilities:
- either it is not possible to mechanically fit any surface through a given set of x y z points; OR
- alternately, that it is not possible for such a surface to be unique
Lagrange and (I think it was) Newton showed that it is possible to fit some surface through a finite list of points (a polynomial surface.) And so we are left with the conclusion:
Although you can fit functions through a finite list of points, the functions cannot possibly be unique. You cannot find "one true model" that explains a given set of points, there are an infinite number of models.
And furthermore... if you have a particular model that fits a given set of points, and you have no constraints on the form of valid models, then since the number of different models that fit the points is literally infinite, then the probability that you have obtained the "right" model is 1/infinity -- which is zero.
Given a finite set of points and no constraints as to what the mathematical form of the model is, the probability that any model you might mechanically find given the points is the "correct" model, is mathematically ZERO.
So... you need to rethink what you are doing.
Now, if there are constraints as to what the forms of the models are, such as if you constrain to multinomials with a given maximum degree, then it would be meaningful to calculate the fit.
0 Comments
J. Alex Lee
on 29 Oct 2022
It's hard to give specific ideas without knowing the shape, but...
"The final goal is to obtain a triangulated surface that connects the nodes and can be exported in STL file"
Assuming then that you don't actually need an analytical functional representation, and assuming from the dome/copula description that z = fn(x,y) is a good way to represent it, and assuming you are not directly triangulating on your nodal data because it isn't dense/sprase enough to your liking:
Maybe scatteredInterpolant will help you. Its default is linear interpolation, but there is an option for "natural", whatever that means, but will be a c1 continuous interpolant.
If you can somehow define a triangulated or triangulatable set of points (x,y) on which you want to "build up" your dome (or like a membrane you want to bring down on it), similar to the wording you used in the title, then you can just feed that into your scatteredInterpolant.
%% generate some kind of dome shape for illustration
m = 7;
N = 2*m+1;
L = membrane(5,m);
x = randi(N,[N,N]);
y = randi(N,[N,N]);
k = sub2ind([N,N],y,x);
z = L(k);
[p,a] = unique([x(:),y(:)],"rows");
x = x(a);
y = y(a);
z = z(a);
plot3(x,y,z,'.')
view(3)
%% define an underlying mesh
% you can do it however you want, but I use grid for regularity
% and then triangulate to get uniform size *in the projection onto xy plane*
M = 31;
[xn,yn] = meshgrid(linspace(1,N,M));
% triangulate
T = delaunay(xn(:),yn(:));
%% interpolant on original xyz data
% use natural method for c1 continuous (continuous derivatives)
F = scatteredInterpolant(x,y,z,"natural");
% evaluate interpolant at mesh
zn = F(xn,yn);
% final mesh
figure(2)
trimesh(T,xn,yn,zn);
0 Comments
See Also
Categories
Find more on Delaunay Triangulation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!