Rotate a 2D plot around a specific point on the plot?

조회 수: 30 (최근 30일)
N/A
N/A 2018년 11월 27일
편집: Luna 2018년 11월 28일
Hello, I am trying to rotate an object (a plot of a propeller blade cross-section) around a specific point on the plot.
I was given a large list of coordinates to plot. After plotting these many points, the following is plotted:
BladeGraph1.PNG
Now, I need to rotate this blade by a certain number of degrees around a certain point on the plot, for example (0,0), counter-clockwise.
I need to not do this just once, but 205 times (I will use a loop, obviously), and replot each figure on top of eachother, separated by a certain distance in the Z-Plane, so that the plot looks like a wind turbine blade. How can I achieve this?

답변 (2개)

Jim Riggs
Jim Riggs 2018년 11월 27일
편집: Jim Riggs 2018년 11월 27일
% Given data vectors X and Y.
% Want to rotate the data through angle "ang" about rotation center Xc, Yc
X = [..];
Y = [..];
ang = ..;
% Specify the coordinates of the center of rotation
Xc = 0.25 ; % Rotate about the 1/4 chord point
Yc = 0 ;
% The data is roated in a three-step process
% Step 1) Shift the data to the rotation center
Xs = X - Xc; % shifted data
Ys = Y - Yc;
% Step 2) Rotate the data
Xsr = Xs*cos(ang) + Ys*sin(ang); % shifted and rotated data
Ysr = -Xs*sin(ang) + Ys*cos(ang); %
% Step 3) Un-shift the data (back to the original coordinate system)
Xr = Xsr + Xc; % Rotated data
Yr = Ysr + Yc;
The above three steps can be combined into a single step:
Xr = (X-Xc)*cos(ang) + (Y-Yc)*sin(ang) + Xc;
Yr = -(X-Xc)*sin(ang) + (Y-Yc)*cos(ang) + Yc;

Luna
Luna 2018년 11월 27일
편집: Luna 2018년 11월 28일
I think you can easily use rotate function which already manipulates the data. It is different from view.
Here for you I have created a simple line and a figure, with a 10 times for loop.
Each time rotated, plots the manipulated data again with holding on, according to origin.
x = 1:10;
y = randi(10,1,10)
figure;
h = plot(x,y);
for i = 1:10
rotate(h,[0 0],20); % rotate h line, by [0 0] point, with 20 degrees
hold on;
plot(h.XData,h.YData, 'color','b')
end
  댓글 수: 2
Luna
Luna 2018년 11월 28일
Yes, it gives something like this, so Ryan can plot his eliptic line (which I don't know its formula) with the same method so hopefully it looks like a turbine blade.

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

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by