0

C# System.Drawing名前空間を使用して3点を通る二次曲線を描くにはどうすればよいですか?

4

1 に答える 1

5

与えられた 3 点を通る2 次曲線を描きたいですか、それとも与えられた 3 点を使用する2 次ベジエ曲線を描きたいですか?

ベジエ曲線が必要な場合は、これを試してください。

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);
}

のMSDN ドキュメントから恥知らずに取り上げたものですGraphicsPath.AddBeziers()

編集: 二次曲線に合わせることが本当に必要な場合は、ポイントに対して曲線フィッティングまたは多項式補間を行う必要があります。おそらく、Ask Dr. Math からのこの回答が役立つでしょう。

于 2009-09-19T03:52:21.813 に答える