scaling issue for my surface
古いコメントを表示
Here is my code:
------------------
clc;clear all; close all;
myaxes=axes('xlim', [-200,200], 'ylim', [-200,200], 'zlim', [-200, 200]);
grid on; axis equal;view(130,21);
I=imread('road.jpg');
[X, Y] = meshgrid(-200:200, -200:200);Z=zeros(size(X));
ground=surf(X,Y,Z-10, I,'edgecolor', 'none','FaceColor','texturemap','parent',myaxes);
hold on; xlabel('x'); ylabel('y');zlabel('z');
[xcy,ycy,zcy]=cylinder([1,1],20);
h(1)=surface(zcy*5,ycy*5,xcy*5, 'facecolor','yellow','parent',myaxes);
-----------------------------------------------
Every time i run the above script; the z-axis keep re-scaling based on the max-z value of my surface "h(1)", even though i made "myaxes" its parent!!! any suggestions is much appricated.
回答 (1 件)
Walter Roberson
2015 年 12 月 31 日
myaxes = axes('xlim', [-200,200], 'ylim', [-200,200], 'zlim', [-200, 200]);
grid(myaxes, 'on'); axis(myaxes, 'equal'); view(myaxes, 130,21); %changed
I = imread('road.jpg');
[X, Y] = meshgrid(-200:200, -200:200); Z = zeros(size(X));
ground = surf(X,Y,Z-10, I,'edgecolor', 'none','FaceColor','texturemap','parent',myaxes);
hold(myaxes, 'on'); xlabel(myaxes, 'x'); ylabel(myaxes, 'y'); zlabel(myaxes, 'z'); %changed
[xcy,ycy,zcy] = cylinder([1,1],20);
h(1) = surface(zcy*5,ycy*5,xcy*5, 'facecolor','yellow','parent',myaxes);
And if that still does not work then in your creation of myaxes add the parameter 'zlimmode', 'manual'
6 件のコメント
AWNI ALSHAKHSHIR
2015 年 12 月 31 日
Walter Roberson
2015 年 12 月 31 日
See imfreehand(), and impoly() with 'closed', false
Here is a trick: if you get a set of vertices:
V = getposition(impoly('Closed', false));
then supposing you want to work in an M x N array,
V2 = [V; V(end-1:-1:1)];
mask = poly2mask(V2(:,1), V2(:,2), M, N);
Then mask will be true for each pixel that the lines go through.
Reversing V together with the reverse of V defines a 1 pixel thick line. If you had used just V then the first pixel would be connected to the last pixel automatically which is not going to be desirable.
AWNI ALSHAKHSHIR
2016 年 1 月 4 日
編集済み: Walter Roberson
2016 年 1 月 4 日
Walter Roberson
2016 年 1 月 4 日
I do not have the toolbox that defines impoint so I cannot test your code. I do notice
ground=hggroup;ground=surf(X,Y,Z-1, I,'edgecolor', 'none','FaceColor','texturemap');
ground=hggroup;set(ground,'parent',myaxes);
should be
ground_group = hggroup('Parent', myaxes);
ground = surf(X,Y,Z-1, I, 'edgecolor', 'none', 'FaceColor', 'texturemap', 'Parent', ground_group);
AWNI ALSHAKHSHIR
2016 年 1 月 7 日
AWNI ALSHAKHSHIR
2016 年 1 月 7 日
カテゴリ
ヘルプ センター および File Exchange で 2-D and 3-D Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!