2009-09-19 191 views

回答

5

你想通過 3定的點來繪製去二次曲線,或者你想畫quadratic Bézier curve使用 3給定的點?

如果你想要的是一個貝塞爾曲線,試試這個:

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 documentation調高了GraphicsPath.AddBeziers()

編輯:如果你真的想要的是適合二次曲線,那麼你需要做你點curve fittingpolynomial interpolation。也許this answer from Ask Dr. Math將有所幫助。