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:
Rectangular box

Subject: Rectangular box

From: Chris Lach

Date: 16 Oct, 2010 17:38:04

Message: 1 of 3

I'm having trouble on an assignment I'm working on. I need to draw a rectangular box that spins about its center. Can anyone help me out?

Subject: Rectangular box

From: Miroslav Balda

Date: 17 Oct, 2010 15:31:03

Message: 2 of 3

"Chris Lach" <lachky2002@yahoo.com> wrote in message <i9cnts$jlr$1@fred.mathworks.com>...
> I'm having trouble on an assignment I'm working on. I need to draw a rectangular box that spins about its center. Can anyone help me out?

Hi
It is sinple:
ah=2.75; bh=1.75;
plot(0,0,'or'), hold on
plot([-ah,-ah,ah,ah,-ah],[-bh,bh,bh,-bh,-bh],'r'), grid
Hope it helps.
Mira

Subject: Rectangular box

From: Image Analyst

Date: 18 Oct, 2010 00:57:03

Message: 3 of 3

"Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <i9f4rn$jpv$1@fred.mathworks.com>...
> "Chris Lach" <lachky2002@yahoo.com> wrote in message <i9cnts$jlr$1@fred.mathworks.com>...
> > I'm having trouble on an assignment I'm working on. I need to draw a rectangular box that spins about its center. Can anyone help me out?
>
> Hi
> It is sinple:
> ah=2.75; bh=1.75;
> plot(0,0,'or'), hold on
> plot([-ah,-ah,ah,ah,-ah],[-bh,bh,bh,-bh,-bh],'r'), grid
> Hope it helps.
> Mira
-------------------------------------------------------------------------
It might help slightly. Your code doesn't specify the angle that the box is rotated by, or allow a center that is located away from the origin, but these are easy mathematical transformations that are what I suspect are the main point of the assignment and so are best left for Chris to figure out. Chris will have to put these into a for loop that repeatedly clears and re-draws the box at the new angle. And he might have to have a pause() and a drawnow in there to allow it to show the box at the new angle. Then you would observe the box spinning.

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