Re: 2D Rotation of Rectangle?



JPhilson wrote:
Hi,

I was wondering if there is a way to rotate a 2D rectangle that I
have plotted using the rectangle() command.

I have tried using rotate(), but it doesn't seem to like rectagle
objects. I didn't notice any xData/yData properties under the
rectangle object either, so I don't think I can simply hit the data
points with a rotation matrix.

Thanks for any suggestions.

Hello, Since you know what a rotation matrix is, I would offer this suggestion:


rect.vertices=[0 0;1 0; 1 1; 0 1]; %square rect.faces=[1 2 3 4]; %connect vertices %rotation matrix theta = pi/4; R=[cos(theta) sin(theta);-sin(theta) cos(theta)]; S = [5 0; 0 1]; %Scaling for rectangle patch(rect,'Vertices',rect.vertices*S*R,'FaceColor',[1 0 0]); axis equal



The patch command is extremely versatile for drawing many 2D and 3D shapes, and I would recommend looking at it more carefully. There may very well be much simpler ways to draw and rotate a rectangle (you can box and rotate text with the text command, for example), but patch is much more interesting. You can add the rectangle to any figure without using the hold command. The coordinates should be in the data space, and if there is no data space (no current figure), the figure props will be adjusted to fit your polygon.


Cheers, Eric Carlson .



Relevant Pages

  • 2D Rotation of Rectangle?
    ... I was wondering if there is a way to rotate a 2D rectangle that I ... have plotted using the rectanglecommand. ... rectangle object either, so I don't think I can simply hit the data ...
    (comp.soft-sys.matlab)
  • RE: FreeBSD 4.7 Syslogs
    ... # Purchasing database syslog ... The command ps ax displays all the tasks running on your system. ... manual documentation for the newsyslog command. ... rotate when the message file size is larger that 100k. ...
    (freebsd-questions)
  • Re: [SLE] nvidia handholding
    ... Return to init 5 and proceed and screen ... The Rotate function is more for LCD style displays the can be adjusted so ... Then as I do, command: ... Make the changes back to a working config (or try a variation or other ...
    (SuSE)
  • Re: Setting date as filename with logrotate
    ... > would like to rotate each log once a day, keep it for a week and then move ... > program will look for changes, if all log files changes filename everyday ... # * -h CMD: Execute the command CMD after moving the file. ...
    (comp.os.linux.misc)
  • Re: Help with ROI in Image Processing
    ... I have acheived this thru region props command. ... dont care.What i want is that the rectangle captured in a previos image ... sent to regionprops) and then run bwboundarieson it. ... If you want to measure the exact same areas as your first image, ...
    (comp.soft-sys.matlab)