/// <summary> /// Implements Get next photon /// </summary> /// <param name="tissue">tissue</param> /// <returns>photon</returns> public Photon GetNextPhoton(ITissue tissue) { // sample angular distribution Direction finalDirection = SourceToolbox.GetDirectionForGivenPolarAzimuthalAngleRangeRandom(_polarAngleRangeToDefineSphericalSurface, _azimuthalAngleRangeToDefineSphericalSurface, Rng); //Source starts from anywhere in the sphere Position finalPosition = GetFinalPositionFromProfileType(finalDirection, _radius, Rng); //Lambertian distribution (uniform hemispherical distribution) PolarAzimuthalAngles polarAzimuthalPair = SourceToolbox.GetPolarAzimuthalPairForGivenAngleRangeRandom( SourceDefaults.DefaultHalfPolarAngleRange.Clone(), SourceDefaults.DefaultAzimuthalAngleRange.Clone(), Rng); //Avoid updating the finalDirection during following rotation Position dummyPosition = finalPosition; //Rotate polar azimutahl angle by polarAzimuthalPair vector SourceToolbox.UpdateDirectionPositionAfterRotatingByGivenAnglePair(polarAzimuthalPair, ref finalDirection, ref dummyPosition); //Find the relevent polar and azimuthal pair for the direction PolarAzimuthalAngles _rotationalAnglesOfPrincipalSourceAxis = SourceToolbox.GetPolarAzimuthalPairFromDirection(_newDirectionOfPrincipalSourceAxis); //Translation and source rotation SourceToolbox.UpdateDirectionPositionAfterGivenFlags( ref finalPosition, ref finalDirection, _rotationalAnglesOfPrincipalSourceAxis, _translationFromOrigin, _rotationAndTranslationFlags); var photon = new Photon(finalPosition, finalDirection, 1.0, tissue, _initialTissueRegionIndex, Rng); return(photon); }
public void validate_static_method_updatedirectionpositionafterrotatingbygivenanglepair() { var dir = _direction.Clone(); var pos = _position.Clone(); SourceToolbox.UpdateDirectionPositionAfterRotatingByGivenAnglePair(_angPair, ref dir, ref pos); Assert.Less(Math.Abs(dir.Ux - _tp[130]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(dir.Uy - _tp[131]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(dir.Uz - _tp[132]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(pos.X - _tp[133]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(pos.Y - _tp[134]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(pos.Z - _tp[135]), ACCEPTABLE_PRECISION); }