rotate by a certain angle a plane in space around a node P

조회 수: 2 (최근 30일)
Alberto Acri
Alberto Acri 2023년 10월 7일
댓글: Alberto Acri 2023년 10월 7일
HI! I have a plane normal to a node (point P) in the figure.
line = importdata("line_G.mat");
plane = importdata("plane_G.mat");
P = [24.2914 -21.7784 81.7641];
figure
plot3(line(:,1),line(:,2),line(:,3),'k.','Markersize',10);
hold on
patch(plane(:,1), plane(:,2),plane(:,3),'r');
plot3(P(:,1),P(:,2),P(:,3),'k*','Markersize',10);
hold off
axis equal
How can I rotate the plane in the two directions X and Y by an angle alpha and beta? The plane, consequently, rotates around point P and is no longer normal.
For example, I wanted to use the code found here, but it seems I did something wrong.
v = plane;
% create a matrix which will be used later in calculations
center = P;
% define a 60 degree counter-clockwise rotation matrix
theta = pi/3; % pi/3 radians = 60 degrees
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
% do the rotation...
s = v - center; % shift points in the plane so that the center of rotation is at the origin
so = R*s; % apply the rotation about the origin
vo = so + center; % shift again so the origin goes back to the desired center of rotation
% this can be done in one line as:
% vo = R*(v - center) + center
% pick out the vectors of rotated x- and y-data
x_rotated = vo(1,:);
y_rotated = vo(2,:);
% make a plot
plot(x, y, 'k-', x_rotated, y_rotated, 'r-', x_center, y_center, 'bo');
axis equal

채택된 답변

Matt J
Matt J 2023년 10월 7일
편집: Matt J 2023년 10월 7일
I can't tell from your illustration what defines the axes of rotation, but you can use this FEX download,
Vrot = AxelRot(V.',alpha,axisDirection,P)
  댓글 수: 3
Dyuman Joshi
Dyuman Joshi 2023년 10월 7일
@Alberto Acri, look in the file via the Functions tab of the submission Matt has linked.
You will find the functionality of each input used noted in the comments of the code.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assembly에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by