Esempio n. 1
0
        /// <summary>
        /// Computes the anisotropy function using bilinear interpolation from Ir192 source
        /// </summary>
        /// <param name="radialDistanceMm">radial distance in mm</param>
        /// <param name="polarAngle">polar angle</param>
        /// <returns>anisotropy factor</returns>
        public static double ComputeAnisotropy(double radialDistanceMm, double polarAngle)
        {
            var polar = new PolarPosition(radialDistanceMm, polarAngle);

            return(Ir192AnisotropyCalculator.Compute(polar));
        }
        /// <summary>
        /// Computes the anisotropy function using bilinear interpolation.
        /// </summary>
        /// <param name="radialDistanceMm"></param>
        /// <param name="polarAngle"></param>
        /// <returns></returns>
        public static double Compute(PolarPosition polar)
        {
            if (!areTablesPopulated)
            {
                PopulateTable();
            }

            double rCm      = polar.Distance_mm / 10.0;
            double angleDeg = 180.0 * polar.Angle_rad / Math.PI;

            if (rCm < anisotropyFunctionTableRadialDistanceCm[0] || rCm >= anisotropyFunctionTableRadialDistanceCm[anisotropyFunctionTableRadialDistanceCm.Length - 1])
            {
                throw new ArgumentOutOfRangeException("radialDistanceMm", "Distance is not within range of the anisotropy function table.");
            }

            if (angleDeg < 0.0 || angleDeg > 180.0)
            {
                throw new ArgumentOutOfRangeException("polarAngle", "Invalid polar angle - polar angle must be in range 0-180 degrees.");
            }

            int j = 0;

            if (rCm >= anisotropyFunctionTableRadialDistanceCm[anisotropyFunctionTableRadialDistanceCm.Length - 1])
            {
                j = anisotropyFunctionTableRadialDistanceCm.Length - 2;
            }
            else if (rCm > anisotropyFunctionTableRadialDistanceCm[0])
            {
                j = Array.FindLastIndex(anisotropyFunctionTableRadialDistanceCm, r => r < rCm);
            }

            int i = 0;

            if (angleDeg >= anisotropyFunctionTablePolarAngleDeg[anisotropyFunctionTablePolarAngleDeg.Length - 1])
            {
                i = anisotropyFunctionTablePolarAngleDeg.Length - 2;
            }
            else if (angleDeg > anisotropyFunctionTablePolarAngleDeg[0])
            {
                i = Array.FindLastIndex(anisotropyFunctionTablePolarAngleDeg, a => a < angleDeg);
            }

            if (Double.IsNaN(anisotropyFunctionTableValue[i, j]) || Double.IsNaN(anisotropyFunctionTableValue[i, j + 1]) || Double.IsNaN(anisotropyFunctionTableValue[i + 1, j]) || Double.IsNaN(anisotropyFunctionTableValue[i + 1, j + 1]))
            {
                throw new ArgumentOutOfRangeException("radialDistanceMm", "Interpolation of anisotropy function requires data points that are not defined - calculation point is inside the source.");
            }

            double delta   = rCm - anisotropyFunctionTableRadialDistanceCm[j];
            double slope   = (anisotropyFunctionTableValue[i, j + 1] - anisotropyFunctionTableValue[i, j]) / (anisotropyFunctionTableRadialDistanceCm[j + 1] - anisotropyFunctionTableRadialDistanceCm[j]);
            double result1 = slope * delta + anisotropyFunctionTableValue[i, j];

            delta = rCm - anisotropyFunctionTableRadialDistanceCm[j];
            slope = (anisotropyFunctionTableValue[i + 1, j + 1] - anisotropyFunctionTableValue[i + 1, j]) / (anisotropyFunctionTableRadialDistanceCm[j + 1] - anisotropyFunctionTableRadialDistanceCm[j]);
            double result2 = slope * delta + anisotropyFunctionTableValue[i + 1, j];

            delta = angleDeg - anisotropyFunctionTablePolarAngleDeg[i];
            slope = (result2 - result1) / (anisotropyFunctionTablePolarAngleDeg[i + 1] - anisotropyFunctionTablePolarAngleDeg[i]);
            double result = slope * delta + result1;

            return(result);
        }
Esempio n. 3
0
 /// <summary>
 /// Computes the anisotropy function using bilinear interpolation from Ir192 source
 /// </summary>
 /// <param name="polar">the polar position of desired calc</param>
 /// <returns>anisotropy factor</returns>
 public static double ComputeAnisotropy(PolarPosition polar)
 {
     return(Ir192AnisotropyCalculator.Compute(polar));
 }