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

59 次查看(过去 30 天)
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 中查找有关 Oil, Gas & Petrochemical 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by