Exemple #1
0
        /// <summary>
        /// Bilinearly interpolate between four values.
        /// </summary>
        /// <param name="ul">The upper left value.</param>
        /// <param name="ur">The upper right value.</param>
        /// <param name="ll">The lower left value.</param>
        /// <param name="lr">The lower right value.</param>
        /// <param name="x">The horizontal interpolation factor.</param>
        /// <param name="y">The vertical interpolation factor.</param>
        /// <returns>The interpolated value between all four points by the interpolation factors.</returns>
        public static double BilinerInterpolate(double ul, double ur, double ll, double lr, double x,
                                                double y)
        {
            var u = MapUtil.Interpolate(ul, ur, x);
            var l = MapUtil.Interpolate(ll, lr, x);

            return(MapUtil.Interpolate(u, l, y));
        }
Exemple #2
0
        /// <summary>
        /// Get the ocean bias for a cell.
        /// </summary>
        /// <param name="ca">The cell address</param>
        /// <returns></returns>
        public float OceanBiasAt(CellAddress ca)
        {
            var pX = (ca.X / _cellsPerPoint) * _cellsPerPoint;
            var pY = (ca.Y / _cellsPerPoint) * _cellsPerPoint;

            var ul = GetBiasPoint(pX, pY).PercentOcean;
            var ur = GetBiasPoint(pX + _cellsPerPoint, pY).PercentOcean;
            var ll = GetBiasPoint(pX, pY + _cellsPerPoint).PercentOcean;
            var lr = GetBiasPoint(pX + _cellsPerPoint, pY + _cellsPerPoint).PercentOcean;

            var xPerc = (ca.X - pX) / (float)_cellsPerPoint;
            var yPerc = (ca.Y - pY) / (float)_cellsPerPoint;

            return((float)MapUtil.BilinerInterpolate(ul, ur, ll, lr, xPerc, yPerc));
        }