필터 지우기
필터 지우기

surface from boundary curves

조회 수: 6 (최근 30일)
Dominik Cech
Dominik Cech 2021년 8월 13일
댓글: Dominik Cech 2021년 8월 18일
Hello i have 4 boundary curves and i would like to make a surface from them do you have any tip how to do it?
And also do you have any tip if i would like to know distance and the surface betwen red and yelow curve at any point?
thank you, Dominik
  댓글 수: 2
Image Analyst
Image Analyst 2021년 8월 13일
Please attach your data for the 4 curves to make it easier for people to help you.
Also explain how you'd like to assign the surface for the missing z values. Do you just want to take the weighted-by-distance average of the 4 closest points (one closest point from each curve)? Or do you have some other recipe?
What sort of resolution do you have or require, like how many points between 0 and 80? Or 20 and 55?
Dominik Cech
Dominik Cech 2021년 8월 18일
clear all;
clc;
t= 0:.01:1;
b0 = (1-t).^3;
b1 = 3*t.*(1-t).^2;
b2 = 3*t.^2.*(1-t);
b3 = t.^3;
% cross top
P0 = [54.0982, 29.0875, 64.4223];
P1 = [48, 25, 65];
P2 = [35, 4, 67];
P3 = [25.2895, 5.3514, 68.1216];
% cross bottom
aP0 = [30.6264, 82.4986, 21.4401];
aP1 = [30, 82, 20];
aP2 = [25, 85, 14];
aP3 = [24.5166, 84.5159, 12.4509];
% head guiding
bP0 = [54.0982, 29.0875, 64.4223];
bP1 = [43, 54, 51];
bP2 = [22, 50, 32];
bP3 = [30.6264, 82.4986, 21.4401];
% bottom guiding
cP0 = [25.2895, 5.3514, 68.1216];
cP1 = [17, 28, 41];
cP2 = [20, 44, 8];
cP3 = [24.5166, 84.5159, 12.4509];
x = P0(1)*b0+P1(1)*b1+P2(1)*b2+P3(1)*b3;
y = P0(2)*b0+P1(2)*b1+P2(2)*b2+P3(2)*b3;
z = P0(3)*b0+P1(3)*b1+P2(3)*b2+P3(3)*b3;
xa = aP0(1)*b0+aP1(1)*b1+aP2(1)*b2+aP3(1)*b3;
ya = aP0(2)*b0+aP1(2)*b1+aP2(2)*b2+aP3(2)*b3;
za = aP0(3)*b0+aP1(3)*b1+aP2(3)*b2+aP3(3)*b3;
xb = bP0(1)*b0+bP1(1)*b1+bP2(1)*b2+bP3(1)*b3;
yb = bP0(2)*b0+bP1(2)*b1+bP2(2)*b2+bP3(2)*b3;
zb = bP0(3)*b0+bP1(3)*b1+bP2(3)*b2+bP3(3)*b3;
xc = cP0(1)*b0+cP1(1)*b1+cP2(1)*b2+cP3(1)*b3;
yc = cP0(2)*b0+cP1(2)*b1+cP2(2)*b2+cP3(2)*b3;
zc = cP0(3)*b0+cP1(3)*b1+cP2(3)*b2+cP3(3)*b3;
delkax=0;
delkay=0;
delkaz=0;
delkaxa=0;
delkaya=0;
delkaza=0;
delkaxb=0;
delkayb=0;
delkazb=0;
delkaxc=0;
delkayc=0;
delkazc=0;
for i=1:100
delkax(i)=(x(i+1)-x(i))^2
delkay(i)=(y(i+1)-y(i))^2
delkaz(i)=(z(i+1)-z(i))^2
delkaxa(i)=(xa(i+1)-xa(i))^2
delkaya(i)=(ya(i+1)-ya(i))^2
delkaza(i)=(za(i+1)-za(i))^2
delkaxb(i)=(xb(i+1)-xb(i))^2
delkayb(i)=(yb(i+1)-yb(i))^2
delkazb(i)=(zb(i+1)-zb(i))^2
delkaxc(i)=(xc(i+1)-xc(i))^2
delkayc(i)=(yc(i+1)-yc(i))^2
delkazc(i)=(zc(i+1)-zc(i))^2
end
delka=sum(sqrt(delkax+delkay+delkaz))
delkaa=sum(sqrt(delkaxa+delkaya+delkaza))
delkab=sum(sqrt(delkaxb+delkayb+delkazb))
delkac=sum(sqrt(delkaxc+delkayc+delkazc))
Thank you for you tips but I think I expressed myself incorectly. I have 4 points with x,y,z coordinates and I have to do bezier curve and then i would like to make a surface like is on the picture and then i would like to measure the distance betwen yellow and red curve on the surface

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2021년 8월 13일
To find the shortest distance between the red curve and the yellow curve, try this. Adapt as needed:
% Create two curves that are a list of (x,y,z) coordinates - one point per row.
xyzRed = rand(3, 100)';
xyzYellow = rand(3, 150)';
% Now we have our data and we can begin.
numPoints = size(xyzRed, 1);
distances = zeros(numPoints, 2);
for k = 1 : numPoints
thisX = xyzRed(k, 1);
thisY = xyzRed(k, 2);
thisZ = xyzRed(k, 3);
% Get distances of this point to every other point.
allDistances = sqrt((thisX - xyzYellow(:, 1)) .^ 2 + ...
(thisY - xyzYellow(:, 2)) .^ 2 + ...
(thisZ - xyzYellow(:, 3)) .^ 2)
% Find the min distance
[minDistance, indexOfMin] = min(allDistances);
% Log the closest distance and its index.
distances(k, 1) = minDistance;
distances(k, 2) = indexOfMin;
end
You can do the converse also of course. If you want the distance of the red curve from all points in the yellow curve. They will be different distances if the red and yellow curves do not have the same number of elements.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by