Something like this (Jmol 12.1) var imin = 0; var dmin = 1000000; for(x in {*}){var d = x.distance({1 1 1});if (d < dmin) {dmin = d;i = x.atomindex} }
print "The closest atom is " + {atomindex = imin}.label() On Wed, Mar 30, 2011 at 12:58 AM, Paul Pillot < paul.pil...@ac-orleans-tours.fr> wrote: > The within selector allows you to make a selection of all atoms within a > given radius form a point : > select within (distance,{x y z}) > It won't give you just the closest... > > I think it is feasible with Jmol math, where you can create an array of > atoms, then calculate an array of distances from a point (using the distance > function) and sort that array to get the smallest distance. I am not > literate enough in Jmol math subtleties to provide you with further hints... > > -Paul > > Le 30 mars 2011 à 02:06, Yingjie Lin a écrit : > > > Hi Jmolers, > > > > I need to find the nearest atom(s) to a given point. What I can think of > is the following: > > > > [pseudocode] > > > > get atoms within a 1*1 boundbox > > if ( some atoms are found) { > > return these atoms; > > stop; > > } else { > > get atoms within a 2*2 boundbox; > > if ( some atoms are found) { > > return these atoms; > > stop; > > else { > > ...... > > } > > } > > [/pseudocode] > > The searching stops at 5*5, since I am not interested in something that > far away. > > Is there a better way to do this? > > > > Thank you. > > > > Yingjie > > > > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > Jmol-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users > -- Robert M. Hanson Professor of Chemistry St. Olaf College 1520 St. Olaf Ave. Northfield, MN 55057 http://www.stolaf.edu/people/hansonr phone: 507-786-3107 If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------ Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users