| Benoît Jacob ( @ 2006-11-17 10:23:00 |
| Entry tags: | kalzium 3d eigen kde |
First benefits of using Eigen for Kalzium
In Kalzium's 3D viewer, a problem was that when you loaded a molecule, the default viewpoint was not always optimal, sometimes totally unreadable. For instance, look at this molecule of L-tryptophan :
Of course, Kalzium always allowed to freely rotate around the molecule, so after some mouse effort, you could get that:
But then, a second problem appears: depending on the viewing angle, double bonds can look like single bonds. In the above pic, one should see 6 double bonds. This even mislead some people into believing that our molecule files were wrong! So I sat down and figured that the first thing to do was to perform a linear regression to compute the best-fitting plane for the molecule. Once we know that plane, elementary geometry allows to find a nice viewpoint and to orient the multiple bonds in a convenient way. So I implemented linear regression and a computeFittingHyperplane function in Eigen, and reworked Kalzium's 3D viewer to make use of it. Result:
I haven't had to do any manual rotation for this screenshot, this is the exact viewpoint you get when you load the molecule. Also note that now the 6 double bonds clearly appear. Maximizing the window, I got this.
About speed: for these screenies, I take the high-quality mode, and get 56 FPS on my software-only (no hardware acceleration) 1.66 GHz Intel Core 1. In low-quality mode, I get 178 FPS, and at this window size, the visual difference is not too big. Even on Carsten's laptop, it runs OK ;)
Update: as a comment pointed out, the molecule file is wrong, there is one hydrogen atom missing and one double bond too much. This was a bug in the (very old) molecule file that I used, and has been fixed since in the BlueObelisk project.