绘制二次曲线

Pav*_*sky 0 c# system.drawing gdi+ quadratic

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

Dan*_*den 5

你想得出这样进了二次曲线通过 3个给定的点,或者你想画一个二次贝塞尔曲线使用 3点给定的点?

如果你想要的是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);
}
Run Code Online (Sandbox Code Playgroud)

我只是无耻地从MSDN文档中解除了GraphicsPath.AddBeziers().

编辑:如果您真正想要的是拟合二次曲线,那么您需要对点进行曲线拟合多项式插值.也许Ask Dr. Math的这个答案会有所帮助.