Class GeometryUtil

java.lang.Object
org.openscience.cdk.geometry.GeometryUtil

public final class GeometryUtil extends Object
A set of static utility classes for geometric calculations and operations. This class is extensively used, for example, by JChemPaint to edit molecule. All methods in this class change the coordinates of the atoms. Use GeometryTools if you use an external set of coordinates (e. g. renderingCoordinates from RendererModel)
Author:
seb, Stefan Kuhn, Egon Willighagen, Ludovic Petain, Christian Hoppe, Niels Out, John May
Source code:
main
  • Method Details

    • translateAllPositive

      public static void translateAllPositive(IAtomContainer atomCon)
      Adds an automatically calculated offset to the coordinates of all atoms such that all coordinates are positive and the smallest x or y coordinate is exactly zero. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      atomCon - AtomContainer for which all the atoms are translated to positive coordinates
    • translate2D

      public static void translate2D(IAtomContainer atomCon, double transX, double transY)
      Translates the given molecule by the given Vector. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      atomCon - The molecule to be translated
      transX - translation in x direction
      transY - translation in y direction
    • scaleMolecule

      public static void scaleMolecule(IAtomContainer atomCon, double[] areaDim, double fillFactor)
      Scales a molecule such that it fills a given percentage of a given dimension. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      atomCon - The molecule to be scaled {width, height}
      areaDim - The dimension to be filled {width, height}
      fillFactor - The percentage of the dimension to be filled
    • scaleMolecule

      public static void scaleMolecule(IAtomContainer atomCon, double scaleFactor)
      Multiplies all the coordinates of the atoms of the given molecule with the scalefactor. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      atomCon - The molecule to be scaled
      scaleFactor - Description of the Parameter
    • center

      public static void center(IAtomContainer atomCon, double[] areaDim)
      Centers the molecule in the given area. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      atomCon - molecule to be centered
      areaDim - dimension in which the molecule is to be centered, array containing {width, height}
    • translate2D

      public static void translate2D(IAtomContainer atomCon, javax.vecmath.Vector2d vector)
      Translates a molecule from the origin to a new point denoted by a vector. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      atomCon - molecule to be translated
      vector - dimension that represents the translation vector
    • rotate

      public static void rotate(IAtomContainer atomCon, javax.vecmath.Point2d center, double angle)
      Rotates a molecule around a given center by a given angle.
      Parameters:
      atomCon - The molecule to be rotated
      center - A point giving the rotation center
      angle - The angle by which to rotate the molecule, in radians
    • reflect

      public static void reflect(Collection<IAtom> atoms, javax.vecmath.Point2d beg, javax.vecmath.Point2d end)
      Reflect a collection of atoms in the line formed by the two specified points (beg,end).
      Parameters:
      atoms - the atoms
      beg - the begin point of a line
      end - the end point of a line
    • reflect

      public static void reflect(Collection<IAtom> atoms, IBond bond)
      Reflect a collection of atoms in the line formed by the specified bond.
      Parameters:
      atoms - the atoms
      bond - the bond at which to reflect
    • rotate

      public static void rotate(IAtom atom, javax.vecmath.Point3d p1, javax.vecmath.Point3d p2, double angle)
      Rotates a 3D point about a specified line segment by a specified angle. The code is based on code available here. Positive angles are anticlockwise looking down the axis towards the origin. Assume right hand coordinate system.
      Parameters:
      atom - The atom to rotate
      p1 - The first point of the line segment
      p2 - The second point of the line segment
      angle - The angle to rotate by (in degrees)
    • normalize

      public static void normalize(javax.vecmath.Point3d point)
      Normalizes a point.
      Parameters:
      point - The point to normalize
    • get2DDimension

      public static double[] get2DDimension(IAtomContainer atomCon)
      Returns the dimension of a molecule (width/height).
      Parameters:
      atomCon - of which the dimension should be returned
      Returns:
      array containing {width, height}
    • getMinMax

      public static double[] getMinMax(Iterable<IAtom> atoms)
      Returns the minimum and maximum X and Y coordinates of the atoms. The output is returned as:
         minmax[0] = minX;
         minmax[1] = minY;
         minmax[2] = maxX;
         minmax[3] = maxY;
       
      Parameters:
      atoms - the atoms.
      Returns:
      An four int array as defined above.
    • getMinMax

      public static double[] getMinMax(IAtomContainer container)
      Returns the minimum and maximum X and Y coordinates of the atoms in the AtomContainer. The output is returned as:
         minmax[0] = minX;
         minmax[1] = minY;
         minmax[2] = maxX;
         minmax[3] = maxY;
       
      See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      container - Description of the Parameter
      Returns:
      An four int array as defined above.
    • translate2DCentreOfMassTo

      public static void translate2DCentreOfMassTo(IAtomContainer atomCon, javax.vecmath.Point2d p)
      Translates a molecule from the origin to a new point denoted by a vector. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      atomCon - molecule to be translated
      p - Description of the Parameter
    • get2DCenter

      public static javax.vecmath.Point2d get2DCenter(Iterable<IAtom> atoms)
      Calculates the center of the given atoms and returns it as a Point2d. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      atoms - The vector of the given atoms
      Returns:
      The center of the given atoms as Point2d
    • get2DCenter

      public static javax.vecmath.Point2d get2DCenter(Iterator<IAtom> atoms)
      Calculates the center of the given atoms and returns it as a Point2d. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      atoms - The Iterator of the given atoms
      Returns:
      The center of the given atoms as Point2d
    • get2DCenter

      public static javax.vecmath.Point2d get2DCenter(IRingSet ringSet)
      Returns the geometric center of all the rings in this ringset. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      ringSet - Description of the Parameter
      Returns:
      the geometric center of the rings in this ringset
    • get2DCentreOfMass

      public static javax.vecmath.Point2d get2DCentreOfMass(IAtomContainer ac)
      Calculates the center of mass for the Atoms in the AtomContainer for the 2D coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      ac - AtomContainer for which the center of mass is calculated
      Returns:
      Null, if any of the atomcontainer IAtom's masses are null
      Keywords:
      center of mass
    • get2DCenter

      public static javax.vecmath.Point2d get2DCenter(IAtomContainer container)
      Returns the geometric center of all the atoms in the atomContainer. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      container - Description of the Parameter
      Returns:
      the geometric center of the atoms in this atomContainer
    • translate2DCenterTo

      public static void translate2DCenterTo(IAtomContainer container, javax.vecmath.Point2d p)
      Translates the geometric 2DCenter of the given AtomContainer container to the specified Point2d p.
      Parameters:
      container - AtomContainer which should be translated.
      p - New Location of the geometric 2D Center.
      See Also:
    • get3DCentreOfMass

      public static javax.vecmath.Point3d get3DCentreOfMass(IAtomContainer ac)
      Calculates the center of mass for the Atoms in the AtomContainer.
      Parameters:
      ac - AtomContainer for which the center of mass is calculated
      Returns:
      The center of mass of the molecule, or NULL if the molecule does not have 3D coordinates or if any of the atoms do not have a valid atomic mass
      Dictionary pointer(s):
      calculate3DCenterOfMass in the Blue Obelisk Chemoinformatics Dictionary [blue-obelisk:calculate3DCenterOfMass]
      Keywords:
      center of mass
    • get3DCenter

      public static javax.vecmath.Point3d get3DCenter(IAtomContainer ac)
      Returns the geometric center of all the atoms in this atomContainer. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      ac - Description of the Parameter
      Returns:
      the geometric center of the atoms in this atomContainer
    • getAngle

      public static double getAngle(double xDiff, double yDiff)
      Gets the angle attribute of the GeometryTools class.
      Parameters:
      xDiff - Description of the Parameter
      yDiff - Description of the Parameter
      Returns:
      The angle value
    • distanceCalculator

      public static int[] distanceCalculator(int[] coords, double dist)
      Gets the coordinates of two points (that represent a bond) and calculates for each the coordinates of two new points that have the given distance vertical to the bond.
      Parameters:
      coords - The coordinates of the two given points of the bond like this [point1x, point1y, point2x, point2y]
      dist - The vertical distance between the given points and those to be calculated
      Returns:
      The coordinates of the calculated four points
    • distanceCalculator

      public static double[] distanceCalculator(double[] coords, double dist)
    • getBondCoordinates

      public static int[] getBondCoordinates(IBond bond)
      Writes the coordinates of the atoms participating the given bond into an array. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      bond - The given bond
      Returns:
      The array with the coordinates
    • getClosestAtom

      public static IAtom getClosestAtom(int xPosition, int yPosition, IAtomContainer atomCon)
      Returns the atom of the given molecule that is closest to the given coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      xPosition - The x coordinate
      yPosition - The y coordinate
      atomCon - The molecule that is searched for the closest atom
      Returns:
      The atom that is closest to the given coordinates
    • getClosestAtom

      public static IAtom getClosestAtom(IAtomContainer atomCon, IAtom atom)
      Returns the atom of the given molecule that is closest to the given atom (excluding itself).
      Parameters:
      atomCon - The molecule that is searched for the closest atom
      atom - The atom to search around
      Returns:
      The atom that is closest to the given coordinates
    • getClosestAtom

      public static IAtom getClosestAtom(double xPosition, double yPosition, IAtomContainer atomCon, IAtom toignore)
      Returns the atom of the given molecule that is closest to the given coordinates and is not the atom. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      xPosition - The x coordinate
      yPosition - The y coordinate
      atomCon - The molecule that is searched for the closest atom
      toignore - This molecule will not be returned.
      Returns:
      The atom that is closest to the given coordinates
    • getClosestAtom

      public static IAtom getClosestAtom(double xPosition, double yPosition, IAtomContainer atomCon)
      Returns the atom of the given molecule that is closest to the given coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      xPosition - The x coordinate
      yPosition - The y coordinate
      atomCon - The molecule that is searched for the closest atom
      Returns:
      The atom that is closest to the given coordinates
    • getClosestBond

      public static IBond getClosestBond(int xPosition, int yPosition, IAtomContainer atomCon)
      Returns the bond of the given molecule that is closest to the given coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      xPosition - The x coordinate
      yPosition - The y coordinate
      atomCon - The molecule that is searched for the closest bond
      Returns:
      The bond that is closest to the given coordinates
    • getClosestBond

      public static IBond getClosestBond(double xPosition, double yPosition, IAtomContainer atomCon)
      Returns the bond of the given molecule that is closest to the given coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      xPosition - The x coordinate
      yPosition - The y coordinate
      atomCon - The molecule that is searched for the closest bond
      Returns:
      The bond that is closest to the given coordinates
    • sortBy2DDistance

      public static void sortBy2DDistance(IAtom[] atoms, javax.vecmath.Point2d point)
      Sorts a Vector of atoms such that the 2D distances of the atom locations from a given point are smallest for the first atoms in the vector. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      point - The point from which the distances to the atoms are measured
      atoms - The atoms for which the distances to point are measured
    • getScaleFactor

      public static double getScaleFactor(IAtomContainer container, double bondLength)
      Determines the scale factor for displaying a structure loaded from disk in a frame. An average of all bond length values is produced and a scale factor is determined which would scale the given molecule such that its See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      container - The AtomContainer for which the ScaleFactor is to be calculated
      bondLength - The target bond length
      Returns:
      The ScaleFactor with which the AtomContainer must be scaled to have the target bond length
    • getBondLengthAverage

      public static double getBondLengthAverage(IAtomContainer container)
      An average of all 2D bond length values is produced. Bonds which have Atom's with no coordinates are disregarded. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      container - The AtomContainer for which the average bond length is to be calculated
      Returns:
      the average bond length
    • getLength2D

      public static double getLength2D(IBond bond)
      Returns the geometric length of this bond in 2D space. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      bond - Description of the Parameter
      Returns:
      The geometric length of this bond
    • has2DCoordinates

      public static boolean has2DCoordinates(IAtomContainer container)
      Determines if all this IAtomContainer's atoms contain 2D coordinates. If any atom is null or has unset 2D coordinates this method will return false.
      Parameters:
      container - the atom container to examine
      Returns:
      indication that all 2D coordinates are available
      See Also:
    • has2DCoordinates

      public static boolean has2DCoordinates(IReaction reaction)
      Determine if all parts of a reaction have coodinates
      Parameters:
      reaction - a reaction
      Returns:
      the reaction has coordinates
    • get2DCoordinateCoverage

      public static GeometryUtil.CoordinateCoverage get2DCoordinateCoverage(IAtomContainer container)
      Determines the coverage of this IAtomContainer's 2D coordinates. If all atoms are non-null and have 2D coordinates this method will return GeometryUtil.CoordinateCoverage.FULL. If one or more atoms does have 2D coordinates and any others atoms are null or are missing 2D coordinates this method will return GeometryUtil.CoordinateCoverage.PARTIAL. If all atoms are null or are all missing 2D coordinates this method will return GeometryUtil.CoordinateCoverage.NONE. If the provided container is null GeometryUtil.CoordinateCoverage.NONE is also returned.
      Parameters:
      container - the container to inspect
      Returns:
      GeometryUtil.CoordinateCoverage.FULL, GeometryUtil.CoordinateCoverage.PARTIAL or GeometryUtil.CoordinateCoverage.NONE depending on the number of 3D coordinates present
      See Also:
    • has2DCoordinatesNew

      @Deprecated public static int has2DCoordinatesNew(IAtomContainer container)
      Deprecated.
      Determines if this AtomContainer contains 2D coordinates for some or all molecules. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      container - the molecule to be considered
      Returns:
      0 no 2d, 1=some, 2= for each atom
      See Also:
    • has2DCoordinates

      public static boolean has2DCoordinates(IAtom atom)
      Determines if this Atom contains 2D coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      atom - Description of the Parameter
      Returns:
      boolean indication that 2D coordinates are available
    • has2DCoordinates

      public static boolean has2DCoordinates(IBond bond)
      Determines if this Bond contains 2D coordinates. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      bond - Description of the Parameter
      Returns:
      boolean indication that 2D coordinates are available
    • has3DCoordinates

      public static boolean has3DCoordinates(IAtomContainer container)
      Determines if all this IAtomContainer's atoms contain 3D coordinates. If any atom is null or has unset 3D coordinates this method will return false. If the provided container is null false is returned.
      Parameters:
      container - the atom container to examine
      Returns:
      indication that all 3D coordinates are available
      See Also:
    • get3DCoordinateCoverage

      public static GeometryUtil.CoordinateCoverage get3DCoordinateCoverage(IAtomContainer container)
      Determines the coverage of this IAtomContainer's 3D coordinates. If all atoms are non-null and have 3D coordinates this method will return GeometryUtil.CoordinateCoverage.FULL. If one or more atoms does have 3D coordinates and any others atoms are null or are missing 3D coordinates this method will return GeometryUtil.CoordinateCoverage.PARTIAL. If all atoms are null or are all missing 3D coordinates this method will return GeometryUtil.CoordinateCoverage.NONE. If the provided container is null GeometryUtil.CoordinateCoverage.NONE is also returned.
      Parameters:
      container - the container to inspect
      Returns:
      GeometryUtil.CoordinateCoverage.FULL, GeometryUtil.CoordinateCoverage.PARTIAL or GeometryUtil.CoordinateCoverage.NONE depending on the number of 3D coordinates present
      See Also:
    • calculatePerpendicularUnitVector

      public static javax.vecmath.Vector2d calculatePerpendicularUnitVector(javax.vecmath.Point2d point1, javax.vecmath.Point2d point2)
      Determines the normalized vector orthogonal on the vector p1->p2.
      Parameters:
      point1 - Description of the Parameter
      point2 - Description of the Parameter
      Returns:
      Description of the Return Value
    • getNormalizationFactor

      public static double getNormalizationFactor(IAtomContainer container)
      Calculates the normalization factor in order to get an average bond length of 1.5. It takes only into account Bond's with two atoms. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      container - Description of the Parameter
      Returns:
      The normalizationFactor value
    • getBestAlignmentForLabel

      public static int getBestAlignmentForLabel(IAtomContainer container, IAtom atom)
      Determines the best alignment for the label of an atom in 2D space. It returns 1 if left aligned, and -1 if right aligned. See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      container - Description of the Parameter
      atom - Description of the Parameter
      Returns:
      The bestAlignmentForLabel value
    • getBestAlignmentForLabelXY

      public static int getBestAlignmentForLabelXY(IAtomContainer container, IAtom atom)
      Determines the best alignment for the label of an atom in 2D space. It returns 1 if right (=default) aligned, and -1 if left aligned. returns 2 if top aligned, and -2 if H is aligned below the atom See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
      Parameters:
      container - Description of the Parameter
      atom - Description of the Parameter
      Returns:
      The bestAlignmentForLabel value
    • findClosestInSpace

      public static List<IAtom> findClosestInSpace(IAtomContainer container, IAtom startAtom, int max) throws CDKException
      Returns the atoms which are closes to an atom in an AtomContainer by distance in 3d.
      Parameters:
      container - The AtomContainer to examine
      startAtom - the atom to start from
      max - the number of neighbours to return
      Returns:
      the average bond length
      Throws:
      CDKException - Description of the Exception
    • mapAtomsOfAlignedStructures

      public static Map<Integer,Integer> mapAtomsOfAlignedStructures(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, double searchRadius, Map<Integer,Integer> mappedAtoms) throws CDKException
      Returns a Map with the AtomNumbers, the first number corresponds to the first (or the largest AtomContainer) atomcontainer. It is recommend to sort the atomContainer due to their number of atoms before calling this function. The molecules needs to be aligned before! (coordinates are needed)
      Parameters:
      firstAtomContainer - the (largest) first aligned AtomContainer which is the reference
      secondAtomContainer - the second aligned AtomContainer
      searchRadius - the radius of space search from each atom
      Returns:
      a Map of the mapped atoms
      Throws:
      CDKException - Description of the Exception
    • getBondLengthRMSD

      public static double getBondLengthRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map<Integer,Integer> mappedAtoms, boolean Coords3d)
      Return the RMSD of bonds length between the 2 aligned molecules.
      Parameters:
      firstAtomContainer - the (largest) first aligned AtomContainer which is the reference
      secondAtomContainer - the second aligned AtomContainer
      mappedAtoms - Map: a Map of the mapped atoms
      Coords3d - boolean: true if moecules has 3D coords, false if molecules has 2D coords
      Returns:
      double: all the RMSD of bonds length
    • getAngleRMSD

      public static double getAngleRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map<Integer,Integer> mappedAtoms)
      Return the variation of each angle value between the 2 aligned molecules.
      Parameters:
      firstAtomContainer - the (largest) first aligned AtomContainer which is the reference
      secondAtomContainer - the second aligned AtomContainer
      mappedAtoms - Map: a Map of the mapped atoms
      Returns:
      double: the value of the RMSD
    • getAllAtomRMSD

      public static double getAllAtomRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map<Integer,Integer> mappedAtoms, boolean Coords3d) throws CDKException
      Return the RMSD between the 2 aligned molecules.
      Parameters:
      firstAtomContainer - the (largest) first aligned AtomContainer which is the reference
      secondAtomContainer - the second aligned AtomContainer
      mappedAtoms - Map: a Map of the mapped atoms
      Coords3d - boolean: true if molecules has 3D coords, false if molecules has 2D coords
      Returns:
      double: the value of the RMSD
      Throws:
      CDKException - if there is an error in getting mapped atoms
    • getHeavyAtomRMSD

      public static double getHeavyAtomRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map<Integer,Integer> mappedAtoms, boolean hetAtomOnly, boolean Coords3d)
      Return the RMSD of the heavy atoms between the 2 aligned molecules.
      Parameters:
      firstAtomContainer - the (largest) first aligned AtomContainer which is the reference
      secondAtomContainer - the second aligned AtomContainer
      mappedAtoms - Map: a Map of the mapped atoms
      hetAtomOnly - boolean: true if only hetero atoms should be considered
      Coords3d - boolean: true if molecules has 3D coords, false if molecules has 2D coords
      Returns:
      double: the value of the RMSD
    • getBondLengthAverage3D

      public static double getBondLengthAverage3D(IAtomContainer container)
      An average of all 3D bond length values is produced, using point3ds in atoms. Atom's with no coordinates are disregarded.
      Parameters:
      container - The AtomContainer for which the average bond length is to be calculated
      Returns:
      the average bond length
    • shiftContainer

      public static double[] shiftContainer(IAtomContainer container, double[] bounds, double[] last, double gap)
      Shift the container horizontally to the right to make its bounds not overlap with the other bounds. To avoid dependence on Java AWT, rectangles are described by arrays of double. Each rectangle is specified by {minX, minY, maxX, maxY}.
      Parameters:
      container - the IAtomContainer to shift to the right
      bounds - the bounds of the IAtomContainer to shift
      last - the bounds that is used as reference
      gap - the gap between the two rectangles
      Returns:
      the rectangle of the IAtomContainer after the shift
    • getBondLengthAverage

      public static double getBondLengthAverage(IReaction reaction)
    • getBondLengthMedian

      public static double getBondLengthMedian(IAtomContainer container)
      Calculate the median bond length of an atom container.
      Parameters:
      container - structure representation
      Returns:
      median bond length
      Throws:
      IllegalArgumentException - unset coordinates or no bonds
    • getBondLengthMedian

      public static double getBondLengthMedian(Iterable<IBond> bonds, int cap)
      Calculate the median bond length of some bonds.
      Parameters:
      bonds - the bonds
      Returns:
      median bond length
      Throws:
      IllegalArgumentException - unset coordinates or no bonds
    • has3DCoordinates

      public static boolean has3DCoordinates(IChemModel chemModel)
      Determines if this model contains 3D coordinates for all atoms.
      Parameters:
      chemModel - the ChemModel to consider
      Returns:
      Boolean indication that 3D coordinates are available for all atoms.
    • shiftReactionVertical

      public static double[] shiftReactionVertical(IReaction reaction, double[] bounds, double[] last, double gap)
      Shift the containers in a reaction vertically upwards to not overlap with the reference rectangle. The shift is such that the given gap is realized, but only if the reactions are actually overlapping. To avoid dependence on Java AWT, rectangles are described by arrays of double. Each rectangle is specified by {minX, minY, maxX, maxY}.
      Parameters:
      reaction - the reaction to shift
      bounds - the bounds of the reaction to shift
      last - the bounds of the last reaction
      Returns:
      the rectangle of the shifted reaction
    • polarBondComparator

      public static Comparator<IBond> polarBondComparator(IAtom central)
      Sort the bonds using polar/radial coords around a central atom in 2D.
      Parameters:
      central - the central atom
    • polarAtomComparator

      public static Comparator<IAtom> polarAtomComparator(javax.vecmath.Point2d central)
      Sort the atoms using polar/radial coords around a central point in 2D.
      Parameters:
      central - the central atom
    • polarAtomComparator

      public static Comparator<IAtom> polarAtomComparator(IAtom central)
      Sort the atoms using polar/radial coords around a central atom in 2D.
      Parameters:
      central - the central atom