Coords and matrices

Hi,

today I committed my auto-center-and-fit-in-XY-plane feature. Finally I
thought it made sense to combine both in one function, tell me if that’s not
OK.

Finally I put it in Molecule, not in GLWidget, I think that makes more sense,
hope I got your design right.

Just to demonstrate it, I added a call to it from GLWidget::setMolecule.

But anyway, it will have to be completely modified for Avo: as Geoff said,
changing the molecule’s coordinate system is not good for a molecular
editor (while for Kalzium it was OK).

I propose to do the following changes if you’re OK:

  • replace the translationVector, rotation and scaling by a single 4x4
    modelview matrix, using Eigen::MatrixP3d.
  • at molecule loading, don’t change the molecule coords; instead, compute a
    sensible default modelview matrix, reusing my auto-center-and-fit-in-XY-plane
    code, and auto-adjusting to the molecule’s radius.
  • store separately the "approximate normal vector to the molecule’s plane"
    computed in previous step
  • modify (or overload) Cylinder::draw to take this normal vector as argument,
    using it for auto-orientation of double bonds. This doesn’t mean any overhead,
    thanks to using OpenGL display lists.

After all, the only reason why I wanted to change molecule coordinates, was
that it allowed to make Cylinder::draw slightly simpler. Not anything
fundamental…

Cheers,
Benoit

(Mon, Mar 12, 2007 at 09:17:48AM +0100) Benoît Jacob jacob@math.jussieu.fr:

Hi,

today I committed my auto-center-and-fit-in-XY-plane feature. Finally I
thought it made sense to combine both in one function, tell me if that’s not
OK.

that’s fine but would there be times you might want one without the
other? If so we could have a function that executes both functions. If
not, single func. is OK. I realize this means we have two context
switches but i don’t feel this is a function we’ll be calling ALL that
much and might want the diversity.

Finally I put it in Molecule, not in GLWidget, I think that makes more sense,
hope I got your design right.

If it’s not going to modify the molecule coordinates, then it should be
a function in the GLWidget class because it’s just reorienting the
camera. If it does change the molecular coordinates then it can go in
the Molecule class.

Just to demonstrate it, I added a call to it from GLWidget::setMolecule.

But anyway, it will have to be completely modified for Avo: as Geoff said,
changing the molecule’s coordinate system is not good for a molecular
editor (while for Kalzium it was OK).

I propose to do the following changes if you’re OK:

  • replace the translationVector, rotation and scaling by a single 4x4
    modelview matrix, using Eigen::MatrixP3d.

i’m curious about this but trust you so sounds good.

  • at molecule loading, don’t change the molecule coords; instead, compute a
    sensible default modelview matrix, reusing my auto-center-and-fit-in-XY-plane
    code, and auto-adjusting to the molecule’s radius.

I think this sounds good too. It would be cool if people can use a tool
that allows them to orient the molecule from any point in space. Or
say, “View form Z Axis” / “View from X Axis”. Whatever, all cool.

  • store separately the “approximate normal vector to the molecule’s plane”
    computed in previous step
  • modify (or overload) Cylinder::draw to take this normal vector as argument,
    using it for auto-orientation of double bonds. This doesn’t mean any overhead,
    thanks to using OpenGL display lists.

After all, the only reason why I wanted to change molecule coordinates, was
that it allowed to make Cylinder::draw slightly simpler. Not anything
fundamental…

We can talk on IRC and brainstorm but all this stuff sounds good. I
think what you need from me is more where to put the stuff.

When i do get home i think what i’ll do is try to draw up some
architecture drawings to show how data flows between parts of avogadro.
This would also give architecture of libavogadro. Then from these
drawings we can figure out where we want to go and how to put the tools
into it also.

Out,
Donald

On Mar 12, 2007, at 8:29 PM, Donald Ephraim Curtis wrote:

I think this sounds good too. It would be cool if people can use a
tool
that allows them to orient the molecule from any point in space. Or
say, “View form Z Axis” / “View from X Axis”. Whatever, all cool.

Yes, this is often a nice feature. Jmol and Chime also had the
ability to write a script to give a “tour” of a molecule.

Views from particular axes also become important with crystal
structures. Sometimes you want to orient along a particular plane or
axis. I think that’s probably something to add later.

When i do get home i think what i’ll do is try to draw up some
architecture drawings to show how data flows between parts of
avogadro.
This would also give architecture of libavogadro. Then from these
drawings we can figure out where we want to go and how to put the
tools
into it also.

I believe the wiki can upload pictures. If not, let me know and I’ll
fix it. Pictures definitely sound like the right way to go – and the
wiki can allow us to keep a record of the brainstorms.

Just my $0.01,
-Geoff

On Tuesday 13 March 2007 01:29:18 Donald Ephraim Curtis wrote:

that’s fine but would there be times you might want one without the
other? If so we could have a function that executes both functions. If
not, single func. is OK. I realize this means we have two context
switches but i don’t feel this is a function we’ll be calling ALL that
much and might want the diversity.

OK, so anyway this is deprecated in favor of what I described below in my
mail. Sorry for the confusion - that’s what happens when I don’t think enough
before starting writing a new mail…

If it’s not going to modify the molecule coordinates, then it should be
a function in the GLWidget class because it’s just reorienting the
camera. If it does change the molecular coordinates then it can go in
the Molecule class.

It is changing the molecule coords. However I’m replacing this with another
approach that isn’t changing the molecule coords, but is computing some data
specific to the molecule, like: normal vector to the approximate fitting
plane of the molecule, radius of the molecule, center of the molecule. As
these are properties of the molecule, I thought it would fit in the Molecule
class. What’s your opinion?

I think this sounds good too. It would be cool if people can use a tool
that allows them to orient the molecule from any point in space. Or
say, “View form Z Axis” / “View from X Axis”. Whatever, all cool.

OK, sure! That’s very easy to do, and indeed it requires that we don’t change
the molecule’s coordinate system.

We can talk on IRC and brainstorm but all this stuff sounds good. I
think what you need from me is more where to put the stuff.

Yes, exactly! Don’t know when I’ll be able to log on IRC though.
I think I’ll do a first implementation and then it’ll be easy to move things
around if it’s not where you want it.

When i do get home i think what i’ll do is try to draw up some
architecture drawings to show how data flows between parts of avogadro.
This would also give architecture of libavogadro. Then from these
drawings we can figure out where we want to go and how to put the tools
into it also.

That would be great!

Cheers,
Benoit