0
点赞
收藏
分享

微信扫一扫

AI:人工智能关系概览—人工智能与数据挖掘/机器学习/深度学习/神经网络的概念定义与关系阐述、梳理之详细攻略(建议收藏)

灵魂跑者 2024-01-29 阅读 5

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

 

举报

相关推荐

0 条评论