getclstrlengths

PURPOSE ^

GETCLSTRLENGTHS gets the length of each cluster.

SYNOPSIS ^

function lengths=getclstrlengths(angleVector,rangeMatrix,clstrs)

DESCRIPTION ^

 GETCLSTRLENGTHS gets the length of each cluster.

 GETCLSTRLENGTHS gets the length of each cluster. The length is defined as
 the Euclidean distance between the end points.
 
     angleVector: 1xN vector; angleVector lists the angles for the ranges
     in rangeMatrix.
 
     rangeMatrix: MxN array; Each row in rangeMatrix contains a laser scan
     with ranges at the angles specified in angleVector.
 
     clstrs: MxN array. clstrs should be the same size as rangeMatrix.
     Each element in clstrs is an integer indicating the line cluster the
     range to which reading belongs.
 
 OUTPUTS:
     lengths: MxK array where K is the largest cluster number. It
     contains the lengths for each cluster.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function lengths=getclstrlengths(angleVector,rangeMatrix,clstrs)
0002 % GETCLSTRLENGTHS gets the length of each cluster.
0003 %
0004 % GETCLSTRLENGTHS gets the length of each cluster. The length is defined as
0005 % the Euclidean distance between the end points.
0006 %
0007 %     angleVector: 1xN vector; angleVector lists the angles for the ranges
0008 %     in rangeMatrix.
0009 %
0010 %     rangeMatrix: MxN array; Each row in rangeMatrix contains a laser scan
0011 %     with ranges at the angles specified in angleVector.
0012 %
0013 %     clstrs: MxN array. clstrs should be the same size as rangeMatrix.
0014 %     Each element in clstrs is an integer indicating the line cluster the
0015 %     range to which reading belongs.
0016 %
0017 % OUTPUTS:
0018 %     lengths: MxK array where K is the largest cluster number. It
0019 %     contains the lengths for each cluster.
0020 
0021 noscans=size(rangeMatrix,1);
0022 
0023 [x,y]=pol2cart(repmat(angleVector,[noscans,1]),rangeMatrix);
0024 
0025 noclstrs=max(clstrs,[],2);
0026 maxnoclstrs=max(noclstrs);
0027 
0028 lengths=zeros(noscans,maxnoclstrs);
0029 
0030 for cntr1=1:noscans
0031     for cntr2=1:noclstrs(cntr1)
0032         ind=find(clstrs(cntr1,:)==cntr2);
0033         pt1=min(ind);
0034         pt2=max(ind);
0035         len=norm([x(cntr1,pt2)-x(cntr1,pt1),y(cntr1,pt2)-y(cntr1,pt1)]);
0036         lengths(cntr1,cntr2)=len;
0037     end
0038 end

Generated on Thu 08-Apr-2010 14:35:09 by m2html © 2005