NewsEtc |
Dec., 1998 |
The programming that launches and propagates each photon through the tissue is enclosed within a DO-WHILE LOOP which launches N photons (N = Nphotons).
/**** RUN
Launch N photons, initializing each one before progation.
*****/
do {
/* PROGRAM SITS WITHIN THIS DO-WHILE LOOP THAT LAUNCHES N PHOTONS */
/* If photon dead, then launch new photon. */
} /* end RUN */
while (i_photon < Nphotons);
On each launch of a new photon the following is done. The photon counter (i_photon) is incremented. The photon weight (W) is set to value 1. The photon status (photon_status) is set to "ALIVE". Later when the program determines the photon should be terminated, the photon_status will be set to "DEAD".
Each "photon" is launched at a position (x, y, z) which is set to the origin (0, 0, 0). The initial trajectory of the photons is described by the projection of the trajectory onto the x, y, and z coordinates. For an isotropic point source the initial trajectory is randomly set to a value between -1 and 1 (corresponding to 180° - 0° with respect to a given axis). The length of the trajectory vector (ux, uy, uz) is determined and assigned to a dummy variable u which is then used to normalize ux, uy, and uz. Consequently, the normalized trajectory vector has a unit length:
/**** LAUNCH Initialize photon position and trajectory. Implements an isotropic point source. *****/ i_photon += 1; /* increment photon count */ W = 1.0; /* set photon weight to one */ photon_status = ALIVE; /* Launch an ALIVE photon */ x = 0; /* Set photon position to origin. */ y = 0; z = 0; ux = 1.0 - 2.0*RandomNum; /* Randomly set photon trajectory*/ uy = 1.0 - 2.0*RandomNum; /* to yield an isotropic source. */ uz = 1.0 - 2.0*RandomNum; u = sqrt(ux*ux + uy*uy + uz*uz); /* dummy variable assigned vector length */ ux = ux/u; /* Normalize so vector has unit length */ uy = uy/u; uz = uz/u;