Esempio n. 1
0
        protected abstract Direction GetFinalDirection(Position position); // position may or may not be needed

        private static Position GetFinalPositionFromProfileType(ISourceProfile sourceProfile, double innerRadius, double outerRadius, Random rng)
        {
            Position finalPosition = SourceDefaults.DefaultPosition.Clone();

            switch (sourceProfile.SourceProfileType)
            {
            case SourceProfileType.Flat:
                // var flatProfile = sourceProfile as FlatSourceProfile;
                finalPosition = SourceToolbox.GetPositionInACircleRandomFlat(
                    SourceDefaults.DefaultPosition.Clone(),
                    innerRadius,
                    outerRadius,
                    rng);
                break;

            case SourceProfileType.Gaussian:
                var gaussianProfile = sourceProfile as GaussianSourceProfile;
                finalPosition = SourceToolbox.GetPositionInACircleRandomGaussian(
                    SourceDefaults.DefaultPosition.Clone(),
                    outerRadius,
                    innerRadius,
                    gaussianProfile.BeamDiaFWHM,
                    rng);
                break;
            }
            return(finalPosition);
        }
        public void validate_static_method_getpositioninacirclerandomgaussian()
        {
            Random rng = new MathNet.Numerics.Random.MersenneTwister(0);
            var    pos = SourceToolbox.GetPositionInACircleRandomGaussian(_position, _outerRadius, _innerRadius, _bdFWHM, rng);

            Assert.Less(Math.Abs(pos.X - _tp[50]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(pos.Y - _tp[51]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(pos.Z - _tp[52]), ACCEPTABLE_PRECISION);
        }
Esempio n. 3
0
        protected abstract Direction GetFinalDirection(Position position); // position may or may not be needed

        private static Position GetFinalPosition(double beamDiameterFWHM, double innerRadius, double outerRadius, Random rng)
        {
            return(beamDiameterFWHM < 0.0
                ? SourceToolbox.GetPositionInACircleRandomFlat(
                       SourceDefaults.DefaultPosition.Clone(),
                       innerRadius,
                       outerRadius,
                       rng)
                : SourceToolbox.GetPositionInACircleRandomGaussian(
                       SourceDefaults.DefaultPosition.Clone(),
                       outerRadius,
                       innerRadius,
                       beamDiameterFWHM,
                       rng));
        }