Determine the far right of a molecule

User c23c5e9da4

03-04-2007 18:58:05

What is the best way to determine the largest x of a molecule's bounds?





Molecule m = mol.getReactant(i);


DPoint3 center = m.calcCenter();


double farRight = center.x + (m.calcWidth() / 2);





This is what I am doing right now and it doesn't work very well - it reports values that overlap with the molecule.

User c23c5e9da4

03-04-2007 19:40:10

I found that this give accurate results - is this the best way to do it?





for(DPoint3 point : m.getPoints()) {


farRight = Math.max(farRight, point.x);


}

User f359e526a1

04-04-2007 08:38:25

Hello, is not Molecule.getImageSize(..) more convenient for your purposes? Also there is a MoleculeGraph.calcOutRect() that is doing more or less what you wrote in the snippet.

User c23c5e9da4

04-04-2007 16:01:17

perhaps calcOutRect is what I need but I am confused by how to interpret the results - it returns a DPoint3 which holds an x, y, z - is this the point in the upper left of the box and I use getHeight and getWidth to determine the box?

User f359e526a1

11-04-2007 06:57:37

Sorry for the late answer, in short: calcOutRect() calculates the extend of the bounding box around the moleclule (x: width, y: height, z: depth). Molecule.calcCenter() gives the centre of this rectangle.