本文主要是介绍C#,计算几何,二维贝塞尔拟合曲线(Bézier Curve)参数点的计算代码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Pierre Bézier
Bézier 算法用于曲线的拟合与插值。
插值是一个或一组函数计算的数值完全经过给定的点。
拟合是一个或一组函数计算的数值尽量路过给定的点。
这里给出 二维 Bézier 曲线拟合的参数点计算代码。
区别于另外一种读音接近的贝塞耳插值算法(Bessel's interpolation)哈!德国,法国。
1 文本格式
class Point
{
double X;
double Y;
}
public Point GetBezierPoint(double t, Point p0, Point p1, Point p2, Point
p3)
{
double cx = 3 * (p1.X - p0.X);
double bx = 3 * (p2.X - p1.X) - cx;
double ax = p3.X - p0.X - cx - bx;
double cy = 3 * (p1.Y - p0.Y);
double by = 3 * (p2.Y - p1.Y) - cy;
double ay = p3.Y - p0.Y - cy - by;
double tCubed = t * t * t;
double tSquared = t * t;
double resultX = (ax * tCubed) + (bx * tSquared) + (cx * t) + p0.X;
double resultY = (ay * tCubed) + (by * tSquared) + (cy * t) + p0.Y;
return new Point((int)resultX, (int)resultY);
}
——————————————————————
POWER BY 315SOFT.COM &
TRUFFER.CN
2 代码格式
class Point
{double X;double Y;
}public Point GetBezierPoint(double t, Point p0, Point p1, Point p2, Point
p3)
{double cx = 3 * (p1.X - p0.X);double bx = 3 * (p2.X - p1.X) - cx;double ax = p3.X - p0.X - cx - bx;double cy = 3 * (p1.Y - p0.Y);double by = 3 * (p2.Y - p1.Y) - cy;double ay = p3.Y - p0.Y - cy - by;double tCubed = t * t * t;double tSquared = t * t;double resultX = (ax * tCubed) + (bx * tSquared) + (cx * t) + p0.X;double resultY = (ay * tCubed) + (by * tSquared) + (cy * t) + p0.Y;return new Point((int)resultX, (int)resultY);
}
这篇关于C#,计算几何,二维贝塞尔拟合曲线(Bézier Curve)参数点的计算代码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!