Commit 78506396 authored by Jean-Yves TINEVEZ's avatar Jean-Yves TINEVEZ
Browse files

Plot an ellipse give in cartesian form on the XY plane.

parent c9908f3e
function h = plot_ellipse_2d( f, npoints)
%PLOT_ELLIPSE_2D Plot an ellipse in XY plane.
if nargin < 2
npoints = 20;
end
x0 = f(1);
y0 = f(2);
a = f(3);
b = f(4);
theta = f(5);
R = [ cos( theta ) sin( theta ) ;
-sin( theta ) cos( theta ) ] ;
t = linspace( 0 , 2 * pi, npoints )';
XY0 = [ a * sin(t), b * cos(t) ];
XY1 = XY0 * R;
xr = XY1( :, 1 ) + x0;
yr = XY1( :, 2 ) + y0;
xr = [ xr ; xr(1,:) ];
yr = [ yr ; yr(1,:) ];
h = line( xr, yr );
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment