User:Karsten Theis/Rigid body interpolation

From Proteopedia

(Difference between revisions)
Jump to: navigation, search
Line 55: Line 55:
define sel1 1.1 and (1125-1162) and *:A
define sel1 1.1 and (1125-1162) and *:A
define sel2 1.2 and (1125-1162) and *:A
define sel2 1.2 and (1125-1162) and *:A
-
define anch1 1.1 and 1125:A.CA
+
define anch1 1.1 and 1124:A.CA
-
define anch2 1.2 and 1125:A.CA
+
define anch2 1.2 and 1124:A.CA
rigid(progress)
rigid(progress)
linear(progress)
linear(progress)
define sel1 1.1 and (1125-1162) and *:B
define sel1 1.1 and (1125-1162) and *:B
define sel2 1.2 and (1125-1162) and *:B
define sel2 1.2 and (1125-1162) and *:B
-
define anch1 1.1 and 1125:B.CA
+
define anch1 1.1 and 1124:B.CA
-
define anch2 1.2 and 1125:B.CA
+
define anch2 1.2 and 1124:B.CA
rigid(progress)
rigid(progress)
linear(progress)
linear(progress)
define sel1 1.1 and (1125-1162) and *:C
define sel1 1.1 and (1125-1162) and *:C
define sel2 1.2 and (1125-1162) and *:C
define sel2 1.2 and (1125-1162) and *:C
-
define anch1 1.1 and 1125:C.CA
+
define anch1 1.1 and 1124:C.CA
-
define anch2 1.2 and 1125:C.CA
+
define anch2 1.2 and 1124:C.CA
rigid(progress)
rigid(progress)
linear(progress)
linear(progress)

Revision as of 18:49, 6 March 2021

This page shows a way to superpose two rigid bodies so that they both have the same rotation, and they are translated such that a common anchor (center of mass, given atom) is in the same location.

The entire coordinates are copies first so that you can play around with the parameters and then reset the coordinates. The starting point is a structure with two models containing the same atoms in the same order, but with different coordinates.

function linear(progress) {
  coord1 = {sel1}.xyz.all
  coord2 = {sel2}.xyz.all
  len = coord1.length
  ssergorp = 1 - progress
  for (var i FROM [1,len]) {coord1[i] = (coord2[i] * progress + coord1[i] * ssergorp)}
  {sel1}.xyz = @coord1
}

function rigid(progress) {
  fourbyfour = compare({sel1}, {sel2})
  total_quat = quaternion(@fourbyfour%1)
  ssergorp = 1 - progress
  quat1 = total_quat * progress
  quat2 = total_quat * ssergorp * -1
  anchorpos = {anch2}.xyz * progress + {anch1}.xyz * ssergorp
  select sel1
  rotateselected @quat1 molecular
  transl1 = anchorpos - {anch1}.xyz
  translateselected @transl1
  select sel2
  rotateselected @quat2 molecular
  transl2 = anchorpos - {anch2}.xyz
  translateselected @transl2
}


original = {all}.xyz.all
for (var i FROM [1,20]) {
  {all}.xyz = @original
  progress = 0.05 * i
  define sel1 1.1 and (912-984) and *:A
  define sel2 1.2 and (912-984) and *:A
  define anch1 1.1 and 984:A.CA
  define anch2 1.2 and 984:A.CA
  rigid(progress)
  linear(progress)
  define sel1 1.1 and (912-984) and *:B
  define sel2 1.2 and (912-984) and *:B
  define anch1 1.1 and 984:B.CA
  define anch2 1.2 and 984:B.CA
  rigid(progress)
  linear(progress)
  define sel1 1.1 and (912-984) and *:C
  define sel2 1.2 and (912-984) and *:C
  define anch1 1.1 and 984:C.CA
  define anch2 1.2 and 984:C.CA
  rigid(progress)
  linear(progress)
  define sel1 1.1 and (1125-1162) and *:A
  define sel2 1.2 and (1125-1162) and *:A
  define anch1 1.1 and 1124:A.CA
  define anch2 1.2 and 1124:A.CA
  rigid(progress)
  linear(progress)
  define sel1 1.1 and (1125-1162) and *:B
  define sel2 1.2 and (1125-1162) and *:B
  define anch1 1.1 and 1124:B.CA
  define anch2 1.2 and 1124:B.CA
  rigid(progress)
  linear(progress)
  define sel1 1.1 and (1125-1162) and *:C
  define sel2 1.2 and (1125-1162) and *:C
  define anch1 1.1 and 1124:C.CA
  define anch2 1.2 and 1124:C.CA
  rigid(progress)
  linear(progress)
  delay 1.0
}

  

Drag the structure with the mouse to rotate

Proteopedia Page Contributors and Editors (what is this?)

Karsten Theis

Personal tools