问题
I have 3 vectors of position data : x
, y
and z
x = [0.1524 0.1219 0.0610 0.0914 0.0610 0.1219 0.0305 0.0914 0.2134 0.0610 0.1219
0.0305 0.0610 0.1219 0.0914 0.1524 0.0610 0.1524 0.0610 0.0610 0.0610 0.0610
0.1524 0.0914 0.0610 0.1524 0.0610 0.2134 0.0610 0.0914 0.1524];
y = [0.1219 0.1524 0.0305 0.1219 0.1524 0.1524 0.0610 0.1219 0.1219 0.1524 0.1524
0.0610 0.0914 0.1524 0.1829 0.1829 0.0914 0.1829 0.2134 0.0914 0.2134 0.0914
0.1829 0.0610 0.0914 0.1829 0.0914 0.1829 0.2134 0.1219 0.1829];
z = [0.0305 0.0305 0.0610 0.0610 0.0610 0.0610 0.0914 0.0914 0.0914 0.0914 0.0914
0.1219 0.1219 0.1219 0.1219 0.1219 0.1524 0.1524 0.1524 0.1829 0.1829 0.2134
0.2134 0.2438 0.2438 0.2438 0.2743 0.2743 0.2743 0.3048 0.3048];
I was wondering how I could apply convex-hull on this set? Matlab doesn't accept this format but regularly spaced grid.
回答1:
You can use convhulln to compute the convex hull for dimensions grater than 2. If you want to plot the results, use trisurf. See the sample code for your input below:
X = [x;y;z]'; %# involves a 3D point on each row
K = convhulln(X);
trisurf(K,X(:,1),X(:,2),X(:,3))
来源:https://stackoverflow.com/questions/13247475/convhull-in-matlab