public void validate_static_method_getdirectionforgiven2dpositionandgivenpolarangle()
        {
            read_data();
            var pos = _position.Clone();
            var dir = SourceToolbox.GetDirectionForGiven2DPositionAndGivenPolarAngle(_polarAngle, pos);

            Assert.Less(Math.Abs(dir.Ux - _tp[31]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(dir.Uy - _tp[32]), ACCEPTABLE_PRECISION);
            Assert.Less(Math.Abs(dir.Uz - _tp[33]), ACCEPTABLE_PRECISION);
        }
Пример #2
0
        /// <summary>
        /// Returns direction for a given position
        /// </summary>
        /// <param name="position">position</param>
        /// <returns>new direction</returns>
        protected override Direction GetFinalDirection(Position position)
        {
            if (_lineLength == 0.0)
            {
                return(SourceToolbox.GetDirectionForGivenPolarAzimuthalAngleRangeRandom(
                           new DoubleRange(0.0, Math.Abs(_thetaConvOrDiv)),
                           SourceDefaults.DefaultAzimuthalAngleRange.Clone(),
                           Rng));
            }

            // sign is negative for diverging and positive positive for converging
            var polarAngle = SourceToolbox.UpdatePolarAngleForDirectionalSources(
                0.5 * _lineLength,
                position.X,
                _thetaConvOrDiv);

            return(SourceToolbox.GetDirectionForGiven2DPositionAndGivenPolarAngle(polarAngle, position));
        }
 /// <summary>
 /// Returns direction for a given position
 /// </summary>
 /// <param name="position">position</param>
 /// <returns>new direction</returns>
 protected override Direction GetFinalDirection(Position position)
 {
     if ((_rectLengthX == 0.0) && (_rectWidthY == 0.0))
     {
         return(SourceToolbox.GetDirectionForGivenPolarAzimuthalAngleRangeRandom(
                    new DoubleRange(0.0, Math.Abs(_thetaConvOrDiv)),
                    SourceDefaults.DefaultAzimuthalAngleRange.Clone(),
                    Rng));
     }
     else
     {
         // sign is negative for diverging and positive positive for converging
         var polarAngle = SourceToolbox.UpdatePolarAngleForDirectionalSources(
             _rectLengthX,
             Math.Sqrt(position.X * position.X + position.Y * position.Y),
             _thetaConvOrDiv);
         return(SourceToolbox.GetDirectionForGiven2DPositionAndGivenPolarAngle(polarAngle, position));
     }
 }