%-----------------------------------------------------------
% Carlos Cabral 2003 - Dep.UA

%conversao dos dados laser em dados cartesianos 
%----------------------------------------------------------

function [cart_data, data] = CONVERTDATA2CART(a,i)

    data = a(i , 1:1:360);  % to eliminate the time from de data
    data(length(data)+1)=data(length(data)); % to guaranty that the data have the same size because the model was made with 361 elements and original data has only 360
    data=10*data; % to convert cm to mm
    
    % incremento angular em radianos para representação polar das distancias
    t=0:pi/360:pi;
    %representação em espaço cartesiano
    x=data.*cos(t);
    y=data.*sin(t);
    cart_data=[x' y'];    
%     figure(1),subplot (2,1,1)
%     plot(cart_data(:,1),cart_data(:,2),cart_data(:,1),cart_data(:,2),'.',0,0,'ro'), grid on, axis ('equal'),axis([-8300 8300 -2000 9000])
 