How to rotate a fsurf plot

7 ビュー (過去 30 日間)
Stephan
Stephan 2018 年 5 月 7 日
回答済み: Stephan 2018 年 5 月 8 日
Hello everyone,
the following code rotates the plot that is produced by the function surf().
%example for surf:
hsurf= surf(peaks(20));
direction = [1 0 0];
rotate(hsurf,direction,25);
It does not work, however, for the function fsurf():
% example fsurf:
f = @(x,y) x;
g = @(x,y) y;
h = @(x,y) x*0;
hfsurf = fsurf(f,g,h);
direction = [1 0 0];
rotate(hfsurf,direction,25);
Could someone tell me how to fix this problem?
Thanks!

採用された回答

Stephan
Stephan 2018 年 5 月 8 日
Thank you very much. I summarize your idea in this code:
%
ax = axes('XLim',[-1.5 1.5],'YLim',[-1.5 1.5],'ZLim',[-1.5 1.5]);
view(2)
f = @(x,y) x;
g = @(x,y) y;
h = @(x,y) x*0;
hfsurf = fsurf(f,g,h);
t = hgtransform('Parent',ax);
set(hfsurf,'Parent',t);
Rz = makehgtform('xrotate',pi/4);
set(t,'Matrix',Rz);

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 5 月 7 日
The output of fsurf() is a ParameterizedFunctionSurface object, which rotate() cannot process. rotate() can process surface(), line(), and patch() objects.
You will need to create an hgtransform group, parent the fsurf to it, and apply a rotation matrix to the hgtransform

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by