It's a bit verbose, but the simplest way is probably nested hgtransform objects . Here's a simple example: [x,y,z] = cylinder;
g1 = hgtransform;
s1 = surface(2*x,2*y,10*z,'FaceColor','red','Parent',g1);
g2 = hgtransform('Parent',g1,'Matrix',makehgtform('translate',[0 0 10]));
s2 = surface(2*x,2*y,10*z,'FaceColor','blue','Parent',g2);
view(3)
axis equal
Now we can change the Matrix properties of the two hgtransforms to make the cylinders move.
m1 = g1.Matrix;
m2 = g2.Matrix;
for ang=0:.01:pi/3
g1.Matrix = m1 * makehgtform('xrotate',ang);
g2.Matrix = m2 * makehgtform('xrotate',ang);
drawnow
end
The basic idea is that when we change the Matrix of g1, every object parented to it (i.e. s1, g2, & s2) will get rotated. And when we change the Matrix of g2, every object parented to it (i.e. s2) will get rotated. And the transformation that's applied to s2 will be the product of the Matrix properties of g1 and g2.
Does that make sense?