現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
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
- first search curve (any x)
- second search curve (any y)
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
t = [0 .. 2*pi]
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)