Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Rotating through a known angle

Subject: Rotating through a known angle

From: Susan

Date: 17 Sep, 2010 13:41:20

Message: 1 of 4

Hi,

I'm having trouble with my code; I simply want to rotate my shape (2D rectangle) about it's centre point by degree values set by me. Here's my code:

daspect([1,1,1]);
deg = 100;

for i = 1:1:deg
p1 = rectangle('Position',[2,2,0.5,4.5],...
          'Curvature',[1,1],...
         'LineWidth',1,'LineStyle','-','FaceColor','r');
     rotate(p1,[1 1],i,[2.25 4.25]);
end

I'd appreciate any help!

Subject: Rotating through a known angle

From: Jan Simon

Date: 17 Sep, 2010 15:49:05

Message: 2 of 4

Dear Susan,

> I'm having trouble with my code; I simply want to rotate my shape (2D rectangle) about it's centre point by degree values set by me. Here's my code:
>
> daspect([1,1,1]);
> deg = 100;
>
> for i = 1:1:deg
> p1 = rectangle('Position',[2,2,0.5,4.5],...
> 'Curvature',[1,1],...
> 'LineWidth',1,'LineStyle','-','FaceColor','r');
> rotate(p1,[1 1],i,[2.25 4.25]);
> end

You forgot to mention the troubles.
Of course, I can guess, that the results differ from your expectations. But it's your turn to describe both.

Kind regards, Jan

Subject: Rotating through a known angle

From: Susan

Date: 17 Sep, 2010 16:11:20

Message: 3 of 4

Hi Jan,

Yes, apologies. At present when I run my code it gives me a plot of my shape as expected. However, I would like to have a plot that shows my shape rotated about it's centre point. In my code it is an ellipse, but what I would like is a sort of 'petals of a flower' shape. In order to do this I would like to rotate my ellipse through an angle of known angular step (which I can choose) - I can't seem to get a plot of my shape rotated.

Have you any idea of how I can achieve this? Any suggestions I would be very appreciative!

Kind regards,
Susan

Subject: Rotating through a known angle

From: Walter Roberson

Date: 17 Sep, 2010 18:39:00

Message: 4 of 4

On 10-09-17 08:41 AM, Susan wrote:

> I'm having trouble with my code; I simply want to rotate my shape (2D
> rectangle) about it's centre point by degree values set by me. Here's my
> code:
>
> daspect([1,1,1]);
> deg = 100;
>
> for i = 1:1:deg
> p1 = rectangle('Position',[2,2,0.5,4.5],...
> 'Curvature',[1,1],...
> 'LineWidth',1,'LineStyle','-','FaceColor','r');
> rotate(p1,[1 1],i,[2.25 4.25]);
> end

doc rotate

"rotate changes the Xdata, Ydata, and Zdata properties of the appropriate
graphics object."


However, a rectangle object does not have those properties and so is not
affected by rotate()


You will probably have to do something like use hgtransform() on a hggroup
that you create and use to parent the rectangle object.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us