public class GeometryTools extends Object
Constructor and Description |
---|
GeometryTools() |
Modifier and Type | Method and Description |
---|---|
static javax.vecmath.Vector2d |
calculatePerpendicularUnitVector(javax.vecmath.Point2d point1,
javax.vecmath.Point2d point2)
Determines the normalized vector orthogonal on the vector p1->p2.
|
static void |
center(IAtomContainer atomCon,
Dimension areaDim)
Centers the molecule in the given area
See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
|
static double[] |
distanceCalculator(double[] coords,
double dist) |
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.
|
static List<IAtom> |
findClosestInSpace(IAtomContainer container,
IAtom startAtom,
int max)
Returns the atoms which are closes to an atom in an AtomContainer by
distance in 3d.
|
static javax.vecmath.Point2d |
get2DCenter(IAtomContainer container)
Returns the geometric center of all the atoms in the atomContainer.
|
static javax.vecmath.Point2d |
get2DCenter(IRingSet ringSet)
Returns the geometric center of all the rings in this ringset.
|
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
|
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
|
static javax.vecmath.Point2d |
get2DCentreOfMass(IAtomContainer ac)
Calculates the center of mass for the
Atom s in the
AtomContainer for the 2D coordinates. |
static Dimension |
get2DDimension(IAtomContainer atomCon)
Returns the java.awt.Dimension of a molecule
See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
|
static javax.vecmath.Point3d |
get3DCenter(IAtomContainer ac)
Returns the geometric center of all the atoms in this atomContainer.
|
static javax.vecmath.Point3d |
get3DCentreOfMass(IAtomContainer ac)
Calculates the center of mass for the
Atom s in the
AtomContainer for the 2D coordinates. |
static double |
getAllAtomRMSD(IAtomContainer firstAtomContainer,
IAtomContainer secondAtomContainer,
Map<Integer,Integer> mappedAtoms,
boolean Coords3d)
Return the RMSD between the 2 aligned molecules.
|
static double |
getAngle(double xDiff,
double yDiff)
Gets the angle attribute of the GeometryTools class
|
static double |
getAngleRMSD(IAtomContainer firstAtomContainer,
IAtomContainer secondAtomContainer,
Map<Integer,Integer> mappedAtoms)
Return the variation of each angle value between the 2 aligned molecules.
|
static int |
getBestAlignmentForLabel(IAtomContainer container,
IAtom atom)
Determines the best alignment for the label of an atom in 2D space.
|
static int |
getBestAlignmentForLabelXY(IAtomContainer container,
IAtom atom)
Determines the best alignment for the label of an atom in 2D space.
|
static int[] |
getBondCoordinates(IBond bond)
Writes the coordinates of the atoms participating the given bond into an
array.
|
static double |
getBondLengthAverage(IAtomContainer container)
An average of all 2D bond length values is produced.
|
static double |
getBondLengthAverage(IReaction reaction) |
static double |
getBondLengthAverage3D(IAtomContainer container)
An average of all 3D bond length values is produced, using point3ds in atoms.
|
static double |
getBondLengthRMSD(IAtomContainer firstAtomContainer,
IAtomContainer secondAtomContainer,
Map<Integer,Integer> mappedAtoms,
boolean Coords3d)
Return the RMSD of bonds length between the 2 aligned molecules.
|
static IAtom |
getClosestAtom(double xPosition,
double yPosition,
IAtomContainer atomCon)
Returns the atom of the given molecule that is closest to the given
coordinates.
|
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.
|
static IAtom |
getClosestAtom(IAtomContainer atomCon,
IAtom atom)
Returns the atom of the given molecule that is closest to the given atom
(excluding itself).
|
static IAtom |
getClosestAtom(int xPosition,
int yPosition,
IAtomContainer atomCon)
Returns the atom of the given molecule that is closest to the given
coordinates.
|
static IBond |
getClosestBond(double xPosition,
double yPosition,
IAtomContainer atomCon)
Returns the bond of the given molecule that is closest to the given
coordinates.
|
static IBond |
getClosestBond(int xPosition,
int yPosition,
IAtomContainer atomCon)
Returns the bond of the given molecule that is closest to the given
coordinates.
|
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.
|
static double |
getLength2D(IBond bond)
Returns the geometric length of this bond in 2D space.
|
static double[] |
getMinMax(IAtomContainer container)
Returns the minimum and maximum X and Y coordinates of the atoms in the
AtomContainer.
|
static double |
getNormalizationFactor(IAtomContainer container)
Calculates the normalization factor in order to get an average bond length
of 1.5.
|
static Rectangle2D |
getRectangle2D(IAtomContainer container)
Returns the 2D rectangle spanning the space occupied by the atom
container.
|
static double |
getScaleFactor(IAtomContainer container,
double bondLength)
Determines the scale factor for displaying a structure loaded from disk in
a frame.
|
static boolean |
has2DCoordinates(IAtom atom)
Determines if this Atom contains 2D coordinates.
|
static boolean |
has2DCoordinates(IAtomContainer container)
Determines if this AtomContainer contains 2D coordinates.
|
static boolean |
has2DCoordinates(IBond bond)
Determines if this Bond contains 2D coordinates.
|
static int |
has2DCoordinatesNew(IAtomContainer container)
Determines if this AtomContainer contains 2D coordinates for some or all molecules.
|
static boolean |
has3DCoordinates(IAtomContainer container)
Determines if this model contains 3D coordinates
|
static boolean |
has3DCoordinates(IChemModel chemModel)
Determines if this model contains 3D coordinates for all atoms.
|
static Map<Integer,Integer> |
mapAtomsOfAlignedStructures(IAtomContainer firstAtomContainer,
IAtomContainer secondAtomContainer,
double searchRadius,
Map<Integer,Integer> mappedAtoms)
Returns a Map with the AtomNumbers, the first number corresponds to the first (or the largest
AtomContainer) atomcontainer.
|
static void |
normalize(javax.vecmath.Point3d point)
Normalizes a point.
|
static void |
rotate(IAtomContainer atomCon,
javax.vecmath.Point2d center,
double angle)
Rotates a molecule around a given center by a given angle
|
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.
|
static void |
scaleMolecule(IAtomContainer atomCon,
Dimension 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
|
static void |
scaleMolecule(IAtomContainer atomCon,
double scaleFactor)
Multiplies all the coordinates of the atoms of the given molecule with the
scalefactor.
|
static Rectangle2D |
shiftContainer(IAtomContainer container,
Rectangle2D bounds,
Rectangle2D last,
double gap)
Shift the container horizontally to the right to make its bounds not
overlap with the other bounds.
|
static Rectangle2D |
shiftReactionVertical(IReaction reaction,
Rectangle2D bounds,
Rectangle2D last,
double gap)
Shift the containers in a reaction vertically upwards to not overlap
with the reference Rectangle2D.
|
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
|
static void |
translate2D(IAtomContainer atomCon,
double transX,
double transY)
Translates the given molecule by the given Vector.
|
static void |
translate2D(IAtomContainer atomCon,
javax.vecmath.Vector2d vector)
Translates a molecule from the origin to a new point denoted by a vector.
|
static void |
translate2DCenterTo(IAtomContainer container,
javax.vecmath.Point2d p)
Translates the geometric 2DCenter of the given
AtomContainer container to the specified Point2d p.
|
static void |
translate2DCentreOfMassTo(IAtomContainer atomCon,
javax.vecmath.Point2d p)
Translates a molecule from the origin to a new point denoted by a vector.
|
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.
|
public static void translateAllPositive(IAtomContainer atomCon)
atomCon
- AtomContainer for which all the atoms are translated to
positive coordinatespublic static void translate2D(IAtomContainer atomCon, double transX, double transY)
atomCon
- The molecule to be translatedtransX
- translation in x directiontransY
- translation in y directionpublic static void scaleMolecule(IAtomContainer atomCon, Dimension areaDim, double fillFactor)
atomCon
- The molecule to be scaledareaDim
- The dimension to be filledfillFactor
- The percentage of the dimension to be filledpublic static void scaleMolecule(IAtomContainer atomCon, double scaleFactor)
atomCon
- The molecule to be scaledscaleFactor
- Description of the Parameterpublic static void center(IAtomContainer atomCon, Dimension areaDim)
atomCon
- molecule to be centeredareaDim
- dimension in which the molecule is to be centeredpublic static void translate2D(IAtomContainer atomCon, javax.vecmath.Vector2d vector)
atomCon
- molecule to be translatedvector
- dimension that represents the translation vectorpublic static void rotate(IAtomContainer atomCon, javax.vecmath.Point2d center, double angle)
atomCon
- The molecule to be rotatedcenter
- A point giving the rotation centerangle
- The angle by which to rotate the molecule, in radianspublic static void rotate(IAtom atom, javax.vecmath.Point3d p1, javax.vecmath.Point3d p2, double angle)
atom
- The atom to rotatep1
- The first point of the line segmentp2
- The second point of the line segmentangle
- The angle to rotate by (in degrees)public static void normalize(javax.vecmath.Point3d point)
point
- The point to normalizepublic static Dimension get2DDimension(IAtomContainer atomCon)
atomCon
- of which the dimension should be returnedpublic static Rectangle2D getRectangle2D(IAtomContainer container)
container
- IAtomContainer
to calculate the rectangle forRectangle2D
describing the space occupiedpublic static double[] getMinMax(IAtomContainer container)
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
container
- Description of the Parameterpublic static void translate2DCentreOfMassTo(IAtomContainer atomCon, javax.vecmath.Point2d p)
atomCon
- molecule to be translatedp
- Description of the Parameterpublic static javax.vecmath.Point2d get2DCenter(Iterable<IAtom> atoms)
atoms
- The vector of the given atomspublic static javax.vecmath.Point2d get2DCenter(Iterator<IAtom> atoms)
atoms
- The Iterator of the given atomspublic static javax.vecmath.Point2d get2DCenter(IRingSet ringSet)
ringSet
- Description of the Parameterpublic static javax.vecmath.Point2d get2DCentreOfMass(IAtomContainer ac)
Atom
s in the
AtomContainer for the 2D coordinates.
See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate setsac
- AtomContainer for which the center of mass is calculatedIAtom
's masses are nullpublic static javax.vecmath.Point2d get2DCenter(IAtomContainer container)
container
- Description of the Parameterpublic static void translate2DCenterTo(IAtomContainer container, javax.vecmath.Point2d p)
container
- AtomContainer which should be translated.p
- New Location of the geometric 2D Center.get2DCenter(java.lang.Iterable<org.openscience.cdk.interfaces.IAtom>)
,
translate2DCentreOfMassTo(org.openscience.cdk.interfaces.IAtomContainer, javax.vecmath.Point2d)
public static javax.vecmath.Point3d get3DCentreOfMass(IAtomContainer ac)
Atom
s in the
AtomContainer for the 2D coordinates.
See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate setsac
- AtomContainer for which the center of mass is calculatedpublic static javax.vecmath.Point3d get3DCenter(IAtomContainer ac)
ac
- Description of the Parameterpublic static double getAngle(double xDiff, double yDiff)
xDiff
- Description of the ParameteryDiff
- Description of the Parameterpublic static int[] distanceCalculator(int[] coords, double dist)
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 calculatedpublic static double[] distanceCalculator(double[] coords, double dist)
public static int[] getBondCoordinates(IBond bond)
bond
- The given bondpublic static IAtom getClosestAtom(int xPosition, int yPosition, IAtomContainer atomCon)
xPosition
- The x coordinateyPosition
- The y coordinateatomCon
- The molecule that is searched for the closest atompublic static IAtom getClosestAtom(IAtomContainer atomCon, IAtom atom)
atomCon
- The molecule that is searched for the closest atomatom
- The atom to search aroundpublic static IAtom getClosestAtom(double xPosition, double yPosition, IAtomContainer atomCon, IAtom toignore)
xPosition
- The x coordinateyPosition
- The y coordinateatomCon
- The molecule that is searched for the closest atomtoignore
- This molecule will not be returned.public static IAtom getClosestAtom(double xPosition, double yPosition, IAtomContainer atomCon)
xPosition
- The x coordinateyPosition
- The y coordinateatomCon
- The molecule that is searched for the closest atompublic static IBond getClosestBond(int xPosition, int yPosition, IAtomContainer atomCon)
xPosition
- The x coordinateyPosition
- The y coordinateatomCon
- The molecule that is searched for the closest bondpublic static IBond getClosestBond(double xPosition, double yPosition, IAtomContainer atomCon)
xPosition
- The x coordinateyPosition
- The y coordinateatomCon
- The molecule that is searched for the closest bondpublic static void sortBy2DDistance(IAtom[] atoms, javax.vecmath.Point2d point)
point
- The point from which the distances to the atoms are measuredatoms
- The atoms for which the distances to point are measuredpublic static double getScaleFactor(IAtomContainer container, double bondLength)
container
- The AtomContainer for which the ScaleFactor is to be
calculatedbondLength
- The target bond lengthpublic static double getBondLengthAverage(IAtomContainer container)
container
- The AtomContainer for which the average bond length is to be
calculatedpublic static double getLength2D(IBond bond)
bond
- Description of the Parameterpublic static boolean has2DCoordinates(IAtomContainer container)
container
- Description of the Parameterpublic static int has2DCoordinatesNew(IAtomContainer container)
container
- the molecule to be consideredpublic static boolean has2DCoordinates(IAtom atom)
atom
- Description of the Parameterpublic static boolean has2DCoordinates(IBond bond)
bond
- Description of the Parameterpublic static boolean has3DCoordinates(IAtomContainer container)
container
- the molecule to considerpublic static javax.vecmath.Vector2d calculatePerpendicularUnitVector(javax.vecmath.Point2d point1, javax.vecmath.Point2d point2)
point1
- Description of the Parameterpoint2
- Description of the Parameterpublic static double getNormalizationFactor(IAtomContainer container)
container
- Description of the Parameterpublic static int getBestAlignmentForLabel(IAtomContainer container, IAtom atom)
container
- Description of the Parameteratom
- Description of the Parameterpublic static int getBestAlignmentForLabelXY(IAtomContainer container, IAtom atom)
container
- Description of the Parameteratom
- Description of the Parameterpublic static List<IAtom> findClosestInSpace(IAtomContainer container, IAtom startAtom, int max) throws CDKException
container
- The AtomContainer to examinestartAtom
- the atom to start frommax
- the number of neighbours to returnCDKException
- Description of the Exceptionpublic static Map<Integer,Integer> mapAtomsOfAlignedStructures(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, double searchRadius, Map<Integer,Integer> mappedAtoms) throws CDKException
firstAtomContainer
- the (largest) first aligned AtomContainer which is the referencesecondAtomContainer
- the second aligned AtomContainersearchRadius
- the radius of space search from each atomCDKException
- Description of the Exceptionpublic static double getBondLengthRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map<Integer,Integer> mappedAtoms, boolean Coords3d)
firstAtomContainer
- the (largest) first aligned AtomContainer which is the referencesecondAtomContainer
- the second aligned AtomContainermappedAtoms
- Map: a Map of the mapped atomsCoords3d
- boolean: true if moecules has 3D coords, false if molecules has 2D coordspublic static double getAngleRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map<Integer,Integer> mappedAtoms)
firstAtomContainer
- the (largest) first aligned AtomContainer which is the referencesecondAtomContainer
- the second aligned AtomContainermappedAtoms
- Map: a Map of the mapped atomspublic static double getAllAtomRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map<Integer,Integer> mappedAtoms, boolean Coords3d) throws CDKException
firstAtomContainer
- the (largest) first aligned AtomContainer which is the referencesecondAtomContainer
- the second aligned AtomContainermappedAtoms
- Map: a Map of the mapped atomsCoords3d
- boolean: true if molecules has 3D coords, false if molecules has 2D coordsCDKException
- if there is an error in getting mapped atomspublic static double getHeavyAtomRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map<Integer,Integer> mappedAtoms, boolean hetAtomOnly, boolean Coords3d)
firstAtomContainer
- the (largest) first aligned AtomContainer which is the referencesecondAtomContainer
- the second aligned AtomContainermappedAtoms
- Map: a Map of the mapped atomshetAtomOnly
- boolean: true if only hetero atoms should be consideredCoords3d
- boolean: true if molecules has 3D coords, false if molecules has 2D coordspublic static double getBondLengthAverage3D(IAtomContainer container)
container
- The AtomContainer for which the average bond length is to be
calculatedpublic static Rectangle2D shiftContainer(IAtomContainer container, Rectangle2D bounds, Rectangle2D last, double gap)
container
- the IAtomContainer
to shift to the rightbounds
- the Rectangle2D
of the IAtomContainer
to shiftlast
- the bounds that is used as referencegap
- the gap between the two Rectangle2D
sRectangle2D
of the IAtomContainer
after the shiftpublic static double getBondLengthAverage(IReaction reaction)
public static boolean has3DCoordinates(IChemModel chemModel)
chemModel
- the ChemModel to considerpublic static Rectangle2D shiftReactionVertical(IReaction reaction, Rectangle2D bounds, Rectangle2D last, double gap)
reaction
- the reaction to shiftbounds
- the bounds of the reaction to shiftlast
- the bounds of the last reaction