TestInterpolatedSurface() { var curve = new DiscreteSurface(_rows, _pointCoords, VMatrix); var interpCurve = new InterpolatedSurface(curve, new LinearInterpolation(), true); for (int i = 0; i < curve.GetPointList().Count; i++) { IPoint point = curve.GetPointList()[i]; var val = interpCurve.Value(point); Console.WriteLine(point.FunctionValue); } }
public void ValueTestSixteenPoints() { List <IPoint> points = new List <IPoint> { new Point2D(3, 1, 5.2), new Point2D(3, 3, 7.9), new Point2D(3, 8, 8.7), new Point2D(3, 9, 8.9), new Point2D(7, 1, 8.1), new Point2D(7, 3, 12.4), new Point2D(7, 8, 12.5), new Point2D(7, 9, 14.7), new Point2D(8, 1, 8.2), new Point2D(8, 3, 12.2), new Point2D(8, 8, 12.7), new Point2D(8, 9, 13.6), new Point2D(9, 1, 8.3), new Point2D(9, 3, 12.2), new Point2D(9, 8, 12.6), new Point2D(9, 9, 12.9), }; DiscreteSpace surface = new DiscreteSurface(points); InterpolatedSurface interp = new InterpolatedSurface(surface, new LinearInterpolation(), true); // Actual points Assert.AreEqual(5.2, interp.Value(new Point2D(3, 1, 0))); Assert.AreEqual(7.9, interp.Value(new Point2D(3, 3, 0))); Assert.AreEqual(8.7, interp.Value(new Point2D(3, 8, 0))); Assert.AreEqual(8.9, interp.Value(new Point2D(3, 9, 0))); Assert.AreEqual(8.1, interp.Value(new Point2D(7, 1, 0))); Assert.AreEqual(12.4, interp.Value(new Point2D(7, 3, 0))); Assert.AreEqual(12.5, interp.Value(new Point2D(7, 8, 0))); Assert.AreEqual(14.7, interp.Value(new Point2D(7, 9, 0))); Assert.AreEqual(8.2, interp.Value(new Point2D(8, 1, 0))); Assert.AreEqual(12.2, interp.Value(new Point2D(8, 3, 0))); Assert.AreEqual(12.7, interp.Value(new Point2D(8, 8, 0))); Assert.AreEqual(13.6, interp.Value(new Point2D(8, 9, 0))); Assert.AreEqual(8.3, interp.Value(new Point2D(9, 1, 0))); Assert.AreEqual(12.2, interp.Value(new Point2D(9, 3, 0))); Assert.AreEqual(12.6, interp.Value(new Point2D(9, 8, 0))); Assert.AreEqual(12.9, interp.Value(new Point2D(9, 9, 0))); // Interpolate Assert.AreEqual(12.42, interp.Value(new Point2D(7.5, 5, 0))); Assert.AreEqual(7.4750000000000005, interp.Value(new Point2D(4, 2, 0))); Assert.AreEqual(12.95, interp.Value(new Point2D(8.5, 8.5, 0))); // Past the boundary Assert.AreEqual(5.2, interp.Value(new Point2D(2, 0, 0))); Assert.AreEqual(12.9, interp.Value(new Point2D(10, 10, 0))); Assert.AreEqual(14.7, interp.Value(new Point2D(7, 10, 0))); }
public void TestNodeSurfaceValues() { var curve = new InterpolatedSurface(new DiscreteSurface(_rows, _pointCoords, VMatrix), new LinearInterpolation(), true); for (var cols = 0; cols < _pointCoords.Length; cols++) { for (var row = 0; row < _rows.Length; row++) { IPoint pt = new Point2D(_rows[row], _pointCoords[cols]); double actual = curve.Value(pt); Debug.Print("Actual Value : {0} Row : {1} Column : {2}", actual, row, cols); Assert.AreEqual(VMatrix[row, cols], actual, 1e-3); } } }