How to make Ellipse rotates around focus

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by