From: Robin Betz (robin_at_robinbetz.com)
Date: Thu Aug 08 2019 - 12:41:10 CDT

Hi Alex,

The command essentially measures the distance, without anything fancy about
the protein surface normals.
It's a little more complicated than that if you look at the source code in
vmd/src/SpatialSearch.C, at the find_within and find_within_routine
functions.
The molecule is divided up into a 3D grid of size depending on the cutoff,
and atoms are assigned to a grid cell. The within command actually returns
atoms in grid cells that are adjacent to that containing the selection.
This is based on a 5 minute skim of the code, so someone else can probably
give you a more thorough explanation.

Best,
Robin

On Thu, Aug 8, 2019 at 8:42 AM Alex Hummels <alexhummels_at_me.com> wrote:

> Hello,
>
> I’m currently working with diffusion of water within a certain distance of
> a protein and I was wanting to know more in depth how the “within” command
> works. Specifically, if I make a selection like
>
> set sel [atomselect top “name OH2 and (within 5 of protein)”]
>
> does the within command determine which Oxygen atoms are within 5 Å by
> measuring the distance from each protein atom? Or is it something more
> complex like measuring the shortest distance which is perpendicular to the
> protein surface?
>
> If anyone knows the answer or knows where to point me to source code where
> I could find out myself that would be wonderful.
>
> Thanks,
> Alex
>
>