이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How to find the extremum search curve of a parametric surface?
조회 수: 5 (최근 30일)
이전 댓글 표시
I have a parametric surface S(u,v). Can anybody help me solve the differential equation to find the extremum search curve like the pictures below?
These curves passe the local maxima and minima of the surface (z direction).
The extremum search curve is represented as:

Example:
syms u v;
x=u;
y=v;
z=sin(u).*cos(v)-1/8*u*v;
figure; fsurf(x,y,z,[0 2*pi 0 2*pi]);axis equal

or

Thank you so much!
댓글 수: 5
DAT THAN TRONG KHANH
2019년 7월 8일
Thank you for your answer.
For finding the local extrema, I can use this code (Image Processing Toolbox)
clc
syms u v;
x=u;
y=v;
z=sin(u).*cos(v)-1/8*u*v;
%figure; fsurf(x,y,z,[0 2*pi 0 2*pi]);axis equal
deltaU=0.2; deltaV=0.2;
Ui=0:deltaU:2*pi;
Vi=0:deltaV:2*pi;
[ui, vi] = meshgrid(Ui,Vi);
SX = double(subs(x, {u v}, { ui vi }));
SY = double(subs(y, {u v}, { ui vi }));
SZ = double(subs(z, {u v}, { ui vi }));
figure; surf(SX, SY, SZ); % ith patch of a piecewise surface3
%axis equal
xlabel('x');ylabel('y');xlabel('z');
ix = find(imregionalmax(SZ));
iy = find(imregionalmax(-SZ));
hold on
plot3(SX(ix),SY(ix),SZ(ix),'r*','MarkerSize',24)
plot3(SX(iy),SY(iy),SZ(iy),'b*','MarkerSize',24)
But I want to find the extremum search curve as figure above.
DAT THAN TRONG KHANH
2019년 7월 8일
There are 4 local maxima points and 3 local minima points.

When I solve the differential equation, I just get 2 extremum search curves.

채택된 답변
darova
2019년 7월 8일
If you have specific point (local max or min) you can substitute (x0,y0) in your function



댓글 수: 16
DAT THAN TRONG KHANH
2019년 7월 8일
Can you show the Matlab code for finding the second search curve? (the red curve in your figure)
Thank you!
darova
2019년 7월 8일
clc,clear
x = 0:0.5:2*pi;
y = 0:0.5:2*pi;
[X,Y] = meshgrid(x,y);
z = @(x,y) sin(x).*cos(y)-1/8*x.*y;
Z = z(X,Y);
ind = find(imregionalmax(Z));
h = surf(X,Y,Z,'EdgeColor','none'); % display surface without edges
alpha(h,0.5) % set transparency
hold on
scatter3(X(ind),Y(ind),Z(ind)) % display local maximums
% choose 3-th local max
y1 = x*0 + Y(ind(3));
x1 = y*0 + X(ind(3));
plot3(x,y1,z(x,y1)) % horizontal line
plot3(x1,y,z(x1,y)) % vertical line
hold off
DAT THAN TRONG KHANH
2019년 7월 9일
편집: DAT THAN TRONG KHANH
2019년 7월 9일
Thank you so much!
But I also confuse about this case.
How to find the search curve for this parametric surface:
clear all
clc
syms u v;
x=u+v;
y=@(u,v)u-1/8*v.^2;
z=sin(u).*cos(v)-1/8*u*v;
figure; fsurf(x,y,z,[0 2*pi 0 2*pi]);axis equal
Thank you for your support!
DAT THAN TRONG KHANH
2019년 7월 9일
편집: DAT THAN TRONG KHANH
2019년 7월 9일
for example:
clc,clear
ui = 0:0.2:2*pi;
vi = 0:0.2:2*pi;
[U,V] = meshgrid(ui,vi);
x=@(u,v)u+v;
y=@(u,v)u-1/8*v.^2;
z = @(u,v) sin(u).*cos(v)-1/8*u.*v;
X=x(U,V);
Y=y(U,V);
Z = z(U,V);
figure; surf(X,Y,Z); axis equal
shading interp
colormap winter
%%
ind1 = find(imregionalmax(Z));
ind2 = find(imregionalmax(-Z));
hold on
scatter3(X(ind1),Y(ind1),Z(ind1),'r') % display local maximums
scatter3(X(ind2),Y(ind2),Z(ind2),'b') % display local minimums
darova
2019년 7월 9일
What if forget about functions and work with numerical data only?
i1 = ind1(3);
x1 = linspace(min(X(:)),max(X(:)),20);
y1 = x1*0 + Y(i1);
x2 = x1*0 + X(i1);
y2 = linspace(min(Y(:)),max(Y(:)),20);
z1 = griddata(X,Y,Z, x1, y1);
z2 = griddata(X,Y,Z, x2, y2);
hold on
plot3(x1,y1,z1,'.-r')
plot3(x2,y2,z2,'.-r')
DAT THAN TRONG KHANH
2019년 7월 10일
Thank you for your answer!.
Actually, I do the research for controlling the distance ds in real space definded on parametric domain of the surface.

We have two problems like the figures below
- A spiral curve in parametric domain,
is the extremum point of the surace that was determined using the extremum search curve.

- An an Archimedean spiral

With a given m and ds (example m=50, ds=0.2), how to generate the point in the real space. I also focus on the NURBS surface. But firstly, Can you help me solve this problem with the parametric surface above?
You can see more details in the attachment file.
Thank you so much!
darova
2019년 7월 10일
My plesure!
Use formula you show above to generate x and y data


Use griddata to generate z

But! If you take a closer look you will see that ds is different!

You can interpolate the curve, if it's important to you
There is INTERPARC
% x3, y3, z3 - 3D curve
% x3 = t/(2*pi)*cos(50*t) + ...
pt = interparc(t/t(end),x3,y3,z3); % it wants t = [0 .. 1]
plot3(pt(:,1),pt(:,2),pt(:,3),'.-b')
Or it can be done manually (google search: arc length interpolation)
dx2 = diff(x3).^2;
dy2 = diff(y3).^2;
dz2 = diff(z3).^2;
L = cumsum(sqrt(dx2+dy2+dz2));
L = [0 L];
L4 = linspace(0,L(end),100); % 100 equal segments
% L4 = 0 : 0.2 : L(end) % equal segments of length 0.2
x4 = interp1(L,x3,L4);
y4 = interp1(L,y3,L4);
z4 = interp1(L,z3,L4);
plot3(x4,y4,z4,'.-b')
DAT THAN TRONG KHANH
2019년 7월 10일
편집: DAT THAN TRONG KHANH
2019년 7월 10일
Thank you for your quick answer!
Can you show me your full code of this example?
I just do and get the result like the figure below:
figure; surf(X,Y,Z); axis equal
shading interp
colormap winter
hold on
plot3(x1,y1,z1,'.-r')
plot3(x2,y2,z2,'.-r')
%
% x3, y3, z3 - 3D curve
% t=0:0.05:3*pi;
t=linspace(0,2*pi,100);
x3 = t./(2*pi).*cos(5.*t)+X(i1);
y3 = t./(2*pi).*sin(5.*t)+Y(i1);
z3 = griddata(X,Y,Z,x3,y3);
pt = interparc(t/t(end),x3,y3,z3); % it wants t = [0 .. 1]
hold on
plot3(pt(:,1),pt(:,2),pt(:,3),'.-b')
axis equal

I want to map the spiral curve onto full the real space.
Thank you so much!
darova
2019년 7월 10일
Your code is correct. I used this code for my example
x3 = t.*cos(10*t) + X(i1);
y3 = t.*sin(10*t) + Y(i1);
I want to map the spiral curve onto full the real space.
interparc can't generate data because of NaN numbers
I just divided data into groups and interpolate
DAT THAN TRONG KHANH
2019년 7월 11일
편집: DAT THAN TRONG KHANH
2019년 7월 11일
Thank your for your answer!
I have a question about the error of this interpolation (using interparc function and griddata function). How to control the error for this interpolation?
And, I think this method has a problem in the boundary of the surface. We can not obtain the points in boundary surface.
Thank you so much!
darova
2019년 7월 11일
This is data you generated (x,y)

This is data you get after griddata (some Z points don't have values NaN)
Only black lines are used int interpolation

Maybe increase number of points when you generate the data? Will you be satisfied with it?
t = linspace(0,14*pi,1E4);
DAT THAN TRONG KHANH
2019년 7월 11일
Thank you for your answer.
I know that you said. And also, when you set m=5 in this example because we divided data into groups, I want to ask you that how to control the number of spiral turns in full surface? Example, I want to set the number of spiral turns is 50 in full surface.
Otherway, I want to control the step of spiral turn in Z axis instead (example the step size is 1).
Thank you very much for big supports!
darova
2019년 7월 11일
You welcome!
Imagine you have a function

At point (t = 2pi) you want r = max. Think how to change your function such that R=max and 50 loops/cycles

About Z direction:
That is how z(t) data looks like. Think how to get t of those points
Look HERE

But don't know about NaN numbers
DAT THAN TRONG KHANH
2019년 7월 12일
편집: DAT THAN TRONG KHANH
2019년 7월 17일
Thank you for your answer,
I have a Bspline surface like that:

Can you help me to generate the parametric curve (the spiral curve above) that is mapped into the BSpline surface with the same method above?
Thank you so much!
darova
2019년 7월 12일
You have to learn/understand how griddata works. You already have X,Y and Z data
Generate x,y and use griddata to calculate z
Use interparc if interpolation is needed
It is easy. Gool luck!
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)