【发布时间】:2018-03-02 06:38:21
【问题描述】:
考虑具有顶点(0, 0), (1, 0), (7/10, 1), (1/2, 1/2), and (3/10, 1) 的多边形。使用填充函数在 Matlab 中绘制此多边形的图。 Rotate this polygon by an angle of 100 degrees using matrix-vector multiplication in Matlab with an appropriately chosen rotation matrix R. Make another plot of the rotated polygon using fill.
% Makes original polygon
X = [0 1 7/10 1/2 3/10];
Y = [0 0 1 1/2 1];
norm_poly = fill(X,Y,'k');
thetad = 100;
R = [cosd(thetad) -sind(thetad); sind(thetad) cosd(thetad)];
C = repmat([0 0], 5, 1)';
axis([-10 10 -10 10])
V = get(norm_poly,'Vertices')'; % get the current set of vertices
V = R*(V - C) + C; % do the rotation relative to the centre of the
square
set(norm_poly,'Vertices',V'); % update the vertices
我将如何制作不同的情节来展示它们?旋转的代码是否有意义并能满足所有要求?
【问题讨论】:
-
您是否只是在寻找一种显示两个不同图的方法?或者关于轮换的建议?在前一种情况下,标题具有误导性。
-
两者,很抱歉造成混淆。我想确保我的代码有意义。我还需要弄清楚如何显示两个不同的图
-
C = repmat([0 0], 5, 1)';不是多边形的中心。
标签: matlab