Rotation of a set of points

5 visualizaciones (últimos 30 días)
Rasmus
Rasmus el 25 de Feb. de 2014
Respondida: Mischa Kim el 25 de Feb. de 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?

Respuesta aceptada

Mischa Kim
Mischa Kim el 25 de Feb. de 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

Más respuestas (0)

Categorías

Más información sobre 3-D Scene Control en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by