コード例 #1
0
        public void validate_static_method_updatedirectionafterrotatingaroundyaxis()
        {
            var dir = _direction.Clone();

            SourceToolbox.UpdateDirectionAfterRotatingAroundYAxis(_angRot.YRotation, dir);

            Assert.Less(Math.Abs(dir.Ux - _tp[91]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(dir.Uy - _tp[92]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(dir.Uz - _tp[93]), ACCEPTABLE_PRECISION);
        }
コード例 #2
0
        /// <summary>
        /// Implements Get next photon
        /// </summary>
        /// <param name="tissue">tissue</param>
        /// <returns>photon</returns>
        public Photon GetNextPhoton(ITissue tissue)
        {
            //Sample emitting side
            String cSide = SelectEmittingSurface(
                _cubeLengthX,
                _cubeWidthY,
                _cubeHeightZ,
                Rng);

            //sample angular distribution
            Direction finalDirection = SourceToolbox.GetDirectionForGivenPolarAzimuthalAngleRangeRandom(
                _polarAngleEmissionRange,
                SourceDefaults.DefaultAzimuthalAngleRange.Clone(),
                Rng);

            Position tempPosition  = null;
            Position finalPosition = null;

            switch (cSide)
            {
            case "xpos":
                tempPosition    = GetFinalPosition(_beamDiameterFWHM, _cubeHeightZ, _cubeWidthY, Rng);
                finalPosition.X = 0.5 * _cubeLengthX;
                finalPosition.Y = tempPosition.Y;
                finalPosition.Z = tempPosition.X;
                finalDirection  = SourceToolbox.UpdateDirectionAfterRotatingAroundXAxis(0.5 * Math.PI, finalDirection);
                break;

            case "xneg":
                tempPosition    = GetFinalPosition(_beamDiameterFWHM, _cubeHeightZ, _cubeWidthY, Rng);
                finalPosition.X = -0.5 * _cubeLengthX;
                finalPosition.Y = tempPosition.Y;
                finalPosition.Z = tempPosition.X;
                finalDirection  = SourceToolbox.UpdateDirectionAfterRotatingAroundXAxis(-0.5 * Math.PI, finalDirection);
                break;

            case "ypos":
                tempPosition    = GetFinalPosition(_beamDiameterFWHM, _cubeLengthX, _cubeHeightZ, Rng);
                finalPosition.X = tempPosition.X;
                finalPosition.Y = 0.5 * _cubeWidthY;
                finalPosition.Z = tempPosition.Y;
                finalDirection  = SourceToolbox.UpdateDirectionAfterRotatingAroundYAxis(0.5 * Math.PI, finalDirection);
                break;

            case "yneg":
                tempPosition    = GetFinalPosition(_beamDiameterFWHM, _cubeLengthX, _cubeHeightZ, Rng);
                finalPosition.X = tempPosition.X;
                finalPosition.Y = -0.5 * _cubeWidthY;
                finalPosition.Z = tempPosition.Y;
                finalDirection  = SourceToolbox.UpdateDirectionAfterRotatingAroundYAxis(-0.5 * Math.PI, finalDirection);
                break;

            case "zpos":
                tempPosition    = GetFinalPosition(_beamDiameterFWHM, _cubeLengthX, _cubeWidthY, Rng);
                finalPosition.X = tempPosition.X;
                finalPosition.Y = tempPosition.Y;
                finalPosition.Z = 0.5 * _cubeHeightZ;
                break;

            case "zneg":
                tempPosition    = GetFinalPosition(_beamDiameterFWHM, _cubeLengthX, _cubeWidthY, Rng);
                finalPosition.X = tempPosition.X;
                finalPosition.Y = tempPosition.Y;
                finalPosition.Z = -0.5 * _cubeHeightZ;
                //reverse signs
                finalDirection.Uz = -finalDirection.Uz;
                break;
            }

            //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);
        }