MATLAB: How to find vertices for a box

finding vertices

Dear All,
I have a box represent by centre, height, width and length as follow
centre =[xc,yc,zc]
box =[21.7873 39.9046 20.4403 34.9405 2.8089 39.5015];
xmin = box(:,1);
xmax = box(:,2);
ymin = box(:,3);
ymax = box(:,4);
zmin = box(:,5);
zmax = box(:,6);
h=xmax-xmin;
w=ymax-ymin;
l=zmax-zmin;
then I rotate the box now I want to find again the new vertices
[xmin xmax ymin ymax zmin zmax]
can anybody help me and show me how to find them.
regards

Best Answer

How is your rotation expressed? Is it two angles t1 and t2 that are rotations in two planes (say xy plane and xz plane)? In that case use the rotz() and roty() functions. Alternatively use the rotation matrices:
Rxy = [cos(t1) -sin(t1), 0; sin(t1), cos(t1), 0; 0, 0, 1];
and
Rxz = [cos(t2) -sin(t2), 0; 0, 0, 1; sin(t2), cos(t2), 0];
newmin = Rxy*Rxz*([xmin; ymin; zmin]);
newmax = Rxy*Rxz*([xmax; ymax; zmax]);