MATLAB: Plotting with a rectangle

plotrectangle

Hey guys,
i am working on the simulation of a falling rectangle and have done the formulas. Now i need to test it so i need to plot it. As I need to see if the rotation is correct, I need to plot with a rectangle over my center of gravity. My project advisor told me to plot 4 points and connect them which I did. How can I put the centroid of the rectangle over the center of gravity of my simulation so that it moves with its coordinates and deegres?
my rectangle:
clear all
x1 = [-1 1]
y1 = [0.5 0.5]
plot(x1,y1,'b-');
hold on;
plot([1 1],[0.5, -0.5],'b-');
hold on;
plot([1 -1],[-0.5 -0.5],'b-');
hold on;
plot([-1 -1],[-0.5 0.5],'b-');
xlabel('x');
ylabel('y');
axis([-2 2 -2 2]);
I hope you get my question, if not feel free to ask and I try to explain it better.

Best Answer

I'd approach it by using the COG and rotation as computed by the simulation and then a transformation from that to the location of a given vertex point is a simple matrix operation. Knowing that coordinate and given a width and height of the rectangle, using rectangle to make the drawing would then be "piece 'o cake!".
As sounds like homework/schoolwork problem, will leave with hints rather than actual code...