ECE532 Biomedical Optics © 1998 Steven L. Jacques, Scott A. Prahl Oregon Graduate Institute |
The first step is to launch a photon. In this example implementation, the photons are launched as an isotropic point source in 3 dimensions bookkeeped using Cartesian coordinates.
/**** LAUNCH * Initialize photon position and trajectory. * Implements an isotropic point source. *****/ i_photon += 1; /* increment photon count */ photon_status = ALIVE; /* Launch an ALIVE photon */ L = 0; /* set photon's accumulated pathlength to zero */ it = 0; /* set pointer to timepoint T[1] */ x = 0; /* Set photon position to origin. */ y = 0; z = 0; /* Randomly set photon trajectory to yield an isotropic source. */ costheta = 2.0*RandomNum - 1.0; sintheta = sqrt(1.0 - costheta*costheta); /* sintheta is always positive */ psi = 2.0*PI*RandomNum; ux = sintheta*cos(psi); uy = sintheta*sin(psi); uz = costheta;