How to make Ellipse rotates around focus
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
How to make Ellipse rotates around focus
1 comentario
James Tursa
el 11 de Mzo. de 2020
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 ...?
Respuestas (1)
Peter O
el 11 de Mzo. de 2020
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?
0 comentarios
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!