问个 Bezier 曲线问题 问题如下:已知六个点的坐标,怎样使用 Bezier 曲线将它们光滑的连接起来,要求输出的曲线的光滑度可以指定 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下列代码可以求出你要的曲线上的点,包含在 pPoints 中,其中 P1 - P4 为你输入的六个点,nCount 为你给定的曲线的光滑程度,nCount 越多越光滑:BOOL MakeBezier(const POINT * P1, const POINT * P2, const POINT * P3, const POINT * P4, const POINT * P5, const POINT * P6, int nCount, POINT * pPoints){ if(P1 == NULL || P2 == NULL || P3 == NULL || P4 == NULL || P5 == NULL || P6 == NULL || nCount < 3 || pPoints == NULL) return FALSE; pPoints[0].x = P1->x; pPoints[0].y = P1->y; pPoints[nCount-1].x = P6->x; pPoints[nCount-1].y = P6->y; double t_step = (double)1 / (nCount - 1); double t = t_step; for(int i=1; i<nCount-1; i++, t+=t_step) { double s = 1-t; double d0 = s * s * s * s * s; double d1 = 5 * t * ( s * s * s * s ); double d2 = 10 * t * t * ( s * s * s ); double d3 = 10 * t * t * t * ( s * s ); double d4 = 5 * t * t * t * t * s; double d5 = t * t * t * t * t; double X = d0 * P1->x + d1 * P2->x + d2 * P3->x + d3 * P4->x + d4 * P5->x + d5 * P6->x; double Y = d0 * P1->y + d1 * P2->y + d2 * P3->y + d3 * P4->y + d4 * P5->y + d5 * P6->y; pPoints[i].x = (int)X; pPoints[i].y = (int)Y; } return TRUE;} 好,问题解决,谢谢dzmsoft(天上的星星) ! 关于picture控件载入图片问题 在视图中绘制了多个位图,如何确定选择的是哪个位图,并对它如何操作 求助:SDK 自绘按钮WM_LBUTTONDOWN 消息怎么获取 请问我有错吗,创建线程时,结构体参数传递错误??? 可指定完整路径,逐字节读文件的类是?? 想要加入一段代码,使得程序在一台机器上只能运行一个月!怎么弄啊? 求圆形的BMP图片按扭(BUTTON)的MFC源代码 各位,帮帮我,我不明白为什么我的窗体使用了MSFLEXGRID控件,就不能打开呢? 寻求电子版书籍! VC中怎么获得当前窗口句柄 如何反注册一个COM组件? 很奇怪,我写的ATL服务程序竟然只有.ex
const POINT * P2,
const POINT * P3,
const POINT * P4,
const POINT * P5,
const POINT * P6,
int nCount,
POINT * pPoints)
{
if(P1 == NULL || P2 == NULL ||
P3 == NULL || P4 == NULL ||
P5 == NULL || P6 == NULL ||
nCount < 3 || pPoints == NULL)
return FALSE; pPoints[0].x = P1->x;
pPoints[0].y = P1->y;
pPoints[nCount-1].x = P6->x;
pPoints[nCount-1].y = P6->y; double t_step = (double)1 / (nCount - 1);
double t = t_step; for(int i=1; i<nCount-1; i++, t+=t_step)
{
double s = 1-t;
double d0 = s * s * s * s * s;
double d1 = 5 * t * ( s * s * s * s );
double d2 = 10 * t * t * ( s * s * s );
double d3 = 10 * t * t * t * ( s * s );
double d4 = 5 * t * t * t * t * s;
double d5 = t * t * t * t * t; double X = d0 * P1->x +
d1 * P2->x +
d2 * P3->x +
d3 * P4->x +
d4 * P5->x +
d5 * P6->x;
double Y = d0 * P1->y +
d1 * P2->y +
d2 * P3->y +
d3 * P4->y +
d4 * P5->y +
d5 * P6->y; pPoints[i].x = (int)X;
pPoints[i].y = (int)Y;
} return TRUE;
}