Visibly accurate scales/axes in plot3...

1 Ansicht (letzte 30 Tage)
Chris E.
Chris E. am 19 Okt. 2015
Bearbeitet: Chris E. am 19 Okt. 2015
Hello Everyone,
The code below represents "stored boxes" in a closet (or its one way to think about it). The scales in the plotted function are accurate, but visually it is very inaccurate. I was looking for a way to change the axes to make the box appear like a box and less like a very long rectangle. Any help is welcome!!!
Accurate in terms of actual scale, but visually NOT accurate (long retangle):
Accurate in terms of visually, but NOT in terms of actual scale (looks like an actual box):
Thank you...
function BoxesInStorage()
height = 400;
width = 48+8+8;%48 box width + beam and space on each side
depth = 40*20; %20 box deep
X = [0;width;width;0;0];
Y = [0;0;depth;depth;0];
Z = [0;0;0;0;0];
hold on;
plot3(X,Y,Z); % draw a square in the xy plane with z = 0
plot3(X,Y,Z+height); % draw a square in the xy plane with z = 1
set(gca,'View',[-28,35]); % set the azimuth and elevation of the plot
for k=1:length(X)-1
plot3([X(k);X(k)],[Y(k);Y(k)],[0;1]);
end
plotcube([48 40 65],[0 0 5],.8,[1 0 0]);
plotcube([48 40 5],[0 0 0],.8,[0 1 0]);
function plotcube(varargin)
inArgs = { ...
[10 56 100] , ... % Default edge sizes (x,y and z)
[10 10 10] , ... % Default coordinates of the origin point of the cube
.7 , ... % Default alpha value for the cube's faces
[1 0 0] ... % Default Color for the cube
};
% Replace default input arguments by input values
inArgs(1:nargin) = varargin;
% Create all variables
[edges,origin,alpha,clr] = deal(inArgs{:});
XYZ = { ...
[0 0 0 0] [0 0 1 1] [0 1 1 0] ; ...
[1 1 1 1] [0 0 1 1] [0 1 1 0] ; ...
[0 1 1 0] [0 0 0 0] [0 0 1 1] ; ...
[0 1 1 0] [1 1 1 1] [0 0 1 1] ; ...
[0 1 1 0] [0 0 1 1] [0 0 0 0] ; ...
[0 1 1 0] [0 0 1 1] [1 1 1 1] ...
};
XYZ = mat2cell(...
cellfun( @(x,y,z) x*y+z , ...
XYZ , ...
repmat(mat2cell(edges,1,[1 1 1]),6,1) , ...
repmat(mat2cell(origin,1,[1 1 1]),6,1) , ...
'UniformOutput',false), ...
6,[1 1 1]);
cellfun(@patch,XYZ{1},XYZ{2},XYZ{3},...
repmat({clr},6,1),...
repmat({'FaceAlpha'},6,1),...
repmat({alpha},6,1)...
);
view(3);

Antworten (0)

Kategorien

Mehr zu Interpolation of 2-D Selections in 3-D Grids finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by