Mon 08 Sep 2014 08:01:16 PM UTC, comment #12:
I have found that the linear transformation code (in libs/gcu/matrix.cc) is a terrible mess.
To rotate a point with coordinates (x, y, z) by some angle θ along a given axis (x, y, or z), you have to multiply it with the corresponding transformation matrix:
Rx(θ) = ( 1, 0, 0,
0, cos(θ), -sin(θ),
0, sin(θ), cos(θ) )
Ry(θ) = ( cos(θ), 0, sin(θ),
0, 1, 0,
-sin(θ), 0, cos(θ) )
Rz(θ) = ( cos(θ), -sin(θ), 0,
sin(θ), cos(θ), 0,
0, 0, 1 )
I = ( 1, 0, 0,
0, 1, 0,
0, 0, 1 )
In the code, these matrices are somehow lumped together and hard-coded into two composite matrices called "euler" and "antieuler". For rotation, a multiplicative transformation is generated on the fly by multiplication of "euler" with "antieuler". I am still trying to figure out what those "euler" matrices are (Rx(ψ) x Ry(θ) x Rz(φ)?)
Having no identity operation, the system is comparable to the system of real numbers, but without the number one, so that the result of (x * 1) is undefined. In addition, the system only allows multiplication, but no addition. Therefore, you can only rotate a molecule, but you cannot not move it (which would be nice, for example by using the right mouse button).
In any case, the linear transformation code needs to be restructured like above to make it more comprehensible, extendable and less buggy. Those changes are more important than details like preference dialogs and GL shading.
There should also be a link to a source explaining the algorithm. Many trivial things in the code are commented, but the significant ones aren't. The transformation matrices above are from Banchoff/Wermer, Linear Algebra through Geometry, Springer, 1983, UTM 44.
|
Fri 29 Aug 2014 06:41:05 PM UTC, comment #7:
In my patch, I left out these two lines, because they looked like a workaround:
+ if ((event->x == View->m_Lastx) && (event->y == View->m_Lasty))
+ return false;
Leaving them out makes the molecule disappear when you hit the screen border while dragging the molecule.
That means that View->Rotate(0.0, 0.0) does not work as expected. In my opinion it should: a no-op rotation (0, 0) is a valid transformation that should not break the molecule view. It occurs rarely and there is no need to optimize it out. It is an identity matrix multiplication, which should happen elsewhere.
Did you commit anything related to this? If yes, please upload the patch so I can test it.
|
Thu 21 Aug 2014 10:47:36 AM UTC, comment #2:
The bug is easily reproducible on Fedora 19 and 20 with the latest packaged gtk3 versions (gtk3-3.10.9-1 on Fedora 20). It occurs accidentally when you try to rotate a molecule quickly along any axis.
Here is a detailed instruction:
Open up any molecule in the viewer (e. g. Tools menu -> Import molecule ... -> Enter "CCO", the SMILES code for ethanol -> Apply).
Rotate the molecule diagonally from the lower left corner to the upper right corner of the viewer window:
Move the mouse pointer to the lower left corner of the window. Rotate the molecule to the upper right corner of the window, but take care that the mouse pointer is moving when you left-click ("sliding left click"). Slowly moving the mouse while clicking will suffice. Finish the rotation by dragging the mouse pointer to the upper right corner of the window. Release the left mouse button.
Continue the previous rotation. Move the mouse pointer back to the lower left corner of the window. Start the rotation by moving the mouse pointer diagonally up and right, then click the left mouse button while moving (sliding left click). You'll see that the molecule gets jerked back to the start of the previous rotation.
|