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_getpositioninanellipsoidrandomgaussian() { Random rng = new MathNet.Numerics.Random.MersenneTwister(0); var pos = SourceToolbox.GetPositionInAnEllipsoidRandomGaussian(_position, _aParameter, _bParameter, _cParameter, _bdFWHM, rng); Assert.Less(Math.Abs(pos.X - _tp[74]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(pos.Y - _tp[75]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(pos.Z - _tp[76]), 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)); }