資源簡介
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? 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? 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語言課程設計——超市商品庫存管理系統
評論
共有 條評論