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 CenterFile Exchange에서 Assembly에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by