Pardon me if this should go elsewhere, but it seems like a problem with a linear algebra solution.(adsbygoogle = window.adsbygoogle || []).push({});

I have a series of PDB files from a molecular dynamics simulation of modified DNA strands. I use the program Pymol (http://www.pymol.org) to visualize them as a "movie." But now I want to make a real movie - that is, create a series of raster images that I can encode as a video file. I know how to do that with Pymol, by loading a PDB file, adjusting viewing parameters, and rendering/saving a raster image (repeat x1000). The problem is that the molecule shifts and twists over time, so that the region I want to view becomes hard to see unless I make adjustments by rotating the view. When I'm making raster frames I cannot use the interactive mouse controls like I would when viewing on my desktop machine; I must programmatically determine the compensation-rotations to keep my region of interest unobscured and level.

My idea is to pick two carbon atoms from opposite sides of the strand but located on the same level and two on the same side but located on different levels like so:

http://www.sciencemadness.org/scipics/shot1.png (front)

http://www.sciencemadness.org/scipics/shot2.png (top)

http://www.sciencemadness.org/scipics/shot3.png (side)

Imagine a measurement of the vertical distance between the two left green points or the two right green points (I will just choose left or right and stick with it, ultimately), as seen by the viewing camera. I want to rotate the model so that this vertical distance is maximized (constraint 1). Now imagine a measurement of the horizontal distance between the two magenta points as seen by the viewing camera. I want to maximize this distance (constraint 2) with rotation while still honoring constraint 1. I think this constraint should naturally produce a line that appears perfectly horizontal, but if doesn't, consider "the line must appear perfectly horizontal" as an additional constraint. There are multiple "best" views possible, since mirrored views are going to be the same, but the chosen view should be the best view that differs the least from the best view of the previous frame (constraint 3). This is a long-winded way of saying that I want to always be orienting the model so that I have a clear head-on view of these 3 base pairs.

Here's what I have to work with in modifying the view:

Suppose that everything but the rotation matrix will remain static over the course of the animation, but any of these values can be retrieved. I know that these constraints *can* be satisfied, but I'm at a loss how to go about it. I've done only a little with 3D graphics before, and the other systems I used let me use quaternions or Euler angles to control rotations. Here I just have a matrix. I've spent some time reading Contents of the view matrix

0 - 8 = 3x3 rotation matrix which transforms model to camera space

9 - 11 = camera position (in model space and relative to the origin of rotation)

12 - 14 = origin of rotation (in model space)

15 = front plane distance from the camera

16 = rear plane distance from the camera

17 = orthoscopic flagComputer Graphics: Principles and Practiceas well as the comp.graphics.algorithms FAQ, and neither got me very far. I have a feeling that this would be a pretty simple problem for someone well-versed in linear algebra or 3D graphics, but I am not yet that someone and I need to make these animations before next week

I would very much appreciate it if someone can help me with this, keeping in mind that I did once study linear algebra but it was a while ago, and that I am familiar with most graphics terms (if not the actual implementations).

Edit: I botched one of my constraints. The "maximize vertical distance as seen by the camera" constraint doesn't work because of the twisting of the strand. This constraint will lead to terrible viewing angles. Maybe I should have said "as seen by an orthographic camera" or somesuch... along with additional constraints on what sort of rotation is allowed? Meh, this is even trickier than I thought. I always want to view this 3 base pair region head-on, however that can be stated formally. Any suggestions for dealing with my problem are welcome, even if they're "download this great molecular visualization program BlahViz, it'll do what you want out of the box."

**Physics Forums - The Fusion of Science and Community**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# 3D graphics: finding optimal view of a scene with constraints

Loading...

Similar Threads for graphics finding optimal | Date |
---|---|

I How to find admissible functions for a domain? | Jan 31, 2018 |

I How to find the matrix of the derivative endomorphism? | Oct 22, 2017 |

LP objective function with unknown parameters | Nov 9, 2015 |

Graphical modeling of a dynamic system Help! | Mar 11, 2012 |

Simple intuitive/graphical interpretation of the Gauss-Seidel method | Nov 9, 2008 |

**Physics Forums - The Fusion of Science and Community**