How to rotate RECTANGLE?
40 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
I am using the matlab function RECTANGLE to plot rectangle and ellipse in a figure.
Is it possible to rotate it by any angle (say 30 degrees)?
Kevin
0 个评论
采纳的回答
Walter Roberson
2022-4-2
Not exactly, but there is a way.
h = rectangle('Position',[0 0 2 4],'Curvature',1);
g = hgtransform('Matrix', makehgtform('zrotate', pi/6))
h.Parent = g;
xlim([-5 5]); ylim([-5 5])
Watch out for where the origin of the rotation is; if you want to rotate around the center of the object you should use a transform that subtracts the centroid, does the rotation, and adds back the centroid again. You will find that in practice the makehgtform() call for that will have the addition first, then the rotation, then the subtraction -- that is, the order of operations works out to be right to left.
2 个评论
Image Analyst
2022-4-3
@Kevin I see this requested so often. Please send in a request to support@mathworks.com saying there should be an "Angle" option of rectangle() so we can specify the angle in degrees of the long sides.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Scene Control 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!