フィルターのクリア

Rotation of a set of points

3 ビュー (過去 30 日間)
Rasmus
Rasmus 2014 年 2 月 25 日
回答済み: Mischa Kim 2014 年 2 月 25 日
I am given 4 points, each is a corner of a plane to a box.
p1=[0;0] p2=[sqrt(3/4);-1/2] p3=[sqrt(3/4);1/2] p4=[0;1]
I want to rotate the plane counterclockwise with 120- and240 degree. so that i get a box of some sort.
-------
what i try to do is to make a matrix of the first plane, give the rows x and y varribles and plot them in.
>> fill(x1,y1,'r')
which works fine.
now i want to rotate it with 120 degree. so i make a rotation matrix
theta= 120
R=[cos(theta) -sin(theta); sin(theta) cos(theta)]
I multiply it with the previously matrix, and put new varriables on the new matrix, like x2 and y2
fill(x1,y1,'r',x2,y2,'g')
for some reason it does not obbey my command :S
any tips and trick?

採用された回答

Mischa Kim
Mischa Kim 2014 年 2 月 25 日
Rasmus, this should work:
X = [p1 p2 p3 p4];
theta = 120*(pi/180);
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
Xr1 = R*X;
theta = 240*(pi/180);
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
Xr2 = R*X;
hold on
fill(X(1,:),X(2,:),'r')
fill(Xr1(1,:),Xr1(2,:),'b')
fill(Xr2(1,:),Xr2(2,:),'k')
grid; box;
axis square

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssembly についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by