// $Id: AtomStats.java,v 1.1 2006/05/20 17:02:03 Sasha Buzko Exp $ // // Copyright (c) 2000-2002 San Diego Supercomputer Center (SDSC), // a facility operated jointly by the University of California, // San Diego (UCSD) and General Atomics, San Diego, California, USA. // // Users and possessors of this source code are hereby granted a // nonexclusive, royalty-free copyright and design patent license to // use this code in individual software. License is not granted for // commercial resale, in whole or in part, without prior written // permission from SDSC. This source is provided "AS IS" without express // or implied warranty of any kind. // // For further information, please see: http://mbt.sdsc.edu // // History: // $Log: AtomStats.java,v $ // Revision 1.1 2006/05/20 17:02:03 Sasha Buzko // Updated version // // Revision 1.1 2006/04/30 20:13:59 Sasha Buzko // New version of the app // // Revision 1.1 2006/04/15 19:42:27 Sasha Buzko // Initial commit // // Revision 1.1 2005/11/13 04:35:04 Administrator // *** empty log message *** // // Revision 1.1 2003/04/23 22:52:06 moreland // Created utility methods for computing coordinate bounds and averages. // // Revision 1.1.1.1 2002/07/16 18:00:21 moreland // Initial revision. // package edu.sdsc.mbt.util; import edu.sdsc.mbt.*; /** * The AtomStats class provides a number of static methods for computing * useful information about a collection of Atom objects. *

* @see edu.sdsc.mbt.Atom *

* @author John L. Moreland */ public class AtomStats { /** * Return the coordinate bounds for given a Structure. *

* double[0][0] = min x
* double[0][1] = min y
* double[0][2] = min z
* double[1][0] = max x
* double[1][1] = max y
* double[1][2] = max z
*

*/ public static double[][] getAtomCoordinateBounds( Structure structure ) { if ( structure == null ) throw new IllegalArgumentException( "null structure" ); int atomCount = structure.getStructureComponentCount( StructureComponentRegistry.TYPE_ATOM ); double coordinateBounds[][] = new double[2][3]; if ( atomCount <= 0 ) return coordinateBounds; Atom atom = (Atom) structure.getStructureComponentByIndex( StructureComponentRegistry.TYPE_ATOM, 0 ); coordinateBounds[0][0] = atom.coordinate[0]; // min x coordinateBounds[0][1] = atom.coordinate[1]; // min y coordinateBounds[0][2] = atom.coordinate[2]; // min z coordinateBounds[1][0] = atom.coordinate[0]; // max x coordinateBounds[1][1] = atom.coordinate[1]; // max y coordinateBounds[1][2] = atom.coordinate[2]; // max z for ( int i=1; i coordinateBounds[1][0] ) coordinateBounds[1][0] = atom.coordinate[0]; // max x if ( atom.coordinate[1] > coordinateBounds[1][1] ) coordinateBounds[1][1] = atom.coordinate[1]; // max y if ( atom.coordinate[2] > coordinateBounds[1][2] ) coordinateBounds[1][2] = atom.coordinate[2]; // max z } return coordinateBounds; } /** * Return the coordinate average for a Structure's atom coordinates. *

* double[0] = x
* double[1] = y
* double[2] = z
*

*/ public static double[] getAtomCoordinateAverage( Structure structure ) throws IllegalArgumentException { if ( structure == null ) throw new IllegalArgumentException( "null structure" ); int atomCount = structure.getStructureComponentCount( StructureComponentRegistry.TYPE_ATOM ); double coordinateAverage[] = new double[3]; if ( atomCount <= 0 ) return coordinateAverage; Atom atom = (Atom) structure.getStructureComponentByIndex( StructureComponentRegistry.TYPE_ATOM, 0 ); for ( int i=1; i