Beispiel #1
0
        protected abstract Direction GetFinalDirection(); // position may or may not be needed

        private static Position GetFinalPositionFromProfileType(ISourceProfile sourceProfile, double cubeLengthX, double cubeWidthY, double cubeHeightZ, Random rng)
        {
            Position finalPosition = null;

            switch (sourceProfile.SourceProfileType)
            {
            case SourceProfileType.Flat:
                // var flatProfile = sourceProfile as FlatSourceProfile;
                SourceToolbox.GetPositionInACuboidRandomFlat(
                    SourceDefaults.DefaultPosition.Clone(),
                    cubeLengthX,
                    cubeWidthY,
                    cubeHeightZ,
                    rng);
                break;

            case SourceProfileType.Gaussian:
                var gaussianProfile = sourceProfile as GaussianSourceProfile;
                finalPosition = SourceToolbox.GetPositionInACuboidRandomGaussian(
                    SourceDefaults.DefaultPosition.Clone(),
                    0.5 * cubeLengthX,
                    0.5 * cubeWidthY,
                    0.5 * cubeHeightZ,
                    gaussianProfile.BeamDiaFWHM,
                    rng);
                break;
            }
            return(finalPosition);
        }
        public void validate_static_method_getpositioninacuboidrandomgaussian()
        {
            Random rng = new MathNet.Numerics.Random.MersenneTwister(0);
            var    pos = SourceToolbox.GetPositionInACuboidRandomGaussian(_position, 0.5 * _lengthX, 0.5 * _widthY, 0.5 * _heightZ, _bdFWHM, rng);

            Assert.Less(Math.Abs(pos.X - _tp[56]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(pos.Y - _tp[57]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(pos.Z - _tp[58]), ACCEPTABLE_PRECISION);
        }
        protected abstract Direction GetFinalDirection(); // position may or may not be needed

        private static Position GetFinalPosition(double beamDiameterFWHM, double cubeLengthX, double cubeWidthY, double cubeHeightZ, Random rng)
        {
            return(beamDiameterFWHM < 0.0
                ? SourceToolbox.GetPositionInACuboidRandomFlat(
                       SourceDefaults.DefaultPosition.Clone(),
                       cubeLengthX,
                       cubeWidthY,
                       cubeHeightZ,
                       rng)
                : SourceToolbox.GetPositionInACuboidRandomGaussian(
                       SourceDefaults.DefaultPosition.Clone(),
                       0.5 * cubeLengthX,
                       0.5 * cubeWidthY,
                       0.5 * cubeHeightZ,
                       beamDiameterFWHM,
                       rng));
        }