## Appendix D

The translations and rotations produced by the affine transformation do not correspond to those used on a treatment machine. The treatment and simulator machines use a frame of reference in which the operations of rotation and translation commute (i.e. it does not matter in which order they are carried out). Additionally the centre of rotation for the treatment and simulator machines is the isocentre. A method is required to convert the affine transformation into the coordinate system used by the treatment machines.

Take two images, image one being the simulator image and image two the portal image, and a transformation (r,q,xt,yt) that maps pixels in the version of image two registered with image one, onto corresponding pixels in image two (i.e. the transformation passed to POLY_2D). If (xc,yc) is the position of the centre of rotation (assumed to be the same in both images), and image two has an initial magnification m and the pixel size of both images is p (assumed to be square), then the position of the centre of rotation before the transformation was applied (xa,ya) is given by

 xa = xc r cosq+yc r sinq-xtcosq -ytsinq cos2q-sin2 q ya = yc r cosq-xc r sinq-ytcosq +xtsinq cos2q-sin2 q

The distance between the two points (xc,yc) and (xa,ya) using Pythagoras' theorem is

 h = _________________ Ö (xa-xc)2+ (ya-yc)2

and the angle is given by

 tan f = ya-yc xa-xc

The longitudinal movement of the table (i.e. along its length) is given by

 pm × h cos ćçč p2 -q-f ö÷ř

and the lateral movement of the table is given by

 pm × h sin ćçč p2 -q-f ö÷ř

These movements will have the same units as the pixel size p. The rotation is the same in both systems, and knowing the table height and magnification of image one, working out the vertical table movement is trivial.