Opened 6 years ago
Last modified 5 years ago
#2797 assigned defect
Missing clip caps for models with non-rotation position matrices (instancing)
Reported by: | Tristan Croll | Owned by: | Tom Goddard |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | Graphics | Version: | |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Notify when closed: | Platform: | all | |
Project: | ChimeraX |
Description
The following bug report has been submitted: Platform: Linux-3.10.0-1062.9.1.el7.x86_64-x86_64-with-centos-7.7.1908-Core ChimeraX Version: 0.92 (2020-02-03) Description Clip capping fails for `Drawing`s that are substantially stretched or scaled up by instancing. In `surface.cap.box_positions_intersecting_plane()`: {{{ def box_positions_intersecting_plane(positions, b, origin, normal): c, r = b.center(), b.radius() pc = positions * c pc -= origin from numpy import dot, abs dist = abs(dot(pc,normal)) bint = (dist <= r) ipos = positions.masked(bint) return ipos }}} ... `b.radius()` (aka `Bounds.radius()`) is calculated before taking any transforms into account, so fails if the prototype geometry is much smaller than the final displayed image. Log: UCSF ChimeraX version: 0.92 (2020-02-03) © 2016-2020 Regents of the University of California. All rights reserved. How to cite UCSF ChimeraX > open 6qiy format mmCIF fromDatabase pdb structureFactors true Summary of feedback from opening 6qiy fetched from pdb --- notes | Resolution: 1.5000893166901514 Reflection data provided as intensities. Performing French & Wilson scaling to convert to amplitudes... 6qiy title: CI-2, conformation 1 [more info...] Chain information for 6qiy --- Chain | Description 1.1/A | Subtilisin-chymotrypsin inhibitor-2A 6qiy mmCIF Assemblies --- 1| software_defined_assembly > toolshed show Shell /opt/UCSF/ChimeraX-daily/lib/python3.7/site- packages/IPython/core/history.py:226: UserWarning: IPython History requires SQLite, your history will not be saved warn("IPython History requires SQLite, your history will not be saved") Drag select of Drag select of > select clear Drag select of OpenGL version: 3.3.0 NVIDIA 440.33.01 OpenGL renderer: TITAN Xp/PCIe/SSE2 OpenGL vendor: NVIDIA Corporation
Change History (5)
follow-up: 2 comment:2 by , 6 years ago
Looks like a related issue: for vanilla `Drawing` objects consisting of stretched-out cylinders generated by instancing of a unit cylinder, the tooltip on mouse hover only appears very close to the mid-point of a given cylinder. I see that tooltips for pseudobonds work fine - guess that's due to some custom `first_intercept()` code? On 2020-02-04 12:52, ChimeraX wrote:
comment:3 by , 6 years ago
Component: | Unassigned → Graphics |
---|---|
Owner: | set to |
Platform: | → all |
Project: | → ChimeraX |
Status: | new → assigned |
Summary: | ChimeraX bug report submission → Problems with instanced Drawings |
comment:4 by , 6 years ago
Priority: | normal → minor |
---|
The surface cap code box_positions_intersecting_plane(positions, bounds, ...) is an optimization to determine which drawings cross the clip plane -- only those drawings need caps. That code is trying to handle multiple placed copies of a drawing by using the bounds of one copy of the drawing and considering all the positions where it has been placed. But as you note it does not consider that the positioning matrix might scale the size of the drawing. It just takes the radius of the drawing and translates that sphere using the positions. So it does not correctly determine whether drawing copies intersect the plane if the position matrices are doing scaling.
In general, the ChimeraX Drawing objects are expected to have only rotation and translation, no scaling or skewing in the position matrix. The instancing business is a complex low-level optimization needed for atoms and bonds because there can be millions of those. The instancing code and APIs is a bit of a mess. They always use scaling in the position matrix so they violate the assumptions for Drawing objects.
The reason for wanting to assume positions are rotations without scaling or skewing is because it both simplifies and speeds up many calculations. For instance in the capping code, it only needed to consider the translation and not the 3x3 matrix at all. Matrix inverses are simple and fast to compute for rotations since they are just the transpose.
We try to strike some balance between generality (e.g. handle all 3x3 matrix transforms) with slow speed, and fast speed with assumptions that lead to bugs, and simplicity of code. Given our limited resources ugly compromises must be made.
You are right that bond picking works because it has its own dedicated code which was added not to work around non-rotation matrices, but to make it fast for a million bonds.
Unfortunately given the current compromises, if you use instancing (Drawings with multiple position matrices) you better know exactly what you are doing and be prepared for bugs and hard work to get around the limitations. I'm afraid that is not likely to change much, although I think it could be improved a lot if time were available.
I think this surface capping bug should be fixed, but it is a low priority. Currently no instanced geometry with scaling uses clipping caps (bonds, pseudobonds, atom spheres). Clipping caps are turned off for those because they would greatly impair performance since there are often tens of thousands of instances and the cap calculation is slow.
comment:5 by , 5 years ago
Summary: | Problems with instanced Drawings → Missing clip caps for models with non-rotation position matrices (instancing) |
---|