how to rotate cube not parallel to axis
2 views (last 30 days)
Show older comments
Dear,
I used from file exchange-MATLAB central a program to generate a cube then I tried to rotate but the new cube is parallel to axis so how I get cube not parallel like that
function drawBox3d(box, varargin)
%DRAWBOX3D Draw a 3D box defined by coordinate extents
%
% drawBox3d(BOX);
% Draw a box defined by its coordinate extents:
% BOX = [XMIN XMAX YMIN YMAX ZMIN ZMAX].
% The function draws only the outline edges of the box.
%
% Example
% % Draw bounding box of a cubeoctehedron
% [v e f] = createCubeOctahedron;
% box3d = boundingBox3d(v);
% figure; hold on;
% drawMesh(v, f);
% drawBox3d(box3d);
% set(gcf, 'renderer', 'opengl')
% axis([-2 2 -2 2 -2 2]);
% view(3)
%
% See Also:
% boxes3d, boundingBox3d
%
% ---------
% author : David Legland
% INRA - TPV URPOI - BIA IMASTE
% created the 10/12/2003.
%
% HISTORY
% 2010-02-22 creation
% default values
xmin = box(:,1);
xmax = box(:,2);
ymin = box(:,3);
ymax = box(:,4);
zmin = box(:,5);
zmax = box(:,6);
nBoxes = size(box, 1);
for i=1:length(nBoxes)
% lower face (z=zmin)
drawEdge3d([xmin(i) ymin(i) zmin(i) xmax(i) ymin(i) zmin(i)], varargin{:});
drawEdge3d([xmin(i) ymin(i) zmin(i) xmin(i) ymax(i) zmin(i)], varargin{:});
drawEdge3d([xmax(i) ymin(i) zmin(i) xmax(i) ymax(i) zmin(i)], varargin{:});
drawEdge3d([xmin(i) ymax(i) zmin(i) xmax(i) ymax(i) zmin(i)], varargin{:});
% front face (y=ymin)
drawEdge3d([xmin(i) ymin(i) zmin(i) xmin(i) ymin(i) zmax(i)], varargin{:});
drawEdge3d([xmax(i) ymin(i) zmin(i) xmax(i) ymin(i) zmax(i)], varargin{:});
drawEdge3d([xmin(i) ymin(i) zmax(i) xmax(i) ymin(i) zmax(i)], varargin{:});
% left face (x=xmin)
drawEdge3d([xmin(i) ymax(i) zmin(i) xmin(i) ymax(i) zmax(i)], varargin{:});
drawEdge3d([xmin(i) ymin(i) zmax(i) xmin(i) ymax(i) zmax(i)], varargin{:});
% the last 3 remaining edges
drawEdge3d([xmin(i) ymax(i) zmax(i) xmax(i) ymax(i) zmax(i)], varargin{:});
drawEdge3d([xmax(i) ymax(i) zmin(i) xmax(i) ymax(i) zmax(i)], varargin{:});
drawEdge3d([xmax(i) ymin(i) zmax(i) xmax(i) ymax(i) zmax(i)], varargin{:});
end
I tried to use
t1=45;
t2=30;
Rxy = [cos(t1) -sin(t1), 0; sin(t1), cos(t1), 0; 0, 0, 1];
Rxz = [cos(t2) -sin(t2), 0; 0, 0, 1; sin(t2), cos(t2), 0];
min=[xmin; ymin; zmin];
max=[xmax; ymax; zmax];
min = Rxy*Rxz*min
max = Rxy*Rxz*max
can I transfer it using a corner point that we use it in 2dim.
could anyone help me.
regards
0 Comments
Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!