资源简介
C++ 画图 茶壶
C++ 画图 茶壶
C++ 画图 茶壶
代码片段和文件信息
#include “stdlib.h“
#include
#include
#include
#define X 0
#define Y 1
#define Z 2
#define MAX 100
#ifndef M_PI
#define M_PI 3.1415926535897932384626
#endif
double degree;
typedef double Vector[3];
double DELTA = 0.01;
int LinesNum = 20;
int PointNum = 0;
GLint CUV = 10;
Vector P[MAX];
Vector O[MAX];
Vector Temp[MAX];
Vector Last[MAX];
Vector Bot[MAX];
int n;
static GLfloat theta[]={0.00.00.0};
void drawTeapotMouth17011();
void drawTeapotMouth17012();
void drawTeapotMouth17021();
void drawTeapotMouth17022();
void drawTeapotMouth16011();
void drawTeapotMouth16012();
void drawTeapotMouth15021();
void drawTeapotMouth15022();
GLfloat yrot=0.0f; // Y Rotation
int first = 1;
static GLdouble viewer[]={0.00.0-1};
int winWidth winHeight;
float angle = 0.0 axis[3] trans[3];
bool trackingMouse = false;
bool trackballMove = false;
bool isfirst = true;
bool isFill = false;
void init(void)
{
glClearColor(0.0 0.0 0.0 0.0);
//glShadeModel(GL_FLAT);
}
void binomialCoeffs(GLint nGLint * C){
GLint kj;
for (k = 0; k <= n;k ++) {
C[k] = 1;
for (j = n; j >= k +1; j --) {
C[k] *= j;
}
for (j = n - k; j >= 2; j--) {
C[k] /= j;
}
}
}
void computeBezPt(GLfloat u Vector Q[] GLint nCtrlPts Vector P[] GLint * C){
GLint kn = nCtrlPts -1;
GLfloat bezBlendFcn;
Q[0][0] = Q[0][1] = Q[0][2] = 0.0;
for (k = 0 ; k < nCtrlPts; k ++) {
bezBlendFcn = C[k] * pow(u k) * pow(1 - u n - k);
Q[0][0] += P[k][0] * bezBlendFcn;
Q[0][1] += P[k][1] * bezBlendFcn;
Q[0][2] += P[k][2] * bezBlendFcn;
}
}
void beziercommon(Vector P[] GLint nCtrlPts GLint nBezCurvePts){
Vector T;
GLfloat u;
GLint *C k;
C = new GLint [nCtrlPts];
binomialCoeffs(nCtrlPts - 1C);
for (k = 0; k < nBezCurvePts; k ++) {
u = GLfloat(k) / GLfloat(nBezCurvePts);
computeBezPt(u &T nCtrlPts P C);
Temp[PointNum + k][0] = T[2]*sin(degree) + T[0]*cos(degree);
Temp[PointNum + k][1] = T[1];
Temp[PointNum + k][2] = T[2]*cos(degree) - T[0]*sin(degree);
}
PointNum += nBezCurvePts;
delete [] C;
}
//分割
void BezierCurveSplitting(Vector P[] Vector Q[] Vector R[] int n)
{
int r i;
for(i = 0; i <= n; i ++){
R[i][X] = P[i][X];
R[i][Y] = P[i][Y];
R[i][Z] = P[i][Z];
}
Q[0][X] = R[0][X];
Q[0][Y] = R[0][Y];
Q[0][Z] = R[0][Z];
for(r = 1; r <= n; r ++){
for(i = 0; i <= n - r; i ++){
R[i][X] = (R[i][X] + R[i+1][X]) / 2.0;
R[i][Y] = (R[i][Y] + R[i+1][Y]) / 2.0;
R[i][Z] = (R[i][Z] + R[i+1][Z]) / 2.0;
}
Q[r][X] = R[0][X];
Q[r][Y] = R[0][Y];
Q[r][Z] = R[0][Z];
}
}
//求距离
double Distance(Vector P[] int n)
{ 属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 58368 2011-10-26 19:20 zgd_teapot\Debug\vc60.idb
文件 61440 2011-10-26 19:03 zgd_teapot\Debug\vc60.pdb
文件 173056 2011-10-26 16:22 zgd_teapot\Debug\zgd_teapot.bsc
文件 233528 2011-10-26 19:04 zgd_teapot\Debug\zgd_teapot.exe
文件 245240 2011-10-26 19:04 zgd_teapot\Debug\zgd_teapot.ilk
文件 53374 2011-10-26 19:04 zgd_teapot\Debug\zgd_teapot.obj
文件 404320 2011-10-26 19:03 zgd_teapot\Debug\zgd_teapot.pch
文件 508928 2011-10-26 19:04 zgd_teapot\Debug\zgd_teapot.pdb
文件 0 2011-10-26 16:22 zgd_teapot\Debug\zgd_teapot.sbr
文件 21697 2011-10-26 19:01 zgd_teapot\zgd_teapot.cpp
文件 4332 2009-10-28 15:53 zgd_teapot\zgd_teapot.dsp
文件 545 2009-10-28 14:19 zgd_teapot\zgd_teapot.dsw
文件 66560 2011-10-26 19:21 zgd_teapot\zgd_teapot.ncb
文件 53760 2011-10-26 19:21 zgd_teapot\zgd_teapot.opt
文件 1393 2011-10-26 19:04 zgd_teapot\zgd_teapot.plg
目录 0 2007-01-01 00:42 zgd_teapot\Debug
目录 0 2007-01-01 00:42 zgd_teapot
----------- --------- ---------- ----- ----
1886541 17
- 上一篇:RSA算法1024位C语言实现
- 下一篇:C语言课程设计——超市商品库存管理系统
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- Qt画图工具源码(qgraphics draw)
- c++ 多功能计算器
- C++17 In Detail
- 使用QWT库实现接收串口数据,并根据
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
川公网安备 51152502000135号
评论
共有 条评论