Rotating a plot about a center of origin
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everybody,
I'm trying to rotate an entire plot that I have about a specific origin.
Here is my code
x = 50;
y = 50;
figure
plot( [0:100; 0:100] , [0:100; 0:100] , 'k' )
hold on
fill([0 1 1 0]+(x+1) , [0 0 1 1]+(y+3), 'blue')
fill([0 1 1 0]+(x+2) , [0 0 1 1]+(y+3), 'blue')
fill([0 1 1 0]+(x+1) , [0 0 1 1]+(50-2), 'blue')
fill([0 1 1 0]+(x+2) , [0 0 1 1]+(50-2), 'blue')
fill([0 1 1 0]+ (x+3) , [0 0 1 1]+(y), 'blue')
fill([0 1 1 0]+ (x+3) , [0 0 1 1]+ (y+1), 'blue')
fill([0 1 1 0]+(x) , [0 0 1 1]+(y), 'red')
fill([0 1 1 0]+(x+1) , [0 0 1 1]+(y), 'red')
fill([0 1 1 0]+(x) , [0 0 1 1]+(y+1), 'red')
fill([0 1 1 0]+(x+1) , [0 0 1 1]+(y+1), 'red')
fill([0 1 1 0]+(x-3) , [0 0 1 1]+(y+3), 'red')
fill([0 1 1 0]+(x-2) , [0 0 1 1]+(y+3), 'red')
fill([0 1 1 0]+(x-1) , [0 0 1 1]+(y+3), 'red')
fill([0 1 1 0]+(x-3) , [0 0 1 1]+(y-2), 'red')
fill([0 1 1 0]+(x-2) , [0 0 1 1]+(y-2), 'red')
fill([0 1 1 0]+(x-1) , [0 0 1 1]+(y-2), 'red')
fill([0 1 1 0]+(x-3) , [0 0 1 1]+(y+3), 'red')
fill([0 1 1 0]+(x-2) , [0 0 1 1]+(y+3), 'red')
fill([0 1 1 0]+(x-1) , [0 0 1 1]+(y+3), 'red')
fill([0 1 1 0]+(x-1) , [0 0 1 1]+(y), 'black')
fill([0 1 1 0]+(x-2) , [0 0 1 1]+(y), 'black')
fill([0 1 1 0]+(x-3) , [0 0 1 1]+(y), 'black')
fill([0 1 1 0]+(x+2) , [0 0 1 1]+(y), 'black')
fill([0 1 1 0]+(x-1) , [0 0 1 1]+(y+1), 'black')
fill([0 1 1 0]+(x-2) , [0 0 1 1]+(y+1), 'black')
fill([0 1 1 0]+(x-3) , [0 0 1 1]+(y+1), 'black')
fill([0 1 1 0]+(x+2) , [0 0 1 1]+(y+1), 'black')
fill([0 1 1 0]+(x+2) , [0 0 1 1]+(y+1), 'black')
fill([0 1 1 0]+(x) , [0 0 1 1]+(y-1), 'black')
fill([0 1 1 0]+(x+1) , [0 0 1 1]+(y+2), 'black')
fill([0 1 1 0]+(x+2) , [0 0 1 1]+(y+2), 'black')
fill([0 1 1 0]+(x) , [0 0 1 1]+(y+2), 'black')
fill([0 1 1 0]+(x+1) , [0 0 1 1]+(y-1), 'black')
fill([0 1 1 0]+(x+2) , [0 0 1 1]+(y-1), 'black')
fill([0 1 1 0]+(x-1) , [0 0 1 1]+(y+2), 'black')
fill([0 1 1 0]+(x-2) , [0 0 1 1]+(y+2), 'black')
fill([0 1 1 0]+(x-3) , [0 0 1 1]+(y+2), 'black')
fill([0 1 1 0]+(x-1) , [0 0 1 1]+(y-1), 'black')
fill([0 1 1 0]+(x-2) , [0 0 1 1]+(y-1), 'black')
fill([0 1 1 0]+(x-3) , [0 0 1 1]+(y-1), 'black')
hold off
hax = gca;
hax.XTick = 0:100;
hax.YTick = 0:100;
hax.XTickLabel = [];
hax.YTickLabel = [];
grid
axis square
Here is the plot that it outputs. I took a screenshot and labeled exactly where my center of origin is with its coordinates
0 commentaires
Réponses (1)
Walter Roberson
le 1 Sep 2017
If the rotation is for visual purposes, you could consider parenting to a hgtransform group and applying transforms to the group. Note that this would end up rotating the lines as well.
0 commentaires
Voir également
Catégories
En savoir plus sur 3-D Scene Control dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!