private void BezierMeshFlipXY_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                double[] ratios = new double[] { .4, .3, .2, .1 };        // x axis
                double[] pointCounts = new double[] { 9, 8, 7, 6, 5, 4, 3 };       // y axis
                double[] linkCounts = new double[]      // z values
                {
                    11, 9, 8, 8,
                    8, 7, 7, 7,
                    7, 6, 6, 6,
                    5, 5, 5, 5,
                    4, 4, 4, 0,
                    3, 3, 3, 0,
                    2, 2, 2, 0,
                };

                BezierMesh mesh = new BezierMesh(ratios, pointCounts, linkCounts);

                double test = mesh.EstimateValue(.2, 8);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void BezierMesh_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                double[] ratios = new double[] { 0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1 };        // x axis
                double[] pointCounts = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 26, 35, 47, 61, 77, 96, 118, 142, 168, 197, 229, 263, 300 };       // y axis
                double[] linkCounts = new double[]      // z values
                {
                    0, 	0, 	0, 	0, 	0, 	0, 	0, 	0, 	0, 	0, 	0, 
                    0, 	0, 	0, 	1, 	1, 	1, 	1, 	1, 	1, 	1, 	1, 
                    0, 	0, 	2, 	2, 	2, 	2, 	2, 	2, 	2, 	3, 	3, 
                    0, 	0, 	3, 	3, 	3, 	3, 	3, 	4, 	4, 	6, 	6, 
                    0, 	0, 	4, 	4, 	4, 	4, 	5, 	7, 	7, 	7, 	9.65, 
                    0, 	5, 	5, 	5, 	5, 	6, 	8, 	8, 	10.5875, 	10.7125, 	13.65, 
                    0, 	6, 	6, 	6, 	7, 	9, 	9, 	11.6, 	14.875, 	15, 	18.35, 
                    0, 	7, 	7, 	7, 	8, 	10, 	12.7, 	15.8875, 	15.8625, 	19.3125, 	22.9875, 
                    0, 	8, 	8, 	9, 	11, 	11, 	13.6375, 	16.925, 	20.2625, 	24.15, 	28.3125, 
                    0, 	9, 	9, 	10, 	12, 	14.725, 	17.85, 	21.4375, 	25.2125, 	29.4625, 	33.3125, 
                    0, 	10, 	10, 	11, 	13, 	18.7375, 	22.175, 	26.35, 	30.1625, 	34.4125, 	38.5875, 
                    0, 	11, 	11, 	14, 	16.7375, 	19.8, 	23.225, 	27.3875, 	35.8, 	39.7375, 	43.9125, 
                    0, 	12, 	13, 	15, 	17.775, 	20.8875, 	28.2375, 	32.6, 	36.3125, 	45.5, 	49.7, 
                    0, 	13, 	14, 	16, 	21.9125, 	25.2375, 	29.0625, 	37.275, 	41.55, 	51.1, 	55.6125, 
                    0, 	14, 	15, 	17, 	22.8875, 	30.0625, 	33.9125, 	38.4375, 	47.4875, 	56.9, 	61.3, 
                    0, 	15, 	16, 	20.65, 	23.9625, 	31.2625, 	39.4875, 	43.5, 	52.9625, 	57.75, 	67.4375, 
                    0, 	19, 	22, 	27.7125, 	35.4125, 	43.325, 	52.575, 	61.8875, 	70.9625, 	81.325, 	92.025, 
                    0, 	26, 	30.7125, 	41.3875, 	49.2375, 	62.7875, 	77.5875, 	87.5875, 	102.7875, 	112.9625, 	130.1625, 
                    0, 	37, 	46.2, 	58.05, 	77.1875, 	96.7, 	111.2375, 	127.1625, 	149.225, 	170.65, 	187.2375, 
                    0, 	51.725, 	66.25, 	88.4875, 	113.325, 	139.7, 	160.75, 	188.2125, 	216.375, 	239.225, 	268.4125, 
                    0, 	68.775, 	93.7875, 	122.475, 	154.125, 	185.6875, 	224.4375, 	259.775, 	294.8, 	330.8125, 	366.6625, 
                    0, 	92.0875, 	123.45, 	163.65, 	206.8625, 	246.5875, 	293.4875, 	338.775, 	386.3125, 	428.5, 	476.425, 
                    0, 	119.3875, 	162.0875, 	216.4, 	266.2375, 	324.325, 	381.125, 	435.9, 	496.625, 	550.9375, 	613.95, 
                    0, 	150.3875, 	210.2125, 	269.775, 	338.0125, 	409.425, 	482.075, 	554.5125, 	623.5125, 	696.275, 	769.2875, 
                    0, 	183.4875, 	256.6125, 	340.5875, 	422.725, 	507.1125, 	591.3125, 	675.8625, 	768.6375, 	856.35, 	942.5375, 
                    0, 	223.725, 	315.6625, 	407.325, 	507.8375, 	609.775, 	715.7, 	819.425, 	921.65, 	1026.95, 	1130.8125, 
                    0, 	268.2125, 	373.125, 	490.2375, 	608.125, 	726.0375, 	847.1875, 	972.9625, 	1100.25, 	1219.45, 	1345.4875, 
                    0, 	316.35, 	443.4625, 	581.4625, 	720.925, 	854.7875, 	1000.775, 	1144.6375, 	1290.3, 	1434.2875, 	1584.5125, 
                    0, 	365.9875, 	520.325, 	675.4625, 	834.6, 	1003.275, 	1164.6, 	1328.7, 	1492.9625, 	1665.35, 	1830.9875, 
                    0, 	424.6375, 	598.35, 	779.7, 	963.8, 	1151.2375, 	1340.875, 	1530.5, 	1722.0375, 	1914.4625, 	2106.5375
                };

                BezierMesh mesh = new BezierMesh(ratios, pointCounts, linkCounts);

                //double test = mesh.EstimateValue(.2, 8);
                double test = mesh.EstimateValue(.21, 7.9);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }