%% AMS-LaTeX Created by Wolfram Mathematica 8.0 : www.wolfram.com

\documentclass{article}
\usepackage{amsmath, amssymb, graphics, setspace}

\newcommand{\mathsym}[1]{{}}
\newcommand{\unicode}[1]{{}}

\newcounter{mathematicapage}
\begin{document}

Axis 1 is allong first dimension of detector (when not tilted), this is the slow dimension of the image array in C or Y

\begin{doublespace}
\noindent\(\pmb{\text{x1}=\{1,0,0\}}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\{1,0,0\}\)
\end{doublespace}

 Axis 2 is allong second dimension of detector (when not tilted), this is the fast dimension of the image in C or X

\begin{doublespace}
\noindent\(\pmb{\text{x2}=\{0,1,0\}}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\{0,1,0\}\)
\end{doublespace}

Axis 3 is along the incident X-Ray beam

\begin{doublespace}
\noindent\(\pmb{\text{x3}=\{0,0,1\}}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\{0,0,1\}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{id3}=\{\text{x1},\text{x2},\text{x3}\}}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\{\{1,0,0\},\{0,1,0\},\{0,0,1\}\}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\{\{1,0,0\},\{0,1,0\},\{0,0,1\}\}}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\{\{1,0,0\},\{0,1,0\},\{0,0,1\}\}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{rotM1}=\text{RotationMatrix}[\text{rot1},\text{x1}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\{\{1,0,0\},\{0,\text{Cos}[\text{rot1}],-\text{Sin}[\text{rot1}]\},\{0,\text{Sin}[\text{rot1}],\text{Cos}[\text{rot1}]\}\}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{rotM2} =\text{  }\text{RotationMatrix}[\text{rot2},\text{x2}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\{\{\text{Cos}[\text{rot2}],0,\text{Sin}[\text{rot2}]\},\{0,1,0\},\{-\text{Sin}[\text{rot2}],0,\text{Cos}[\text{rot2}]\}\}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{rotM3} =\text{  }\text{RotationMatrix}[\text{rot3},\text{x3}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\{\{\text{Cos}[\text{rot3}],-\text{Sin}[\text{rot3}],0\},\{\text{Sin}[\text{rot3}],\text{Cos}[\text{rot3}],0\},\{0,0,1\}\}\)
\end{doublespace}

Rotations of the detector are applied first Rot around axis 1, then axis 2 and finally around axis 3

\begin{doublespace}
\noindent\(\pmb{R=\text{rotM3}.\text{rotM2}.\text{rotM1}}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\{\{\text{Cos}[\text{rot2}] \text{Cos}[\text{rot3}],\text{Cos}[\text{rot3}] \text{Sin}[\text{rot1}] \text{Sin}[\text{rot2}]-\text{Cos}[\text{rot1}]
\text{Sin}[\text{rot3}],\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}] \text{Sin}[\text{rot2}]+\text{Sin}[\text{rot1}] \text{Sin}[\text{rot3}]\},\{\text{Cos}[\text{rot2}]
\text{Sin}[\text{rot3}],\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}]+\text{Sin}[\text{rot1}] \text{Sin}[\text{rot2}] \text{Sin}[\text{rot3}],-\text{Cos}[\text{rot3}]
\text{Sin}[\text{rot1}]+\text{Cos}[\text{rot1}] \text{Sin}[\text{rot2}] \text{Sin}[\text{rot3}]\},\{-\text{Sin}[\text{rot2}],\text{Cos}[\text{rot2}]
\text{Sin}[\text{rot1}],\text{Cos}[\text{rot1}] \text{Cos}[\text{rot2}]\}\}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{CForm}[R.\text{x1}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{List(Cos(rot2)*Cos(rot3),Cos(rot2)*Sin(rot3),-Sin(rot2))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{CForm}[R.\text{x2}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{List(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3),Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3),Cos(rot2)*Sin(rot1))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{CForm}[R.\text{x3}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{List(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3),-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3),Cos(rot1)*Cos(rot2))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{CForm}[\text{Det}[R]]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{Power(Cos(rot1),2)*Power(Cos(rot2),2)*Power(Cos(rot3),2) + Power(Cos(rot2),2)*Power(Cos(rot3),2)*Power(Sin(rot1),2) + Power(Cos(rot1),2)*Power(Cos(rot3),2)*Power(Sin(rot2),2)
+ 
   Power(Cos(rot3),2)*Power(Sin(rot1),2)*Power(Sin(rot2),2) + Power(Cos(rot1),2)*Power(Cos(rot2),2)*Power(Sin(rot3),2) + Power(Cos(rot2),2)*Power(Sin(rot1),2)*Power(Sin(rot3),2)
+ 
   Power(Cos(rot1),2)*Power(Sin(rot2),2)*Power(Sin(rot3),2) + Power(Sin(rot1),2)*Power(Sin(rot2),2)*Power(Sin(rot3),2)}\)
\end{doublespace}

Any pixel on detector plan at coordianate (d1, d2) in meters. Detector is at z=L

\begin{doublespace}
\noindent\(\pmb{\text{}}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{P=\{\text{d1},\text{d2},L\}}\\
\pmb{\text{CForm}[R.P]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\{\text{d1},\text{d2},L\}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{List(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
   d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),L*Cos(rot1)*Cos(rot2)
+ d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{t1} = R.P.\text{x1}}\\
\pmb{\text{CForm}[\text{t1}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{d1} \text{Cos}[\text{rot2}] \text{Cos}[\text{rot3}]+\text{d2} (\text{Cos}[\text{rot3}] \text{Sin}[\text{rot1}] \text{Sin}[\text{rot2}]-\text{Cos}[\text{rot1}]
\text{Sin}[\text{rot3}])+L (\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}] \text{Sin}[\text{rot2}]+\text{Sin}[\text{rot1}] \text{Sin}[\text{rot3}])\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{t2} = R.P.\text{x2}}\\
\pmb{\text{CForm}[\text{t2}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{d1} \text{Cos}[\text{rot2}] \text{Sin}[\text{rot3}]+L (-\text{Cos}[\text{rot3}] \text{Sin}[\text{rot1}]+\text{Cos}[\text{rot1}]
\text{Sin}[\text{rot2}] \text{Sin}[\text{rot3}])+\text{d2} (\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}]+\text{Sin}[\text{rot1}] \text{Sin}[\text{rot2}]
\text{Sin}[\text{rot3}])\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{t3}=R.P.\text{x3}}\\
\pmb{\text{CForm}[\text{t3}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(L \text{Cos}[\text{rot1}] \text{Cos}[\text{rot2}]+\text{d2} \text{Cos}[\text{rot2}] \text{Sin}[\text{rot1}]-\text{d1} \text{Sin}[\text{rot2}]\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2)}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{dist} = \text{Norm}[R.P]}\\
\pmb{\text{CForm}[\text{dist}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\surd \left(\text{Abs}[L \text{Cos}[\text{rot1}] \text{Cos}[\text{rot2}]+\text{d2} \text{Cos}[\text{rot2}] \text{Sin}[\text{rot1}]-\text{d1}
\text{Sin}[\text{rot2}]]^2+\text{Abs}[\text{d1} \text{Cos}[\text{rot2}] \text{Cos}[\text{rot3}]+\text{d2} (\text{Cos}[\text{rot3}] \text{Sin}[\text{rot1}]
\text{Sin}[\text{rot2}]-\text{Cos}[\text{rot1}] \text{Sin}[\text{rot3}])+L (\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}] \text{Sin}[\text{rot2}]+\text{Sin}[\text{rot1}]
\text{Sin}[\text{rot3}])]^2+\text{Abs}[\text{d1} \text{Cos}[\text{rot2}] \text{Sin}[\text{rot3}]+L (-\text{Cos}[\text{rot3}] \text{Sin}[\text{rot1}]+\text{Cos}[\text{rot1}]
\text{Sin}[\text{rot2}] \text{Sin}[\text{rot3}])+\text{d2} (\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}]+\text{Sin}[\text{rot1}] \text{Sin}[\text{rot2}]
\text{Sin}[\text{rot3}])]^2\right)\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{Sqrt(Power(Abs(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2)),2) + Power(Abs(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2)
- Cos(rot1)*Sin(rot3)) + 
       L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))),2) + Power(Abs(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))
+ d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3))),
     2))}\)
\end{doublespace}

cos(2theta) can be defined as (R.P component along x3) over the distance $|$R.P$|$

\begin{doublespace}
\noindent\(\pmb{\text{tthc} = \text{ArcCos} [-(R.P).\text{x3}/\text{Norm}[R.P]]}\\
\pmb{\text{CForm}[\text{tthc}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{ArcCos}\left[(-L \text{Cos}[\text{rot1}] \text{Cos}[\text{rot2}]-\text{d2} \text{Cos}[\text{rot2}] \text{Sin}[\text{rot1}]+\text{d1}
\text{Sin}[\text{rot2}])\left/\left(\surd \left(\text{Abs}[L \text{Cos}[\text{rot1}] \text{Cos}[\text{rot2}]+\text{d2} \text{Cos}[\text{rot2}] \text{Sin}[\text{rot1}]-\text{d1}
\text{Sin}[\text{rot2}]]^2+\text{Abs}[\text{d1} \text{Cos}[\text{rot2}] \text{Cos}[\text{rot3}]+\text{d2} (\text{Cos}[\text{rot3}] \text{Sin}[\text{rot1}]
\text{Sin}[\text{rot2}]-\text{Cos}[\text{rot1}] \text{Sin}[\text{rot3}])+L (\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}] \text{Sin}[\text{rot2}]+\text{Sin}[\text{rot1}]
\text{Sin}[\text{rot3}])]^2+\text{Abs}[\text{d1} \text{Cos}[\text{rot2}] \text{Sin}[\text{rot3}]+L (-\text{Cos}[\text{rot3}] \text{Sin}[\text{rot1}]+\text{Cos}[\text{rot1}]
\text{Sin}[\text{rot2}] \text{Sin}[\text{rot3}])+\text{d2} (\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}]+\text{Sin}[\text{rot1}] \text{Sin}[\text{rot2}]
\text{Sin}[\text{rot3}])]^2\right)\right)\right.\right]\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{ArcCos((-(L*Cos(rot1)*Cos(rot2)) - d2*Cos(rot2)*Sin(rot1) + d1*Sin(rot2))/
    Sqrt(Power(Abs(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2)),2) + Power(Abs(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2)
- Cos(rot1)*Sin(rot3)) + 
         L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))),2) + Power(Abs(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))
+ 
         d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3))),2)))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{}\\
\pmb{}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{ttht} = \text{ArcTan}[\text{t3},\text{Sqrt}[\text{t1}{}^{\wedge}2 + \text{t2}{}^{\wedge}2]]}\\
\pmb{\text{}}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{ArcTan}\left[L \text{Cos}[\text{rot1}] \text{Cos}[\text{rot2}]+\text{d2} \text{Cos}[\text{rot2}] \text{Sin}[\text{rot1}]-\text{d1}
\text{Sin}[\text{rot2}],\surd \left((\text{d1} \text{Cos}[\text{rot2}] \text{Cos}[\text{rot3}]+\text{d2} (\text{Cos}[\text{rot3}] \text{Sin}[\text{rot1}]
\text{Sin}[\text{rot2}]-\text{Cos}[\text{rot1}] \text{Sin}[\text{rot3}])+L (\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}] \text{Sin}[\text{rot2}]+\text{Sin}[\text{rot1}]
\text{Sin}[\text{rot3}]))^2+(\text{d1} \text{Cos}[\text{rot2}] \text{Sin}[\text{rot3}]+L (-\text{Cos}[\text{rot3}] \text{Sin}[\text{rot1}]+\text{Cos}[\text{rot1}]
\text{Sin}[\text{rot2}] \text{Sin}[\text{rot3}])+\text{d2} (\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}]+\text{Sin}[\text{rot1}] \text{Sin}[\text{rot2}]
\text{Sin}[\text{rot3}]))^2\right)\right]\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{ArcTan(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2)
- Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
      2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))}\)
\end{doublespace}

Tangeant of angle chi is defined as (R.P component along x1) over (R.P component along x2). Arctan2 should be used in actual calculation

\begin{doublespace}
\noindent\(\pmb{\text{chi} =\text{ArcTan}[\text{t1}\text{  }, \text{t2}]}\\
\pmb{\text{CForm}[\text{chi}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{ArcTan}[\text{d1} \text{Cos}[\text{rot2}] \text{Cos}[\text{rot3}]+\text{d2} (\text{Cos}[\text{rot3}] \text{Sin}[\text{rot1}] \text{Sin}[\text{rot2}]-\text{Cos}[\text{rot1}]
\text{Sin}[\text{rot3}])+L (\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}] \text{Sin}[\text{rot2}]+\text{Sin}[\text{rot1}] \text{Sin}[\text{rot3}]),\text{d1}
\text{Cos}[\text{rot2}] \text{Sin}[\text{rot3}]+L (-\text{Cos}[\text{rot3}] \text{Sin}[\text{rot1}]+\text{Cos}[\text{rot1}] \text{Sin}[\text{rot2}]
\text{Sin}[\text{rot3}])+\text{d2} (\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}]+\text{Sin}[\text{rot1}] \text{Sin}[\text{rot2}] \text{Sin}[\text{rot3}])]\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{ArcTan(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
   d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))}\)
\end{doublespace}

Coodinates of the Point of Normal Incidence

\begin{doublespace}
\noindent\(\pmb{\text{}}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{PONI} = R.\{0,0,L\}}\\
\pmb{\text{CForm}[\text{PONI}]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\{L (\text{Cos}[\text{rot1}] \text{Cos}[\text{rot3}] \text{Sin}[\text{rot2}]+\text{Sin}[\text{rot1}] \text{Sin}[\text{rot3}]),L (-\text{Cos}[\text{rot3}]
\text{Sin}[\text{rot1}]+\text{Cos}[\text{rot1}] \text{Sin}[\text{rot2}] \text{Sin}[\text{rot3}]),L \text{Cos}[\text{rot1}] \text{Cos}[\text{rot2}]\}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{List(L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)),L*Cos(rot1)*Cos(rot2))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{CForm}[D[\text{ttht},\text{d1}]]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{((L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))*(2*Cos(rot2)*Cos(rot3)*(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2)
- Cos(rot1)*Sin(rot3)) + 
           L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))) + 2*Cos(rot2)*Sin(rot3)*
         (d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))))/
    (2.*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2)
+ 
        Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))*
      (Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2)
- Cos(rot1)*Sin(rot3)) + 
          L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))
+ d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
     + (Sin(rot2)*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2)
+ Sin(rot1)*Sin(rot3)),2) + 
        Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))/
    (Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) -
Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
       2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{CForm}[D[\text{ttht},\text{d2}]]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{((L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))*(2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3))*
         (d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)))
+ 
        2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3))*(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))
+ d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))))/
    (2.*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2)
+ 
        Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))*
      (Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2)
- Cos(rot1)*Sin(rot3)) + 
          L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))
+ d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
     - (Cos(rot2)*Sin(rot1)*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2)
+ Sin(rot1)*Sin(rot3)),2) + 
        Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))/
    (Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) -
Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
       2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{CForm}[D[\text{ttht},L]]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{((L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))*(2*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3))*
         (d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)))
+ 
        2*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))*(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))
+ d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))))/
    (2.*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2)
+ 
        Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))*
      (Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2)
- Cos(rot1)*Sin(rot3)) + 
          L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))
+ d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
     - (Cos(rot1)*Cos(rot2)*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2)
+ Sin(rot1)*Sin(rot3)),2) + 
        Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))/
    (Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) -
Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
       2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{CForm}[D[\text{ttht},\text{rot1}]]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{((L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))*(2*(L*(-(Cos(rot3)*Sin(rot1)*Sin(rot2)) + Cos(rot1)*Sin(rot3))
+ d2*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)))*
         (d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)))
+ 
        2*(d2*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + L*(-(Cos(rot1)*Cos(rot3)) - Sin(rot1)*Sin(rot2)*Sin(rot3)))*
         (d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))))/
    (2.*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2)
+ 
        Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))*
      (Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2)
- Cos(rot1)*Sin(rot3)) + 
          L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))
+ d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
     - ((d2*Cos(rot1)*Cos(rot2) - L*Cos(rot2)*Sin(rot1))*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3))
+ L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + 
        Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))/
    (Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) -
Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),
       2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{CForm}[D[\text{ttht},\text{rot2}]]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{((L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))*(2*(L*Cos(rot1)*Cos(rot2)*Cos(rot3) + d2*Cos(rot2)*Cos(rot3)*Sin(rot1)
- d1*Cos(rot3)*Sin(rot2))*
         (d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)))
+ 
        2*(L*Cos(rot1)*Cos(rot2)*Sin(rot3) + d2*Cos(rot2)*Sin(rot1)*Sin(rot3) - d1*Sin(rot2)*Sin(rot3))*
         (d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))))/
    (2.*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2)
+ 
        Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))*
      (Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2)
- Cos(rot1)*Sin(rot3)) + 
          L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))
+ d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
     - ((-(d1*Cos(rot2)) - L*Cos(rot1)*Sin(rot2) - d2*Sin(rot1)*Sin(rot2))*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2)
- Cos(rot1)*Sin(rot3)) + 
          L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))
+ d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))
     /(Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2)
- Cos(rot1)*Sin(rot3)) + 
        L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))
+ d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\pmb{\text{CForm}[D[\text{ttht},\text{rot3}]]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(\text{((L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2))*(2*(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2)
- Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)))*
        (-(d1*Cos(rot2)*Sin(rot3)) + L*(Cos(rot3)*Sin(rot1) - Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(-(Cos(rot1)*Cos(rot3)) - Sin(rot1)*Sin(rot2)*Sin(rot3)))
+ 
       2*(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)))*
        (d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)))))/
   (2.*Sqrt(Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) - Cos(rot1)*Sin(rot3)) + L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2)
+ 
       Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3)) + d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2))*
     (Power(L*Cos(rot1)*Cos(rot2) + d2*Cos(rot2)*Sin(rot1) - d1*Sin(rot2),2) + Power(d1*Cos(rot2)*Cos(rot3) + d2*(Cos(rot3)*Sin(rot1)*Sin(rot2) -
Cos(rot1)*Sin(rot3)) + 
         L*(Cos(rot1)*Cos(rot3)*Sin(rot2) + Sin(rot1)*Sin(rot3)),2) + Power(d1*Cos(rot2)*Sin(rot3) + L*(-(Cos(rot3)*Sin(rot1)) + Cos(rot1)*Sin(rot2)*Sin(rot3))
+ d2*(Cos(rot1)*Cos(rot3) + Sin(rot1)*Sin(rot2)*Sin(rot3)),2)))}\)
\end{doublespace}

\end{document}
