\begin{Verbatim}[commandchars=\\\{\}]
\PYG{g+go}{\PYGZsh{} get atom coordinates as vectors}
\PYG{g+gp}{\PYGZgt{}\PYGZgt{}\PYGZgt{} }\PYG{n}{n} \PYG{o}{=} \PYG{n}{residue}\PYG{p}{[}\PYG{l+s+s2}{\PYGZdq{}N\PYGZdq{}}\PYG{p}{]}\PYG{o}{.}\PYG{n}{get\PYGZus{}vector}\PYG{p}{()}
\PYG{g+gp}{\PYGZgt{}\PYGZgt{}\PYGZgt{} }\PYG{n}{c} \PYG{o}{=} \PYG{n}{residue}\PYG{p}{[}\PYG{l+s+s2}{\PYGZdq{}C\PYGZdq{}}\PYG{p}{]}\PYG{o}{.}\PYG{n}{get\PYGZus{}vector}\PYG{p}{()}
\PYG{g+gp}{\PYGZgt{}\PYGZgt{}\PYGZgt{} }\PYG{n}{ca} \PYG{o}{=} \PYG{n}{residue}\PYG{p}{[}\PYG{l+s+s2}{\PYGZdq{}CA\PYGZdq{}}\PYG{p}{]}\PYG{o}{.}\PYG{n}{get\PYGZus{}vector}\PYG{p}{()}
\PYG{g+go}{\PYGZsh{} center at origin}
\PYG{g+gp}{\PYGZgt{}\PYGZgt{}\PYGZgt{} }\PYG{n}{n} \PYG{o}{=} \PYG{n}{n} \PYG{o}{\PYGZhy{}} \PYG{n}{ca}
\PYG{g+gp}{\PYGZgt{}\PYGZgt{}\PYGZgt{} }\PYG{n}{c} \PYG{o}{=} \PYG{n}{c} \PYG{o}{\PYGZhy{}} \PYG{n}{ca}
\PYG{g+go}{\PYGZsh{} find rotation matrix that rotates n}
\PYG{g+go}{\PYGZsh{} \PYGZhy{}120 degrees along the ca\PYGZhy{}c vector}
\PYG{g+gp}{\PYGZgt{}\PYGZgt{}\PYGZgt{} }\PYG{n}{rot} \PYG{o}{=} \PYG{n}{rotaxis}\PYG{p}{(}\PYG{o}{\PYGZhy{}}\PYG{n}{pi} \PYG{o}{*} \PYG{l+m+mf}{120.0}\PYG{o}{/}\PYG{l+m+mf}{180.0}\PYG{p}{,} \PYG{n}{c}\PYG{p}{)}
\PYG{g+go}{\PYGZsh{} apply rotation to ca\PYGZhy{}n vector}
\PYG{g+gp}{\PYGZgt{}\PYGZgt{}\PYGZgt{} }\PYG{n}{cb\PYGZus{}at\PYGZus{}origin} \PYG{o}{=} \PYG{n}{n}\PYG{o}{.}\PYG{n}{left\PYGZus{}multiply}\PYG{p}{(}\PYG{n}{rot}\PYG{p}{)}
\PYG{g+go}{\PYGZsh{} put on top of ca atom}
\PYG{g+gp}{\PYGZgt{}\PYGZgt{}\PYGZgt{} }\PYG{n}{cb} \PYG{o}{=} \PYG{n}{cb\PYGZus{}at\PYGZus{}origin}\PYG{o}{+}\PYG{n}{ca}
\end{Verbatim}
