Code covered by the BSD License  

Highlights from
Rapidly find the points lying inside a cut-off radius

Be the first to rate this file! 28 Downloads (last 30 days) File Size: 776 KB File ID: #35791
image thumbnail

Rapidly find the points lying inside a cut-off radius

by

 

This completely vectorized code helps you find all points within a cut-off radius from given point.

| Watch this File

File Information
Description

Say, in applications such as Molecular Dynamics, you may be required to find out which atoms lye within a cut-off radius (for example, the Van-der Waals distance of interaction, or say that interaction distance for the Tersoff Brenner Potential, etc..).

In any other applications, you may be required to identify a set of points lying within a circle.

This code helps you do that job, very fast. This code is completely vectorized and is fast.

Please try the code testrun.m to know how to use this code. Thank you.

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
23 Mar 2012 Jan Simon

You compare the distances twice:
in = find(dist<radius); ...
out = find(dist>radius);
Logical indexing would be more efficient:
in = (dist <= radius);
out = ~in;
This would include the points on the radius in addition.

Contact us