public void validate_static_method_updatedirectionpositionafterrotatingaroundxaxis() { var dir = _direction.Clone(); var pos = _position.Clone(); SourceToolbox.UpdateDirectionPositionAfterRotatingAroundXAxis(_angRot.XRotation, ref dir, ref pos); Assert.Less(Math.Abs(dir.Ux - _tp[112]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(dir.Uy - _tp[113]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(dir.Uz - _tp[114]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(pos.X - _tp[115]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(pos.Y - _tp[116]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(pos.Z - _tp[117]), ACCEPTABLE_PRECISION); }
/// <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( SourceDefaults.DefaultHalfPolarAngleRange.Clone(), SourceDefaults.DefaultAzimuthalAngleRange.Clone(), Rng); //Translate the photon to _tubeRadius length below the origin. Ring lies on yz plane. Position finalPosition = new Position(0.0, 0.0, _tubeRadius); //Sample a ring that emits photons outside. SourceToolbox.UpdateDirectionPositionAfterRotatingAroundXAxis( 2.0 * Math.PI * Rng.NextDouble(), ref finalDirection, ref finalPosition); //Ring lies on xy plane. z= 0; SourceToolbox.UpdateDirectionPositionAfterRotatingAroundYAxis( 0.5 * Math.PI, ref finalDirection, ref finalPosition); //Sample tube height finalPosition.Z = _tubeHeightZ * (2.0 * Rng.NextDouble() - 1.0); //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, tissue, _initialTissueRegionIndex, Rng); return(photon); }
/// <summary> /// Implements Get next photon /// </summary> /// <param name="tissue">tissue</param> /// <returns>photon</returns> public Photon GetNextPhoton(ITissue tissue) { double curved = 2 * Math.PI * _fiberRadius * _fiberHeightZ * _curvedSurfaceEfficiency; double bottom = Math.PI * _fiberRadius * _fiberRadius * _bottomSurfaceEfficiency; Direction finalDirection; Position finalPosition; if (_fiberRadius > 0.0) { if (Rng.NextDouble() > bottom / (curved + bottom)) { //sample angular distribution finalDirection = SourceToolbox.GetDirectionForGivenPolarAzimuthalAngleRangeRandom( SourceDefaults.DefaultHalfPolarAngleRange.Clone(), SourceDefaults.DefaultAzimuthalAngleRange.Clone(), Rng); //Translate the photon to _tubeRadius length below the origin. Ring lies on yz plane. finalPosition = new Position(0.0, 0.0, _fiberRadius); //Sample a ring that emits photons outside. SourceToolbox.UpdateDirectionPositionAfterRotatingAroundXAxis( 2.0 * Math.PI * Rng.NextDouble(), ref finalDirection, ref finalPosition); //Ring lies on xy plane. z= 0; SourceToolbox.UpdateDirectionPositionAfterRotatingAroundYAxis( 0.5 * Math.PI, ref finalDirection, ref finalPosition); //Sample tube height finalPosition.Z = _fiberHeightZ * (2.0 * Rng.NextDouble() - 1.0); } else { finalPosition = SourceToolbox.GetPositionInACircleRandomFlat( SourceDefaults.DefaultPosition.Clone(), 0.0, _fiberRadius, Rng); finalDirection = SourceToolbox.GetDirectionForGivenPolarAzimuthalAngleRangeRandom( SourceDefaults.DefaultHalfPolarAngleRange.Clone(), SourceDefaults.DefaultAzimuthalAngleRange.Clone(), Rng); } } else { finalPosition = SourceToolbox.GetPositionInALineRandomFlat( SourceDefaults.DefaultPosition.Clone(), _fiberHeightZ, Rng); finalDirection = SourceToolbox.GetDirectionForGivenPolarAzimuthalAngleRangeRandom( SourceDefaults.DefaultFullPolarAngleRange.Clone(), SourceDefaults.DefaultAzimuthalAngleRange.Clone(), Rng); //Rotate 90degrees around y axis SourceToolbox.UpdateDirectionPositionAfterRotatingAroundYAxis( 0.5 * Math.PI, ref finalDirection, ref finalPosition); } //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, tissue, _initialTissueRegionIndex, Rng); return(photon); }