1. 碗状模型数学公式;
step = 2;
R=i*step
x=R * sin(theta),
y=R* cos(theta)
z=pow((R-0.7*R),1.5)
2. OpenGL 实现代码
// Called to draw scene
void drawBowlVertex(void)
{
GLfloat X, Y, Z, angle;
GLfloat fR = 0.0f;
// Clear the window with current color
glClear(GL_COLOR_BUFFER_BIT);
// Save matrix state and do the rotation
glPushMatrix();
// Rotate
glRotatef(xRot, 0.2f, 0.0f, 0.0f);
glRotatef(yRot, 0.0f, 0.0f, 0.0f);
glPointSize(2.f);
glBegin(GL_POINTS);
float stepx = 4.0f;
int n = 10;
int thresh = 0.7 * n;
for (int i = 0; i < n;i++)
{
fR = stepx*i;
if (i < thresh)
{
Z = 0.0f;
}
else
{
Z = -pow(stepx * (i - thresh),1.5);
}
for (angle = 0.0f; angle <= 2.0f * PI; angle += 0.1f) // 5圈
{
X = fR * sin(angle);
Y = fR * cos(angle);
glVertex3f(X, Y, Z);
}
}
glEnd();
// restore transformations
glPopMatrix();
// Flush drawing commands
glFlush();
}
3. 效果如下:


1万+

被折叠的 条评论
为什么被折叠?



