## RNA Center Software

### Math and matrices

The molecular region of interest for the reference structure is held fixed.
The comparison molecular region is aligned to the reference.
The 4x4 matrix of this transformation matrix is obtained from pyMOL.
The matrix is a combination of a rotation and translation.
Eulers rotation theorem states that any rotation can be expressed as a single rotation about some axis.
An axis and rotation angle is obtained such that the motion is equivalent to one rotation.
Xa is original coordinates, Xb is coordinates in aligned to the reference structure.
Let R be the rotation matrix , T is the translation, O can be thought of as an origin shift.
Xb = R Xa + T
Xb + O = R (Xa + O)
R Xa + T = R (Xa + O) - O
R Xa + T = R Xa + R O - O
T = R O - O
T = (R - I) O
O = inv(R-I) T
Technically a pseudo-inverse is used which is equivalent to a 'best fit' (least squares) solution

The angle of rotation is derived from the Euler-Rodrigues formula.
theta = acos((R[0][0] + R[1][1] + R[2][2] -1)/2)
The direction of the axis is similarly calculated.
e0 = (R[2][1] - R[1][2]) / (2*sin(theta))
e1 = (R[0][2] - R[2][0]) / (2*sin(theta))
e2 = (R[1][0] - R[0][1]) / (2*sin(theta))

The axis can now be placed in the e direction passing through the point O.

```