Three Monte Carlo programs of polarized light transport into scattering media : part I

Propagation of light into scattering media is a complex problem that can be modeled using statistical methods such as Monte Carlo. Few Monte Carlo programs have so far included the information regarding the status of polarization of the photon before and after every scattering event. Different approaches have been followed and limited numerical values have been made available to the general public. In this paper, three different ways to build a Monte Carlo program for light propagation with polarization are given. Different groups have used the first two methods; the third method is original. Comparison in between Monte Carlo runs and Adding Doubling program yielded less than 1 % error. ©2005 Optical Society of America OCIScodes : (290.4020) Mie theory (290.4210) Multiple scattering References and Links 1. S. Chandrasekhar, Radiative Transfer, Oxford Clarendon Press; (1950). 2. S. Chandrasekhar and D. Elbert, “The Illumination and polarization of the sunlight sky on Rayleigh scattering,” Trans. Am. Phil. Soc., 44, 6, 1956. 3. K. F. Evans and G. L. Stephens, “A new polarized atmospheric radiative transfer model,” J. Quant. Spectrosc. Radiat Transfer., 46, 5:413-423, 1991. 4. S. A. Prahl, M. J. C. van Gemert, A. J. Welch, “Determining the optical properties of turbid media by using the adding-doubling method,” Applied Optics, 32:559-568, 1993. 5. G. W. Kattawar and G. N. Plass “Radiance and polarization of multiple scattered light from haze and clouds,” Applied Optics, 7, 8:1519-1527, 1967. 6. G. W. Kattawar and G. N. Plass, “Degree and direction of polarization of multiple scattered light. 1: Homogeneous cloud layers,” Applied Optics, 11, 12:2851-2865, 1972. 7. G. W. Kattawar and C. N. Adams “Stokes vector calculations of the submarine light field in an atmosphereocean with scattering according to a Rayleigh phase matrix: effect of interface refractive index on radiance and polarization,” Limnol. Oceanogr., 34, 8:1453-1472, 1989. 8. P. Bruscaglione, G. Zaccanti, W. Qingnong “Transmission of a pulsed polarized light beam through thick turbid media: numerical results,” Applied Optics, 32, 30:6142-6150, 1993. 9. S. Bianchi, A. Ferrara, C. Giovannardi, “Monte Carlo simulations of dusty spiral galaxies: extinction and polarization properties,” American Astronomical Society, 465,1:137-144,1996. 10. S. Bianchi Estinzione e polarizzazione della radiazione nelle galassie a spirale, Tesi di Laura (in Italian), 1994. 11. A. Ambirajan and D.C. Look, “A backward Monte Carlo study of the multiple scattering of a polarized laser beam,” J. Quant. Spectrosc. Radiat. Transfer, 58, 2:171-192; 1997. 12. A. S. Martinez and R. Maynard “Polarization Statistics in Multiple Scattering of light: a Monte Carlo approach,” in Localization and Propagation of classical waves in random and periodic structures Plenum Publishing Corporation New York, 1993. 13. A. S. Martinez Statistique de polarization et effet Faraday en diffusion multiple de la lumiere Ph.D. Thesis (in French and English), 1984. 14. S. Bartel and A. Hielsher, “Monte Carlo simulations of the diffuse backscattering Mueller matrix for highly scattering media,” Applied Optics, 39, 10:1580:1588, 2000. 15. B. D. Cameron, M. J. Rakovic, M. Mehrubeoglu, G. Kattawar, S. Rastegar, L.-H. Wang, G. L. Cote, “Measurement and calculation of the two-dimensional backscattering Mueller matrix of a turbid medium,” Optics Letters, 23: 485-487, 1998. 16. M. J. Rakovic, G. W. Kattawar, M. Mehrubeoglu, B. D. Cameron, L.-H. Wang, S. Rastegar, G. L. Cote, “Light backscattering polarization patterns from turbid media: theory and experiment,” Applied Optics, 38:3399-3408, 1999.


Introduction
Over the last fifty years polarized light travel through scattering media has been studied by many groups and by the atmospheric optics and oceanography community in particular.An exact solution of the radiative transfer for a plane-parallel atmosphere with Rayleigh scattering was derived by Chandrasekhar in 1950 [1,2].More complicated geometries proved too complex to be solved analytically.Adding-doubling methods were developed to handle the same kind of geometry for inhomogeneous atmosphere containing randomly oriented particles [3,4].Kattawar and Plass [5] were the first to calculate the status of polarization of the light after multiple scattering using a Monte Carlo method.They later defined the degree of polarization for homogeneous layers for different solar zenith angles and optical thickness for haze and clouds [6].Since then many papers have been published on Monte Carlo models and their applications.Kattawar and Adams used a Monte Carlo program to calculate the Stokes vector at any location in a fully inhomogeneous atmosphere-ocean system [7].Other groups used Monte Carlo codes to analyze changes in polarization of light pulses transmitted through turbid media [8].Monte Carlo programs were used to measure the polarization properties of dusty spiral galaxies by Bianchi et al. [9,10]; a detailed description of their Monte Carlo program was included.Ambirajan and Look [11] developed a backward Monte Carlo model for slab geometry with circularly polarized incident light.Martinez and Maynard [12] wrote a Monte Carlo program for the plane slab geometry and used it to study the Faraday-effect in an optically active medium [13].
Bartel and Hielsher [14] proposed a Monte Carlo model that differs from previous programs; their program used a local coordinate system to keep track of the polarization reference frame.The coordinate system is rotated with standard rotational matrices.They calculated the diffusely back-scattered Mueller Matrix for suspension of polystyrene spheres and their numerical simulations where compared with experimental results.Cameron et al. showed similar images both experimentally and numerically [15].Cote' et al. [16] developed a three dimensional Monte Carlo to study optically active molecules in turbid media and Wang et al. [17] used Monte Carlo simulations to simulate light propagation in birefringent media.
Several authors have focused on improving the efficiency of polarized light transport simulations.Rakovic et al. [18] proposed a numerical method to simultaneously calculate all 16 elements of the two-dimensional Mueller matrix, and compared it favorably with their Monte Carlo program.Tynes et al. [19] used an effective Mueller matrix to predict the total reflectance and transmission through layered media.Kaplan et al. [20] measured experimentally the Mueller matrix backscattered from mono-disperse solutions of microspheres at different concentrations and scattering angles, and developed a Monte Carlo program whose speed was optimized by using the next-event point-estimator method [21].Min Xu [22] proposed a Monte Carlo implementation that traced the electric field through a multiply scattering media in lieu of a Stokes vector; this program is unique in its ability to simulate coherent phenomenon such as speckle.
Of all the Monte Carlo programs mentioned above only Min Xu and Cote's programs were released to the general public.
In this paper we want to illustrate three different way of implementing Monte Carlo programs that track the status of polarization of scattered light as it propagates in solutions of Mie and Rayleigh scatterers; these codes are released under the GNU public license and are available for download [23].
The first Monte Carlo program follows the algorithm of Chandrasekhar and Kattawar and will be called "meridian plane MC" since the photon's polarization reference plane is always relative to the meridian plane.The second Monte Carlo program uses the algorithm described by Bartel et al. and will be called "Euler MC" because it relies on Euler angles used in spherical rotation problems.The third Monte Carlo program propagates a local coordinate system that is used to define the polarization state.Quaternions are used to propagate the coordinate system, hence this Monte Carlo will be termed "quaternion MC".

Standard Monte Carlo program
Monte Carlo programs are based on a technique proposed first by Metropolis and Ulam [24].The main idea is the use of a stochastic approach to model a physical phenomenon.In the biomedical field, Monte Carlo programs have been used to model laser tissue interactions, fluorescence and many other phenomena [25,26].In Standard Monte Carlo the user is interested only in the distribution of absorbed, transmitter or reflected photons; in the polarized Monte Carlo other parameters must be tracked.A flow-chart that includes both Standard and Polarized Monte Carlo main steps is shown in Fig. 1.The gray boxes are necessary only in the Polarized Monte Carlo; all other steps must be included in both approaches.
A substantial difference between the polarized and standard Monte Carlo is the choice of the azimuthal and scattering angles.In the standard Monte Carlo the scattering angle α is chosen from a phase function, the most commonly used one is the Henyey-Greenstein phase function.Generally an azimuthal angle ψ is chosen uniformly between 0 and 2π .In the polarized Monte Carlo the scattering angle and the azimuth angle are chosen by a "rejection method" (STEP C) that will be discussed in section 9.An important feature of all polarization codes is tracking the reference plane used to describe the light polarization.Since the status of polarization of a field is defined with respect to a reference plane, the reference plane must be defined (STEP A) and updated for each scattering event (STEP D).The different ways of tracking the reference plane account for the three different Monte Carlo programs described and are presented in detail in the next sections.

Method 1-Meridian Planes Monte Carlo
Chandrasekhar was the first to envision the scattering of a photon from one location to the next in the form of meridian and scattering planes [1]. Figure 2 shows the geometry of the problem.The photon directions, before and after scattering, are represented as points A and B respectively on the unit sphere.Each photon direction is uniquely described by two angles θ and φ.The first angle, θ, is the angle between the initial photon direction and the Z-axis.The angle φ is the angle between the meridian plane and the X-Z plane.The photon direction is also specified by a unit vector I 1 whose elements are specified by the direction cosines [u x , u y , u z ] [27].The directions before and after scattering are called respectively I 1 and I 2. The unit vector I 1 and the Z-axis determine a plane COA.The COA plane is the meridian plane.The incident field can be decomposed into two orthogonal components E || and E ⊥ , that describe the vibration of the electrical field parallel and perpendicular to the meridian plane.The polarization relative to the new meridian plane is described by the Stokes vector S. When a scattering event occurs a new meridian plane is created by the new direction of propagation I 2 and the Z-axis, the Stokes vector must be transformed so that the polarization is properly represented with respect to the new meridian plane.Two rotations of the Stokes vector, in and out of the scattering plane, are required by this method.

Method 2 -Euler Monte Carlo
The second method was developed by Bartel and Hielsher [14] and is based on the following idea: the polarization reference frame is tracked via a triplet of unit vectors that are rotated by an azimuth and scattering angle at each scattering step.The unit vectors are rotated using Euler angles by general transformation matrices [28].In our implementation only two vectors are rotated for every scattering event v and u; the third unit vector is implicitly defined by the cross product of v and u and is calculated only when a photon reaches a boundary.The advantages of this method is that the Stokes vector is rotated only once for each scattering event instead of twice as in the meridian plane method.An added advantage is that the propagation of the unit vectors is straightforward and was easier to implement.

Method 3 -Quaternion Monte Carlo
The last method is based on quaternion algebra.Quaternions were used in a quantum diffusion Monte Carlo by Benoit and Clary [29] to perform calculations on molecular clusters.Richartz and Hsu [30] used quaternions to calculate the rotations and retardations of a polarized beam going through optical devices.We used quaternion algebra to track the polarization reference plane.Quaternions offer an elegant and intuitive way of handling rigid body rotations [31].A quaternion is a 4-tuple of real numbers, and it is an element of R 4 .
( ) , , , o q q q q = q (1) A quaternion can also be defined as the sum of a scalar part q 0 and a vector part Γ of the form: An angle θ can be associated with a quaternion, and q can be written as cos sin Where u = q /sin θ is a unit vector, and | q 0 | 2 = cos θ.This construction facilitate the use of quaternions as rotational operators.
Considering a vector T in R 3 , T = it 1 +jt 2 +kt 3 the quaternion operator L(T) can be interpreted either as a rotation of an angle 2θ of the coordinate frame with respect to T about Γ, or an opposite rotation of the vector T with respect to a coordinate frame about the axis Γ [31].q* is the complex conjugate of the quaternion q 0 0 1 2 3 q q q -q -q * = − = − q i j k

Γ
The quaternion q in R 4 can operate on the vector T in R 3 because the latter can be represented as a quaternion T= t 0 + t with null scalar element t 0 .In the Monte Carlo program the rotation of the reference plane about a fixed vector is achieved with the operator L(T) where the product of quaternions q and T has the form q t q t q t q t q t q t q t q t q t q t q t q t q t q t q t q t The product of two quaternions is also a quaternion.Quaternions are associative so the q*Tq operation can be executed with two simple multiplications.

Polarized light Monte Carlo
We explain a Monte Carlo program in detail following the steps of the flowchart in Fig. 1.
The steps for all three different methods will be described in parallel.

Launch
The first step in every Monte Carlo program is to launch one of several million photons in a media.Depending on the geometry of the beam (Gaussian or pencil beam are typical beam shapes) and the incident angle, different launching positions and photon directions cosines must be considered.When the polarization of the field is included some additional steps must be taken.The reference frame of the field must be defined and the Stokes vector describing the incident field polarization must be declared.For illumination perpendicular to the X-Y plane, the initial photon direction is defined by the following direction cosines [u x, u y , u z ] = [0, 0, 1].

Launch -Meridian Planes Monte Carlo
The polarization of the field is relative to the meridian plane.
Figure 1, STEP A: The meridian plane begins with φ=0, and the reference frame is initially equal to the x-z plane.The initial Stokes vector is relative to this meridian plane.Figure 1, STEP B: The status of polarization at launch is defined by the Stokes vector S = [I Q U V] specified relative to the X-Z plane.For example, if the user selects a Stokes vector S=[1 1 0 0] the launched photon will be linearly polarized parallel to the X-Z plane.

Launch-Euler Monte Carlo and Quaternion Monte Carlo
For both the Euler Monte Carlo and the Quaternion Monte Carlo we may select the initial reference frame.

Move
The move step in polarized light Monte Carlo programs is executed as in a standard Monte Carlo program.The photon is moved a propagation distance Δs that is calculated based on pseudo random number ζ generated in the interval (0,1]. where µ t = µ a + µ s , µ a is the absorption coefficient, and µ s is the scattering coefficient of the media.The mean free path between every scattering and absorption event is 1/µ t .The trajectory of the photon is characterized by the direction cosines [u x, u y , u z ].Following Witt [27]  ( 5 )

Drop
As in standard Monte Carlo code the absorption of light by a dye or an absorbing material present in the scattering media is tracked by giving a weight W to a photon and updating this weight after every absorption step according to the media albedo.
The albedo is the fractional probability of being scattered, 1-albedo is the fractional probability of being absorbed.The weight of the photon is initially equal to 1.The photon propagates through an absorbing media; after n steps the weight of the photon is equal to (albedo) n .In our Monte Carlo programs we use matched boundaries so we do not consider weight reduction due to the Fresnel interfaces as in standard Monte Carlo.When the weight of the photon reaches a threshold level the photon is terminated and is considered completely absorbed.If the photon exits the media with a certain weight W the corresponding Stokes vector is multiplied by W to keep in to account the photon attenuation.

Rejection Method
A fundamental problem in every Monte Carlo program with polarization information is the choice of the angles α (angle of scattering) and β (angle of rotation into the scattering plane), Fig. 2.These angles are selected based on the phase function of the considered scatterers and a rejection method.A detailed description of how to implement a rejection method can be found in [18].The phase function P(α,β) for incident light with a Stokes vector The parameters s 11 (α) and s 12 (α) are two elements of the scattering matrix M(α) The scattering matrix M(α) determines the polarization properties of the scattering element; we considered spheres.The matrix M(α) is symmetrical in the spherical case.The terms s 11 (α), s 12 (α), s 34 (α), and s 33 (α) are related to the scattered amplitudes S 1 and S 2 [32].
We omitted the angular α dependence.S 1 and S 2 depend from the size parameter x, the complex index of refraction of the particle n particle , the Riccati-Bessel functions, the spherical Bessel functions, and the spherical Henkel functions; a more in depth explanation of these parameters can be found in reference [32].In our Monte Carlo programs S 1 and S 2 for every scattering angle are obtained from a Mie scattering program [ 32,33].
Hopcraft et al. [34] graphically showed how the phase function depends on both α and β for linearly polarized light.They pointed out that the phase function is not axissymmetric for linearly polarized light.Figure 1, STEP C: The rejection method [35] may be used to generate random variables with a particular distribution.For functions of a single variable, two random numbers are generated.First, P rand is a uniform random deviate between 0 and 1. Second α rand is generated uniformly between 0 and π.The angle α rand is accepted as the new scattering angle if P rand ≤ P(α rand ).If P rand >P(α rand ) α rand and P rand are re-generated and the test is repeated.
When an angle α rand is accepted a similar process is implemented to calculate a new angle β rand .For a bivariate distribution like Eq. ( 7), three random numbers are generated α rand , P rand , and β rand .The angle β is uniformly distributed between 0 and 2π.If P rand ≤ P(α rand , β rand ) then both α rand , ψ rand are accepted as the new angles.

Scatter
Figure 1 STEP D. The scattering step is significantly different in each of the three programs, but it always includes at least one rotation of the Stokes vector reference plane and one multiplication to the scattering matrix M(α).

Scatter -Meridian Planes Monte Carlo
Three operations are necessary to scatter a photon and track the polarization; these operations are graphically described in the Fig. 4, 5, 6, and 7.The E field is originally defined with respect to a meridian plane COA.The field (visible in all Fig. as blue lines) can be decomposed into its parallel and perpendicular components E || and E ⊥ .Once the scattering angle α and azimuth angle β have been generated with the rejection method (section 9) the Stokes vector is manipulated three times, the three manipulation will be described in the next three paragraphs.

Rotation of the reference frame into the scattering plane
First the Stokes vector is rotated so that its reference plane is BOA, Fig. 5; this is the scattering plane.This rotation is necessary because the scattering matrix, that defines the elastic interaction of a photon with a sphere, is specified with respect to the frame of reference of the scattering plane.The new Stokes vector S 1 defined relative to the scattering plane (BOA) is found by multiplying by a rotational matrix R(β), ( ) ( ) ( ) ( ) This action corresponds to a counterclockwise rotation by an angle β about the direction of propagation.
Fig. 5.For a scattering event to occur the Stokes must be referenced with respect to the scattering plane BOA.The electrical field E (blue lines) is rotated so that E || is parallel to BOA.

Scattering of the photon at an angle α in the scattering plane
The Stokes vector at this point is referred to the scattering plane ACB.We can then use the scattering matrix, or Mueller matrix M(α) of Eq. ( 9), that is also related to this plane.The scattering matrix M(α) determines the polarization properties of the scattering sphere.The status of polarization of the field after a scattering event at an angle α and the relative Stokes vector can be obtained by the multiplication of the incident Stokes vector S to the scattering matrix M(α), Fig. 6. α is the scattering angle between the direction of the photon before and after scattering.The angle α depends on the phase function, and is obtained using the rejection method of section 9.

Return the reference frame to a new meridian plane
The Stokes vector is multiplied by the rotational matrix R(-γ) so that it is referenced to the meridian plane COB (Fig. 7).The angle γ was calculated by Hovenier [36], ( )( ) where α is the scattering angle and the plus sign is taken when π <β <2π and the minus sign is taken when 0 <β <π.In summary the Stokes vector S new after scattering is obtained from the Stokes vectors before the scattering event S using the following matrix multiplication:

Scatter -Euler Monte Carlo
The rejection method (section 9, STEP C) establishes the scattering angle α and azimuth angle β.The Stokes vector must be rotated by an angle β so that its reference plane coincides with the scattering plane before scattering can be calculated.This is achieved with the rotational matrix R(β) of Eq. ( 12).The actual scattering by an angle α is done by multiplying the Stokes vector by the scattering matrix M(α), Eq. ( 9).After scattering the Stokes vector, the reference coordinate system must be adjusted.Figure 1, STEP D: Bartel and Hielscher used a set of rotations called Euler Angles.Their implementation will be shown in Appendix 1, in this section we show what we did in our program.
The Stokes vector reference frame was tracked with only two vectors u and v and the rotations were implemented using the rotation matrix R euler .This formulation is often referred to as the Rodriques' formula [28] and can be derived from the matrices used by Bartel and Hielscher.This formula is used to rotate a generic vector p about a unit vector k of an angle σ: (17) in matrix format this rotation is expressed as: where k = [k x , k y ,k z ] is the rotational axis, c=cos(σ), s=sin(σ) and v=1-cos(σ).In the Monte Carlo program the rotations of the vector v and u occur in this order: first the unit vector v is rotated about the vector u by an angle β by multiplying v by the rotational matrix R euler (u,β); u remains unchanged in this process (see Fig. 8 and 9).Then u is rotated about the newly generated v by an angle α.This is done multiplying the unit vector u by the rotational matrix R euler (v,α).Finally the Stokes vector is adjusted for the two rotations.The Stokes vector is multiplied by the rotational matrix R(β) of Eq. ( 12) and then by the scattering matrix M(α) of Eq. ( 9).The new Stokes vector S new becomes: These steps are repeated for every scattering event.

Scatter -Quaternion Monte Carlo
In Quaternion Monte Carlo the rotations of the unit vectors u and v that identify the Stokes vector reference frame are handled with quaternion algebra.

STEP D:
The first rotation about the vector u by an angle β is accomplished generating the quaternion q β q β = β + u = β + iu x + ju y + ku z (20) and then using the quaternion operator of equation 3 on the unit vector v, β β * q vq .
To generate the quaternion q β we used this simple expression: The second rotation is by an angle α about the axis v.This is done generating the quaternion and using the quaternion operator α α * q uq .These steps are frequently optimized for speed and computational efficiency [31]; in our program we use the simplest and more intuitive implementation and not necessarily the fastest one.The Stokes vector is also adjusted for the two rotations as in Eq. (19).

Photon life and boundaries
The life of a photon ends when the photon passes through a boundary or when its weight W value falls below a threshold (typically 0.001) as in standard Monte Carlo.

Meridian Planes Monte Carlo
When the photon reaches one of the boundaries and is ready to be collected by a detector, one last rotation of the Stokes vector is necessary to put the photon polarization in the reference frame of the detector.STEP E: For a photon backscattered from a slab, the last rotation to the meridian plane of the detector is by an angle ϕ The Stokes vector of the reflected photon is multiplied one final time by R(ϕ).For a transmitted photon the angle ϕ is: Since Stokes vectors can be superimposed, all photons traveling in the direction of a detector can be added once they have been rotated to the detector reference frame.

Euler and Quaternion Monte Carlo
When the photon has reached one of the boundaries and is ready to be collected by a detector two final rotations of the Stokes vector are necessary to put the photon status of polarization in the detector reference frame.STEP E: The first rotation is needed to return the Stokes vector to the meridian plane.To do this w is reconstructed as the cross product of v and u.
The angle ε needed to rotate the Stokes vector into a meridian plane is given by: ε = 0 when v z = 0 and u z = 0 ⎟ in all other cases (27) This rotation is about the direction of propagation of the photon, i.e. the axis u, Fig.After this rotation E || is in a meridian plane, and v z = 0 (Fig. 11).A second rotation by an angle ϕ about the Z-axis, Fig. 12, will put the photon reference frame in the detector reference frame.All three reference axis w, v, u are affected by this rotation.ϕ is calculated as in Eq. ( 23) and ( 24 Thus the final Stokes vector is: These steps are repeated for every scattering event.At the boundaries the last aligning rotations are the same as in Euler Monte Carlo.

Comparison with Adding Doubling program
In 1991 Evans designed an adding doubling code [3] that could calculate both the radiance and flux of a polarized light beam exiting the atmosphere.The atmosphere can be modeled as a disperse solution of microspheres.One important feature of Evans' code is the way in which the flux is calculated: when a photon exits the atmosphere either in reflectance or transmission mode the values of the corresponding Stokes vector are summed without relating the polarization to a single detector reference plane.This is equivalent of having several detectors oriented to the meridian planes in different locations on the unit hemisphere.Most users use a single fixed detector to collect all the exiting photons, nevertheless we can model Evans program geometry with a simple modification to the meridian plane code by eliminating step E (Fig. 1) from the program.This prevents the last rotation to the detector meridian plane.Simulations were conducted considering a plane parallel slab of thickness L = 4/μ s , with absorption coefficient µ a =0, and an unpolarized incident beam (Stokes vector [1 0 0 0]) of wavelength λ = 632.8nm.The spheres index of refraction was 1.59 and the media index of refraction was 1.In the Monte Carlo program the number of photon launched was 10 6 .The value of reflectance and transmittance through the slabs are shown in the following tables: The error for the Monte Carlo runs was the standard deviation of five different runs where only the seed of the random generator was changed.The difference in between our code and Evans results is always less than 1%.

Conclusions
In this paper three different Monte Carlo programs that keep track of the status of polarization after every scattering event were described.The three programs are significantly different from each other yet they yield the same numerical results.The programs were developed for Unix platform in C programming language.All three programs run at approximately the same speed.The three codes are available for download at [23].
The Euler's angle Monte Carlo is easy to implement and intuitive, with a triplet of unit vectors following the photon reference frame after every scattering event.Euler's rotational matrices are well known since they are often used in rigid body rotations.Moreover since for any scattering event only one rotation of the reference frame is necessary the program should in principle be faster that the meridian plane method.
The quaternion Monte Carlo is an elegant solution.Quaternion rotations are used more and more often in computer science to handle animations.Many improvements are available to simplify the generation of the quaternion plus the multiplicative step in order to make them faster [31,38].Moreover Richartz and Hsu [30] demonstrated that quaternions can be used to simulate a material retardation, hence this methodology could be particularly useful in the modeling of polarized transfer in biological media, where birefringence and retardation play a large role.We intend to explore these algorithms in the future.
The compilation of these three models was lengthy; seemingly correct solutions were proven wrong by further testing.A key issue we identified during this process relates to the exiting routine and the backscattered reflection of photons.Many of the papers dealing with polarized Monte Carlo program use as proof of the goodness of their code the shapes of the backscattered Mueller matrix from a solution of microsphere.Since many of the elements of the Mueller matrix are axially symmetric an erroneous exiting routine could still generate apparently correct answers.The best way to test for this is to launch photons at a small angle to the normal (~30 degrees).This assures the breaking of symmetry, the backscattered pattern will be better suited for experimental comparison.
Another issue we encountered in the compilations of our Monte Carlo programs was related to the subdivision of the scattering function.Generally a subdivision of 180 angles is acceptable, in Henyey Greenstein based Monte Carlo programs.In our Mie theory based programs the subdivision of the scattering function had to be larger than 1000 angles to obtain accurate values of total reflectance and total transmittance.
Previous papers [14,18] have discussed the correct implementation of the rejection function that chooses the scattering angle α and azimuth angle β.Some author such as Bartel and Hiescher, select first the azimuth angle uniformly between 0 and π and then enter the rejection method algorithm where the scattering angle is selected based on the original choice of β.Rakovic et al. [18] showed that the correct choice of α and β is obtained selecting both angles in the loop of the rejection method.We implemented both method and realized that the two numerical implementations are numerically very similar.Moreover the rejection method is a bottleneck for the Monte Carlo program, optimizing this section of the program would improve dramatically their efficiency.
Significant experimental testing was performed on all three programs.The results of these tests will be shown in the next paper [38].
where δ, ρ,and ω are three general rotation angles and the rotation sequence follows the 3-l-r Euler angle convention.The corresponding matrix multiplication occur in this order: One problem with Euler angles is the occurrence of the "Gimbal Lock".A Gimbal lock is obtained when two of the axes of rotation line up with the consequent loss of one degree of freedom.Fortunately since the D l matrix is the unity matrix the Gimbal Lock never occurs

Fig. 1 .
Fig. 1.Flow chart of Polarized Monte Carlo program, the white cells are used in Standard Monte Carlo programs the gray cells are specific of Polarized Light Monte Carlo programs

Fig. 2 .
Fig. 2. Meridian planes geometry.The photon's direction of propagation before and after scattering is I 1 , and I 2 respectively.The plane COA defines the meridian plane before and after scattering.

Figure 1 ,
Figure 1, STEP A: We use two unit vectors v and u to define the E field reference

Fig 1 ,
STEP B: For any considered status of polarization of the incident field we define a Stokes vector S = [I Q U V] whose reference frame was established in step B; for example: if we want to model an incident field perpendicular to the reference plane we have to assume a Stokes vector S = [1 -1 0 0].
the photon position is updated to a new position [x', y', z'] with the following equations: ' The phase function P(α,β) has a bivariate dependence on angles α and β.For unpolarized light where S o =[1, 0, 0, 0], the phase function becomes a function of just the single variable α,

Fig. 3 .
Fig. 3. Left Fig. shows the Mie phase function for incident linear polarized light and the right Fig. is the phase function for incident circular polarized light.This is visible in Eq. (8).If Q o and U o are not both zero, then the phase function depends both on α and β.For circularly polarized light S o =[1 0 0 1], the phase function is axis-symmetric since there is no β dependence Our simulations of phase function intensities for linear and circular incidence agree with the simulations done by Hopcraft et al. and can be seen in Fig. 3.These simulations show the Mie phase function for linear polarized incidence and circular polarized incidence.The asymmetry of the phase function along the Z-axis for linear incidence is evident.In this Fig., the phase function shows a strong dip at 90˚.A small sphere size (diameter = 10 nm) was used in both graphs with index of refraction 1.59.Figure1, STEP C: The rejection method[35] may be used to generate random variables with a particular distribution.For functions of a single variable, two random numbers are generated.First, P rand is a uniform random deviate between 0 and 1. Second

Fig. 4 .
Fig. 4. Visual description of the rotations necessary to transfer the reference frame from one meridian plane to the next.Initially the electrical field E is defined with respect to the meridian plane COA.

Fig. 6 .
Fig. 6.After a scattering event the Stokes vector is defined respect to the plane BOA.The direction cosines are updated to take into account the new direction.The new direction cosines will be called û.The new trajectory [û x , û y , û z ] is calculated based on the angle α and β and on the current trajectory [u x , u y , u z ].If |u z | ≈ 1:

Fig. 7 .
Fig. 7. Second reference plane rotation.The electric field is now rotated so that E || is in the meridian plane COB.

Fig. 8 .
Fig. 8.The triplet w, v, u is rotated of an angle β.The rotation is about the axis u, left image, the rotated w and v vectors are shown on the right.u remains unchanged.

Fig. 9 .
Fig. 9. Second rotation on the w, v, u triplet.The rotation is of an angle α about the vector v as shown on the left.The rotated vector are shown on the right.v remains unchanged.

(Fig. 10 .
Fig.10.Rotation about an axis u of an angle ε.This rotation will bring v parallel to the Z-axis and the plane w0u in a meridian plane.

Fig. 11 .
Fig.11.Effect of a rotation about an axis u of an angle ε on the w and v vectors.v is parallel to the Z-axis and the plane wOu is in a meridian plane.

Fig. 12 .
Fig. 12. Rotation of the photon reference frame about the Z-axis.All three vectors u, v, w are affected by this rotation.

Table 1 .
Reflectance mode, comparison between Evans adding-doubling code and the meridian plane Monte Carlo program.The results do not include the final rotation for a single detector.

Table 2 .
Transmission mode, comparison between Evans adding doubling code and the meridian plane Monte Carlo program.The results are not corrected for a single detector.