File Exchange

image thumbnail

Rapidly find the points lying inside a cut-off radius

version 1.0 (776 KB) by

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



View License

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.

Comments and Ratings (2)


Ingrid (view profile)

doesn't the build in function rangesearch do exactly the same?

Jan Simon

Jan Simon (view profile)

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.

MATLAB Release
MATLAB 7.10 (R2010a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video