不好意思没写完,再发一遍参考http://mathforum.org/library/drmath/view/54434.html由五个点(x0,y0)......(x4,y4)控制的贝赛尔曲线公式就是 x(t)= (1-t)^4*x0 +4*(1-t)^3*t*x1 +6*(1-t)^2*t^2*x2 +4*(1-t)*t^3*x3 +t^4*x4 y(t)就是把上式中的x0……x4分别对应换成y0……y4x0……前面的系数其实就是由 1=(1-t)+t 然后1^n=((1-t)+t)^n展开所得多项式的各项就是了,n是控制点的个数减一其中t取值从0到1,改变t的值就可以获得贝赛尔曲线上所有的点了吧还有Win32编程时绘制该曲线的函数原型如下: The PolyBezier function draws one or more Bézier curves. BOOL PolyBezier( HDC hdc, // handle to device context CONST POINT *lppt, // pointer to endpoints and control points DWORD cPoints // count of endpoints and control points );
不会有象画直线那样的LineToDDA调用,因为画出的贝塞尔曲线本身并不是曲线,只
是通过导出方程,设置取样间隔得到的近似,是一条折线
{
double x = 0;
double y = 0;
double x0 = (pt1.x+pt2.x)/2;
double y0 = (pt1.y+pt2.y)/2; if(pt1.y>pt2.y)
{
if(pt1.x>pt2.x)
{
x = (pt1.y-pt2.y)/2 + x0;
y = (pt2.x-pt1.x)/2 + y0;
}
else
{
x = (pt1.y-pt2.y)/2 + x0;
y = (pt2.x-pt1.x)/2 + y0;
}
}
else
{
if(pt1.x>pt2.x)
{
x = (pt1.y-pt2.y)/2 + x0;
y = (pt2.x-pt1.x)/2 + y0;
}
else
{
x = (pt1.y-pt2.y)/2 + x0;
y = (pt2.x-pt1.x)/2 + y0;
}
} middle.x = (long)x ;
middle.y = (long)y ; }
pDC->PolyBezier();
EenPath();
long lNumPoints = pDC->GetPath();
CPoint* pcPoints = new CPoint[lNumPoints];
pDC->GetPath(lNumPoints, pcPoints);
x(t)=
(1-t)^4*x0
+4*(1-t)^3*t*x1
+6*(1-t)^2*t^2*x2
+4*(1-t)*t^3*x3
+t^4*x4
y(t)就是把上式中的x0……x4分别对应换成y0……y4x0……前面的系数其实就是由
1=(1-t)+t其中t取值从0到1,改变t的值就可以获得贝赛尔曲线上所有的点了吧其中t是从0到1取值的,改变t的值就能
x(t)=
(1-t)^4*x0
+4*(1-t)^3*t*x1
+6*(1-t)^2*t^2*x2
+4*(1-t)*t^3*x3
+t^4*x4
y(t)就是把上式中的x0……x4分别对应换成y0……y4x0……前面的系数其实就是由
1=(1-t)+t
然后1^n=((1-t)+t)^n展开所得多项式的各项就是了,n是控制点的个数减一其中t取值从0到1,改变t的值就可以获得贝赛尔曲线上所有的点了吧还有Win32编程时绘制该曲线的函数原型如下:
The PolyBezier function draws one or more Bézier curves. BOOL PolyBezier(
HDC hdc, // handle to device context
CONST POINT *lppt, // pointer to endpoints and control points
DWORD cPoints // count of endpoints and control points
);