Rotation of a set of points
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rasmus
am 25 Feb. 2014
Beantwortet: Mischa Kim
am 25 Feb. 2014
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?
0 Kommentare
Akzeptierte Antwort
Mischa Kim
am 25 Feb. 2014
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 3-D Scene Control finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!