private float GetShadeOpacity(
            ShiftsStorage.PointInfo source_of_shade,
            ShiftsStorage.PointInfo shaded_correction)
        {
            Debug.Assert(source_of_shade.distance <= shaded_correction.distance);

            float opacity = 1;

            float angle_in_percents = (float)(Helpers.GetAngleBetweenVectors(source_of_shade, shaded_correction) * 100 / Math.PI);

            Debug.Assert(angle_in_percents <= 100);

            // Opacity descendes gradualy on the sides of opaque sector.
            if (angle_in_percents < calibration_mode.size_of_opaque_sector_in_percents)
            {
                opacity = 1;
            }
            else if (angle_in_percents > calibration_mode.size_of_opaque_sector_in_percents + 10)
            {
                opacity = 0;
            }
            else
            {
                opacity = (calibration_mode.size_of_opaque_sector_in_percents + 10 - angle_in_percents) / (10);
            }

            float distance_from_shade_shell_to_shaded_correction = shaded_correction.distance - source_of_shade.distance;

            if (distance_from_shade_shell_to_shaded_correction < calibration_mode.shade_thickness_in_pixels)
            {
                opacity *= distance_from_shade_shell_to_shaded_correction / calibration_mode.shade_thickness_in_pixels;
            }

            return(opacity);
        }
Пример #2
0
        private float GetShadeOpacity(
            ShiftStorageCache.PointInfo source_of_shade,
            ShiftStorageCache.PointInfo shaded_correction)
        {
            Debug.Assert(source_of_shade.distance <= shaded_correction.distance);

            float opacity = 1;

            float angle_in_percents = (float)(Helpers.GetAngleBetweenVectors(source_of_shade, shaded_correction) * 100 / Math.PI);

            Debug.Assert(angle_in_percents <= 100);

            // Opacity descendes gradualy in the sector between opaque and transparent sectors.
            if (angle_in_percents < calibration_mode.size_of_opaque_sector_in_percents)
            {
                opacity = 1;
            }
            else if (angle_in_percents > 100 - calibration_mode.size_of_transparent_sector_in_percents)
            {
                opacity = 0;
            }
            else
            {
                opacity = (angle_in_percents + calibration_mode.size_of_transparent_sector_in_percents - 100) /
                          (calibration_mode.size_of_opaque_sector_in_percents + calibration_mode.size_of_transparent_sector_in_percents - 100);
            }

            float distance_from_shade_shell_to_shaded_correction = shaded_correction.distance - source_of_shade.distance;

            if (distance_from_shade_shell_to_shaded_correction < calibration_mode.shade_thickness_in_pixels)
            {
                opacity *= distance_from_shade_shell_to_shaded_correction / calibration_mode.shade_thickness_in_pixels;
            }

            return(opacity * source_of_shade.weight);
        }