Thank you, Elaine and Tom. This makes sense. I will center my model first such that the position matrix will be more interpretable.

Best,
Zheng

On Thu, Mar 31, 2022 at 2:04 PM Tom Goddard <goddard@sonic.net> wrote:
Hi Zheng,

  Here's a bit more explanation.  Each model has a coordinate system and the ChimeraX scene has its own coordinate system.  When you first load a model its coordinate system is the same as the scene coordinate system.  But if you move the model using for instance the "model" option of the turn command it will move the model within the scene and the model and scene coordinate systems will be different.

  The turn command by default uses a center of rotation which is the center of the bounding box of the displayed part of your model.  That center will not be 0,0,0 in general.  So when you used the turn command without specifying the center, it rotated about a point that was not 0,0,0.  When you use the "view matrix" command it reports the position of models as a rotation around 0,0,0 followed by a translation.  Your rotation done with the turn command was not centered on 0,0,0 so it is equivalent to a rotation about 0,0,0 plus some non-zero translation, which is what you observed.

  So as Elaine points out you need to specify "center 0,0,0" in your turn command.

  One further detail.  The rotation and translation reported by view matrix maps a point in model coordinates to scene coordinates.  You might think it maps from scene to model coordinates but that would require inverting the transformation.

        Tom


> On Mar 31, 2022, at 9:40 AM, Elaine Meng via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
>
> Hi Zheng,
> My mistake, instead of "center #1" I should have said "center 0,0,0" ... try that:
>
> turn z 90 models #1 center 0,0,0
>
> Then the translation should be all zero.
> Best,
> Elaine
> -----
> Elaine C. Meng, Ph.D.
> UCSF Chimera(X) team
> Department of Pharmaceutical Chemistry
> University of California, San Francisco
>
>> On Mar 31, 2022, at 9:30 AM, Zheng Ruan via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
>>
>> Hi Elaine,
>>
>> Thank you for the reply. However, I don't see a large translation of my map after I type the "turn" command. I only have one map loaded in ChimeraX and the map is rotated about its own z-axis.
>>
>> I also tried to specify the "center" option as suggested, but I still see a large translation value. For example,
>>
>> open volume.mrc format mrc
>>
>> view matrix
>> camera position: 1,0,0,345.63,0,1,0,343.7,0,0,1,1042.6
>> model positions: #1,1,0,0,0,0,1,0,0,0,0,1,0,#1.1,1,0,0,0,0,1,0,0,0,0,1,0
>>
>> turn z 90 models #1 center #1
>>
>> view matrix
>> camera position: 1,0,0,345.63,0,1,0,343.7,0,0,1,1042.6
>> model positions: #1,1.1102e-16,-1,0,689.33,1,1.1102e-16,0,-1.9358,0,0,1,0,#1.1,1,0,0,0,0,1,0,0,0,0,1,0
>>
>> I also tried to change the center of rotation, but the result remains the same.
>>
>> Best,
>> Zheng
>>
>>
>> On Thu, Mar 31, 2022 at 11:20 AM Elaine Meng <meng@cgl.ucsf.edu> wrote:
>> Dear Zheng,
>> I believe it is because the center of rotation from your command is not the same as the center of the model.  If the center of rotation is far from the model, it might be translated a large distance in addition to being rotated.  You can specify the center of rotation for the "turn" command with the "center" option.  I believe that if you use
>>
>> turn z 90 models #1 center #1
>>
>> ...the translation of the model would then be zero or close to zero.
>>
>> See help for "turn"
>> <https://rbvi.ucsf.edu/chimerax/docs/user/commands/turn.html>
>>
>> I hope this helps,
>> Elaine
>> -----
>> Elaine C. Meng, Ph.D.                       
>> UCSF Chimera(X) team
>> Department of Pharmaceutical Chemistry
>> University of California, San Francisco
>>
>>
>>> On Mar 30, 2022, at 8:18 PM, Zheng Ruan via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
>>>
>>> Dear ChimeraX users,
>>>
>>> I'm trying to understand the model position matrix. According to the documentation, "Each matrix is reported as 12 comma-separated numbers, corresponding to a 3x3 rotation matrix and a translation vector in the fourth column. Ordering is row-by-row, such that the translation vector is given as the fourth, eighth, and twelfth numbers."
>>>
>>> When I load a model into ChimeraX and use "view matrix" command to check the model position, I got "#1,1,0,0,0,0,1,0,0,0,0,1,0,#1.1,1,0,0,0,0,1,0,0,0,0,1,0". The rotation matrix for #1 is an identity matrix with translation vector to be 0 for all directions.
>>>
>>> However, if I rotate the model using the command "turn z 90 models #1" and then check the model position using "view matrix", I got something like "#1,1.1102e-16,-1,0,689.33,1,1.1102e-16,0,-1.9358,0,0,1,0,#1.1,1,0,0,0,0,1,0,0,0,0,1,0". The translation vector for #1 becomes (689.33, -1.9358, 0).
>>>
>>> Since I only applied a simple rotation of the model along z-axis, why the translation vector becomes non-zero in this case? I hope to have a better understanding of how ChimeraX handles the model position matrix to describe model positions.
>>>
>>> Thank you so much!
>>> Best,
>>> Zheng
>>
>> _______________________________________________
>> ChimeraX-users mailing list
>> ChimeraX-users@cgl.ucsf.edu
>> Manage subscription:
>> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
>
>
> _______________________________________________
> ChimeraX-users mailing list
> ChimeraX-users@cgl.ucsf.edu
> Manage subscription:
> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
>