Home > src > PF > particles_in_view_of_force.m

particles_in_view_of_force

PURPOSE ^

PARTICLES_IN_VIEW_OF_FORCE - returns the indices of the particles which

SYNOPSIS ^

function indices = particles_in_view_of_force( particles, target, own)

DESCRIPTION ^

 PARTICLES_IN_VIEW_OF_FORCE - returns the indices of the particles which
 could be detected by an own force 

 param: particles - a MxN matrix of M particles with N attributes
 param: target - the target structure to whom the particles belong
 param: own - the struct of the own force
 return: indices - the indices of the particles in view of own force

 NOTE! This is really just a hack to take care of particles that should
 have been observed by the own forces

 AUTHOR  Ronnie Johansson
 CREATED 2005-01-26 - based on particles_in_view
 ALTERED

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function indices = particles_in_view_of_force( particles, target, own)
0002 % PARTICLES_IN_VIEW_OF_FORCE - returns the indices of the particles which
0003 % could be detected by an own force
0004 %
0005 % param: particles - a MxN matrix of M particles with N attributes
0006 % param: target - the target structure to whom the particles belong
0007 % param: own - the struct of the own force
0008 % return: indices - the indices of the particles in view of own force
0009 %
0010 % NOTE! This is really just a hack to take care of particles that should
0011 % have been observed by the own forces
0012 %
0013 % AUTHOR  Ronnie Johansson
0014 % CREATED 2005-01-26 - based on particles_in_view
0015 % ALTERED
0016 %
0017 
0018 global verbose;
0019 
0020 [no_of_particles no_of_attributes] = size( particles );
0021 
0022 
0023 indices = [];
0024 
0025 for p=1:no_of_particles
0026   dist = euclidean_distance( own.pos, particles(p,1:2) );
0027   if (dist < own.sensing_range)
0028     %degree = min( 0, 1-dist/own.sensing_range );
0029     % the detection probability
0030     degree = 1;
0031     if rand < degree
0032       indices = [indices p];
0033 
0034       % print out
0035       if verbose
0036     disp(['particles_in_view_of_force: Own force: ' own.id ' discounted some particles.']);
0037       end
0038     end
0039   end
0040 end

Generated on Wed 16-Mar-2005 09:17:47 by m2html © 2003