Graphics - The MathWorks - #501

/ 667


catalogue search
P. 501
P. 502
P. 503
P. 504
P. 505
P. 506
P. 507
P. 508
P. 509
P. 510
P. 511
P. 512
P. 513
P. 514
P. 515
P. 516
P. 517
P. 518
P. 519
P. 520
P. 521
P. 522
P. 523
P. 524
P. 525
P. 526
P. 527
P. 528
P. 529
P. 530
P. 531
P. 532
P. 533
P. 534
P. 535
P. 536
P. 537
P. 538
P. 539
P. 540
P. 541
P. 542
P. 543
P. 544
P. 545
P. 546
P. 547
P. 548
P. 549
P. 550


See other catalogues for The MathWorks

Text version of the page
Example — Transforming a Hierarchy of Objects
p(2) = patch('FaceColor,,,green',,Parent,,t(2));
txt(2) = text('String,,,Right,,,Parent',t(2));
p(3) = patch('FaceColor,,,blue,,,Parent',t(3));
txt(3) = text(,String',,Back,,,Color,,,white,,,Parent,,t(3));
p(4) = patch('FaceColor,,,yellow',,Parent,,t(4));
txt(4) = text('String,,,Top,,,Parent',t(4));
p(5) = patch('FaceColor,,,cyan',,Parent,,t(5));
txt(5) = text('String,,,Left,,,Parent',t(5));
p(6) = patch('FaceColor,,,magenta',,Parent,,t(6));
txt(6) = text('String,,,Front,,,Parent',t(6));
% Set the patch x, y, and z data
set(p,'XData',X,,YData,,Y,'ZData',Z)
% Set the position and alignment of the text
set(txt,'Position',[Xtext Ytext Ztext],...
'HorizontalAlignment','center',...
'VerticalAlignment','middle')
4 Translate the squares (patch objects) to the desired locations. Note that as hgtransform object 2 is translated, all its children (including hgtransform objects 3 through 6) are also translated. Therefore, each translation requires moving the square by only one unit in either the x or y direction. Hgtransform object 1 is left at its original position.
% Set up initial translation transform matrices
% Translate 1 unit in x
Tx = makehgtform('translate',[1 0 0]);
% Translate 1 unit in y
Ty = makehgtform('translate',[0 1 0]);
% Set the Matrix property of each hgtransform object (2-6)
set(t(2),'Matrix',Tx);
drawnow
set(t(3),'Matrix',Ty); drawnow
set(t(4),'Matrix',Tx); drawnow
set(t(5),'Matrix',Ty); drawnow
set(t(6),'Matrix',Tx);
8-39

pageCatalog pdf di En 2012-06-22-01