Making a 3D volume out of splines
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi! I am making 3D figures out of x y z coordinates. I used alphashape for this so I could also calculate the volume but alphashape creates 3D shapes which are bigger than they should be. I also used splines which creates the shape that the figures should have. However, I do not know how to make an actual 3D volume out of this like the alphashape does. An example: f.l.t.r scatterplot of the coordinates, alphashape and spline figure.
Does someone know how to make a 3D figure out of the spline figure? Or how to calculate the total volume out of this?
Thank you!
답변 (1개)
darova
2020년 6월 14일
Try this
clc,clear
load Coordinates.txt
x = Coordinates(:,1);
y = Coordinates(:,2);
z = Coordinates(:,3);
plot3(x,y,z,'.r')
for z0 = min(z):1:max(z)
ix = find(abs(z-z0)<0.3); % find indices of level
x1 = x(ix)-mean(x(ix)); % center data
y1 = y(ix)-mean(y(ix));
z1 = z(ix);
[t,r] = cart2pol(x1,y1); % convert to polar system
[t2,ix1] = sort(t); % order data by angle
x2 = x1(ix1)+mean(x(ix)); % return to original position
y2 = y1(ix1)+mean(y(ix));
% interpolate data
tt = [0; cumsum(hypot(diff(x2),diff(y2)))];
t3 = linspace(0,tt(end));
x3 = spline(tt,x2,t3);
y3 = spline(tt,y2,t3);
z3 = spline(tt,z1(ix1),t3);
line(x3,y3,z3)
end
axis vis3d
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Bounding Regions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!