private static Position GetFinalPositionFromProfileType(ISourceProfile sourceProfile, double rectLengthX, double rectWidthY, Random rng) { Position finalPosition = null; switch (sourceProfile.SourceProfileType) { case SourceProfileType.Flat: // var flatProfile = sourceProfile as FlatSourceProfile; SourceToolbox.GetPositionInARectangleRandomFlat( SourceDefaults.DefaultPosition.Clone(), rectLengthX, rectWidthY, rng); break; case SourceProfileType.Gaussian: var gaussianProfile = sourceProfile as GaussianSourceProfile; finalPosition = SourceToolbox.GetPositionInARectangleRandomGaussian( SourceDefaults.DefaultPosition.Clone(), 0.5 * rectLengthX, 0.5 * rectWidthY, gaussianProfile.BeamDiaFWHM, rng); break; } return(finalPosition); }
public void validate_static_method_getpositioninarectanglerandomflat() { Random rng = new MathNet.Numerics.Random.MersenneTwister(0); var pos = SourceToolbox.GetPositionInARectangleRandomFlat(_position, _lengthX, _widthY, rng); Assert.Less(Math.Abs(pos.X - _tp[77]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(pos.Y - _tp[78]), ACCEPTABLE_PRECISION); Assert.Less(Math.Abs(pos.Z - _tp[79]), ACCEPTABLE_PRECISION); }
/// <summary> /// returns final position from profile type /// </summary> /// <param name="sourceProfile">ISourceProfile</param> /// <param name="rectLengthX">rectangular length in x direction (length)</param> /// <param name="rectWidthY">rectangular length in y direction (width)</param> /// <param name="rng">random number generator</param> /// <returns>Position</returns> protected static Position GetFinalPosition(double beamDimeterFWHM, double rectLengthX, double rectWidthY, Random rng) { return(beamDimeterFWHM < 0 ? SourceToolbox.GetPositionInARectangleRandomFlat( SourceDefaults.DefaultPosition.Clone(), rectLengthX, rectWidthY, rng) : SourceToolbox.GetPositionInARectangleRandomGaussian( SourceDefaults.DefaultPosition.Clone(), 0.5 * rectLengthX, 0.5 * rectWidthY, beamDimeterFWHM, rng)); }