绘制二次曲线

时间:2009-09-19 03:41:01

标签: c# gdi+ system.drawing quadratic

如何使用C#System.Drawing命名空间绘制通过3个点的二次曲线?

1 个答案:

答案 0 :(得分:5)

你想绘制一个二次曲线,该曲线是三个给定点,或者你想绘制使用三个给定点的quadratic Bézier curve

如果你想要的是Bézier曲线,试试这个:

private void AddBeziersExample(PaintEventArgs e)
{

    // Adds a Bezier curve.
    Point[] myArray =
             {
                 new Point(100, 50),
                 new Point(120, 150),
                 new Point(140, 100)
             };

    // Create the path and add the curves.
    GraphicsPath myPath = new GraphicsPath();
    myPath.AddBeziers(myArray);

    // Draw the path to the screen.
    Pen myPen = new Pen(Color.Black, 2);
    e.Graphics.DrawPath(myPen, myPath);
}

我只是从GraphicsPath.AddBeziers() {{1}}无耻地解除了。

修改:如果你真正想要的是拟合二次曲线,那么你需要对你的点进行MSDN documentationcurve fitting。也许polynomial interpolation会有所帮助。

相关问题