如何使用 C# System.Drawing 命名空间通过 3 个点绘制二次曲线?
问问题
4696 次
1 回答
5
你想画一条通过三个给定点的二次曲线,还是想画一条使用三个给定点的二次贝塞尔曲线?
如果你想要的是贝塞尔曲线,试试这个:
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 回答