Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#521 closed defect (invalid)

Problem positioning drawing copies

Reported by: tic20@… Owned by: Tom Goddard
Priority: blocker Milestone:
Component: Graphics Version:
Keywords: Cc:
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

Hi,

I've been messing around a lot with Places over the past couple of days, working at getting symmetry copies of a molecule to display as duplicates of the one Model object using the Model.positions property. I saw the following passage from the documentation at http://preview.cgl.ucsf.edu/chimerax/docs/devel/core/graphics/graphics.html#chimerax.core.graphics.drawing.Drawing:

"Multiple copies of a drawing be drawn with specified positions and colors. Copy positions can be specified by a shift and scale factor but no rotation, useful for copies of spheres. Each copy can be displayed or hidden, selected or unselected."

Unless I'm misunderstanding something about the implementation, it would appear that the reason rotations haven't been working as expected is that somewhere in the Place pipeline the rotation matrix is getting transposed, so it's failing any time the matrix is non-symmetrical. Demonstration:

import numpy
from chimerax.core.geometry import Place
rot = numpy.array(1, 0, 0],[1,-1,0],[0,0,-1,numpy.double)
p = Place(axes = rot)
c1 = numpy.array([40, 50, 60],numpy.double)
c2 = numpy.array([c1])
c3 = numpy.array([c1])
c1 = numpy.matmul(rot,c1.transpose())
p.move(c2)
p.transpose().move(c3)

c1

array([40., -10., -60.])

c2

array([90., -50., -60.])

c3

array([40., -10., -60.])

Cheers,

Tristan

Change History (3)

comment:1 by Tom Goddard, 9 years ago

Resolution: invalid
Status: assignedclosed

You misunderstand the arguments to the Place constructor. If you want to just do a matrix multiplication using p.move(v) then use

p = Place(matrix = ((1,0,0,0),(1,-1,0,0),(0,0,-1,0)))

in your example. The matrix for a Place object is a 3x4 matrix where the first 3x3 is a linear transformation and the 4th column is a translation that is added after the linear transformation. In your example you instead use Place(axes = (...)) which sets the first 3 columns of the matrix. In other words the first specified axis is the x axis of the place coordinate system so p.move((1,0,0)) will map to that first axis, the second specified axis is what (0,1,0) maps to, and the third specified axis is what (0,0,1) maps to. This is the transpose of what you appear to be trying to do (although I'm not clear on what you are trying to do).

in reply to:  2 ; comment:2 by tic20@…, 9 years ago

Hi Tom,

Ok, my bad. The issue arose while attempting to apply the transformation matrices returned by Clipper to generate the unit cell (standard 4x4 Affine transform matrices as per https://people.cs.clemson.edu/~dhouse/courses/401/notes/affines-matrices.pdf, which rotates & translates your initial coordinates as a single matrix multiplication). As long as it's working as expected that's fine, but I was clearly confused as to the object 
initialisation (it comes out looking like a normal Affine transformation matrix, minus the last row, so I wrongly assumed that's what it was).

Cheers,

Tristan

 
 
Tristan Croll
Research Fellow
Cambridge Institute for Medical Research
University of Cambridge CB2 0XY
 

 

in reply to:  3 ; comment:3 by tic20@…, 9 years ago

Oh wait - I see it now. Sorry for the misunderstanding.

For what it's worth, though, that line in the documentation seems to be 
obsolete. When I get the matrices correct, that sentence in the 
documentation ("Copy positions can be specified by a shift and scale 
factor but no rotation, useful for copies of spheres.") seems to be 
obsolete. Placement of copies with arbitrary transformations appears to 
work perfectly.

Cheers,

Tristan

On 2017-01-20 07:09, Tristan Croll wrote:

Note: See TracTickets for help on using tickets.