protected abstract Direction GetFinalDirection(); // position may or may not be needed

        private static Position GetFinalPositionFromProfileType(ISourceProfile sourceProfile, double aParameter, double bParameter, double cParameter, Random rng)
        {
            Position finalPosition = null;

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

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

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

        private static Position GetFinalPosition(double beamDiameterFWHM, double aParameter, double bParameter, double cParameter, Random rng)
        {
            return(beamDiameterFWHM < 0.0
                ? SourceToolbox.GetPositionInAnEllipsoidRandomFlat(
                       SourceDefaults.DefaultPosition.Clone(),
                       2 * aParameter,
                       2 * bParameter,
                       2 * cParameter,
                       rng)
                : SourceToolbox.GetPositionInAnEllipsoidRandomGaussian(
                       SourceDefaults.DefaultPosition.Clone(),
                       2 * aParameter,
                       2 * bParameter,
                       2 * cParameter,
                       beamDiameterFWHM,
                       rng));
        }