0
如何使用C#System.Drawing命名空間繪製二次曲線通過3個點?繪製二次曲線
如何使用C#System.Drawing命名空間繪製二次曲線通過3個點?繪製二次曲線
你想通過 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 fitting或polynomial interpolation。也許this answer from Ask Dr. Math將有所幫助。
偶然的功課? – 2009-09-19 03:52:25