%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DRAW_ELLIPSE(POS, COV, COLOR) Draws an ellipse in the current figure with color COLOR, 'r', 'g', 'b'...etc The ellipse is drawn at position POS and defined by its covariance matrix COV. See also DRAW_CIRCLE, DRAWROBOT3D. Author: Arturo Gil. Universidad Miguel Hernández de Elche. email: arturo.gil@umh.es date: 05/02/2012 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0002 % DRAW_ELLIPSE(POS, COV, COLOR) 0003 % Draws an ellipse in the current figure with color COLOR, 'r', 'g', 'b'...etc 0004 % The ellipse is drawn at position POS and defined by its covariance 0005 % matrix COV. 0006 % 0007 % See also DRAW_CIRCLE, DRAWROBOT3D. 0008 % 0009 % Author: Arturo Gil. Universidad Miguel Hernández de Elche. 0010 % email: arturo.gil@umh.es date: 05/02/2012 0011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0012 0013 % Copyright (C) 2012, by Arturo Gil Aparicio 0014 % 0015 % This file is part of ARTE (A Robotics Toolbox for Education). 0016 % 0017 % ARTE is free software: you can redistribute it and/or modify 0018 % it under the terms of the GNU Lesser General Public License as published by 0019 % the Free Software Foundation, either version 3 of the License, or 0020 % (at your option) any later version. 0021 % 0022 % ARTE is distributed in the hope that it will be useful, 0023 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0025 % GNU Lesser General Public License for more details. 0026 % 0027 % You should have received a copy of the GNU Leser General Public License 0028 % along with ARTE. If not, see <http://www.gnu.org/licenses/>. 0029 function h = draw_ellipse(pos, cov, color) 0030 0031 %for different DOF 0032 chi2=[6.6349 9.2103 11.3449 13.2767 15.0863 16.8119 18.4753]; 0033 0034 tita = linspace(0, 2*pi,40); 0035 CIRCLE = [cos(tita); sin(tita)]; 0036 0037 [V,D]=eig(full(cov(1:2,1:2))); 0038 ejes=sqrt(chi2(2)*diag(D)); 0039 P = (V*diag(ejes))*CIRCLE; 0040 hp = line(P(1,:)+pos(1), P(2,:)+pos(2)); 0041 set(hp,'Color', color); 0042