Example #1
0
        public void Test_Bezier_curve()
        {
            var curve = new Bezier_curve();

            Point2d[] result      = new Point2d[6];
            Point2d[] coordinates = new Point2d[4];
            coordinates[0] = new Point2d(1, 1);
            coordinates[1] = new Point2d(2, 2);
            coordinates[2] = new Point2d(3, 1);
            coordinates[3] = new Point2d(4, 2);
            curve.Cubic_curve(coordinates, 6, result);
            var expected = new Point2d[6];

            expected[0] = new Point2d(1, 1);
            expected[1] = new Point2d(1.6, 1.392);
            expected[2] = new Point2d(2.2, 1.496);
            expected[3] = new Point2d(2.8, 1.504);
            expected[4] = new Point2d(3.4, 1.608);
            expected[5] = new Point2d(4, 2);
            for (var i = 0; i < 6; i++)
            {
                Assert.IsTrue(Point2d.Abs(expected[i] - result[i]) < 0.0001d);
            }
        }