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

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

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

            case SourceProfileType.Gaussian:
                var gaussianProfile = sourceProfile as GaussianSourceProfile;
                finalPosition = SourceToolbox.GetPositionInAnEllipseRandomGaussian(
                    SourceDefaults.DefaultPosition.Clone(),
                    aParameter,
                    bParameter,
                    gaussianProfile.BeamDiaFWHM,
                    rng);
                break;
            }
            return(finalPosition);
        }
        public void validate_static_method_getpositioninanellipserandomflat()
        {
            Random rng = new MathNet.Numerics.Random.MersenneTwister(0);
            var    pos = SourceToolbox.GetPositionInAnEllipseRandomFlat(_position, _aParameter, _bParameter, rng);

            Assert.Less(Math.Abs(pos.X - _tp[65]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(pos.Y - _tp[66]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(pos.Z - _tp[67]), 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 aParameter, double bParameter, Random rng)
        {
            return(beamDiameterFWHM < 0 // flat
                ? SourceToolbox.GetPositionInAnEllipseRandomFlat(
                       SourceDefaults.DefaultPosition.Clone(),
                       aParameter,
                       bParameter,
                       rng)
                : SourceToolbox.GetPositionInAnEllipseRandomGaussian(
                       SourceDefaults.DefaultPosition.Clone(),
                       aParameter,
                       bParameter,
                       beamDiameterFWHM,
                       rng));
        }