How to make Ellipse rotates around focus

4 ビュー (過去 30 日間)
Haoang Sun
Haoang Sun 2020 年 3 月 11 日
回答済み: Peter O 2020 年 3 月 11 日
How to make Ellipse rotates around focus
  1 件のコメント
James Tursa
James Tursa 2020 年 3 月 11 日
You rotate all of the points on the ellipse. I think we need more details from you. Do you have an equation, a set of points, or ...?

サインインしてコメントする。

回答 (1 件)

Peter O
Peter O 2020 年 3 月 11 日
Haoang,
Are you looking to have the ellipse rotate in a plot?
You might be interested in applying a rotation matrix. See:
If you have the (x,y) points of your ellipse, you can multiply them by the rotation matrix for each frame or angle of interest.
For instance, (this is pseudocode -- it won't run without having the xy points, and it's possible to be a little more clever to remove the inner loop with arrayfun and broadcasting.)
my_ellipse_xy % an Nx2 set of x,y points
angles = linspace(0,2*pi)
origin_x = 1.0
origin_y = 2.1
x = my_ellipse_xy(:,1) - origin_x
y = my_ellipse_xy(:,2) - origin_y
for ix=1:numel(angles)
q = angles(ix)
R = [cos(q), -sin(q);
sin(q), cos(q)]
ellipse_rot = zeros(numel(x),2)
for jx=1:numel(x)
% Apply the rotation at this angle.
% The transpose operation gets it into the Nx2 rows again.
% (2x2)*(2x1) is a column vector otherwise.
% If you use a 2xN approach, the transpose is not needed.
ellipse_rot(jx,1:2) = transpose(R*[x(jx);y(jx)])
end
%do something with the rotated vector here
end
Does this help?

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by