双三次bezier曲面算法c语音
时间: 2023-07-26 10:28:44 浏览: 85
MFC绘制双三次Bezier曲面DrawSewBezier.zip
5星 · 资源好评率100%
以下是一个简单的双三次Bezier曲面算法的C语言实现:
```c
#include <stdio.h>
#include <math.h>
#define MAX_CONTROL_POINTS 10
int nControlPoints; //控制点数量
int nDivisions; //细分数
float delta; //细分间隔
typedef struct tagPOINT
{
float x, y, z;
} POINT;
POINT controlPoints[MAX_CONTROL_POINTS][MAX_CONTROL_POINTS]; //控制点
POINT CalculateBezierPoint(float u, float v)
{
POINT p = {0, 0, 0};
for(int i = 0; i < nControlPoints; i++)
{
for(int j = 0; j < nControlPoints; j++)
{
float coefficient = pow(u, i) * pow(1 - u, nControlPoints - i - 1) * pow(v, j) * pow(1 - v, nControlPoints - j - 1);
p.x += coefficient * controlPoints[i][j].x;
p.y += coefficient * controlPoints[i][j].y;
p.z += coefficient * controlPoints[i][j].z;
}
}
return p;
}
void DrawBezierSurface()
{
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_QUADS);
for(int i = 0; i < nDivisions; i++)
{
阅读全文