




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、貴州大學(xué)實(shí)驗(yàn)報(bào)告學(xué)院:計(jì)算機(jī)科學(xué)與技術(shù) 專業(yè): 計(jì)算機(jī)科學(xué)與技術(shù) 班級(jí):計(jì)科131姓名學(xué)號(hào)實(shí)驗(yàn)組實(shí)驗(yàn)時(shí)間指導(dǎo)教師黃初華成績(jī)實(shí)驗(yàn)項(xiàng)目名稱圖形變換實(shí)驗(yàn)?zāi)康膶?shí)驗(yàn)?zāi)康耐ㄟ^本實(shí)驗(yàn),使學(xué)生了解并掌握在光柵顯示系統(tǒng)中直線的生成和顯示算法,熟悉相關(guān)開發(fā)平臺(tái)。為后繼實(shí)驗(yàn)打下基礎(chǔ)。實(shí)驗(yàn)要求對(duì)于設(shè)計(jì)性實(shí)驗(yàn),應(yīng)根據(jù)“由學(xué)生自行設(shè)計(jì)實(shí)驗(yàn)方案并加以實(shí)現(xiàn)的實(shí)驗(yàn)”內(nèi)涵要求,注意省略由學(xué)生自主設(shè)計(jì)的“實(shí)驗(yàn)方案”。根據(jù)本實(shí)驗(yàn)的特點(diǎn)、要求和具體條件,采用“以學(xué)生自主訓(xùn)練為主的開放模式組織教學(xué),還是采用集中授課形式”,須加以明確。實(shí)驗(yàn)原理標(biāo)準(zhǔn)齊次坐標(biāo)(x,y,1) 二維變換的矩陣表示平移變換旋轉(zhuǎn)變換放縮變換l 平移變換只改變圖形的位
2、置,不改變圖形的大小。l 旋轉(zhuǎn)變換不改變圖形的形狀l 放縮變換引起圖形形狀的變化。復(fù)合變換結(jié)果與變換的順序有關(guān)(矩陣乘法不可交換實(shí)驗(yàn)環(huán)境硬件平臺(tái):PC軟件(推薦):Windows平臺(tái),Visual stdio2013,openGL實(shí)驗(yàn)步驟實(shí)驗(yàn)步驟1. 掌握算法原理;2. 依據(jù)算法,編寫源程序并進(jìn)行調(diào)試;3. 對(duì)運(yùn)行結(jié)果進(jìn)行保存與分析;4. 把源程序以文件的形式提交;5. 按格式書寫實(shí)驗(yàn)報(bào)告。實(shí)驗(yàn)內(nèi)容#include"stdafx.h"#include <glut.h>#include <stdlib.h>#include <math.h>
3、GLsizei winWidth = 600, winHeight = 600;GLfloat xwcMin = 0.0, xwcMax = 225.0;GLfloat ywcMin = 0.0, ywcMax = 225.0;class wcPt2Dpublic:GLfloat x, y;typedef GLfloat Matrix3x333;Matrix3x3 matComposite;const GLdouble pi = 3.14159;void init(void)glClearColor(1.0, 1.0, 1.0, 0.0);void matrix3x3SetIdentity(M
4、atrix3x3 matIdent3x3)GLint row, col;for (row = 0; row<3; row+)for (col = 0; col<3; col+)matIdent3x3rowcol = (row = col);/生成1,0,00,1,00,0,1void matrix3x3PreMultiply(Matrix3x3 m1, Matrix3x3 m2)GLint row, col;Matrix3x3 matTemp;for (row = 0; row<3; row+)for (col = 0; col<3; col+)matTemprowco
5、l = m1row0 * m20col + m1row1 * m21col + m1row2 * m22col;for (row = 0; row<3; row+)for (col = 0; col<3; col+)m2rowcol = matTemprowcol;void translate2D(GLfloat tx, GLfloat ty)/平移Matrix3x3 matTransl;matrix3x3SetIdentity(matTransl);matTransl02 = tx;matTransl12 = ty;matrix3x3PreMultiply(matTransl,
6、matComposite);void rotate2D(wcPt2D pivotPt, GLfloat theta)/旋轉(zhuǎn)Matrix3x3 matRot;matrix3x3SetIdentity(matRot);matRot00 = cos(theta);matRot01 = -sin(theta);matRot02 = pivotPt.x*(1 - cos(theta) + pivotPt.y*sin(theta);matRot10 = sin(theta);matRot11 = cos(theta);matRot312 = pivotPt.x*(1 - cos(theta) - pivo
7、tPt.y*sin(theta);matrix3x3PreMultiply(matRot, matComposite);void scale2D(GLfloat sx, GLfloat sy, wcPt2D fixedPt)/縮放Matrix3x3 matScale;matrix3x3SetIdentity(matScale);matScale00 = sx;matScale02 = (1 - sx)*fixedPt.x;matScale11 = sy;matScale12 = (1 - sy)*fixedPt.y;matrix3x3PreMultiply(matScale, matCompo
8、site);void transformVerts2D(GLint nVerts, wcPt2D * verts)/組合變化后的矩陣GLint k;GLfloat temp;for (k = 0; k<nVerts; k+)temp = matComposite00 * vertsk.x + matComposite01 * vertsk.y + matComposite02;vertsk.y = matComposite10 * vertsk.x + matComposite11 * vertsk.y + matComposite12;vertsk.x = temp;void tria
9、ngle(wcPt2D*verts)GLint k;glBegin(GL_TRIANGLES);for (k = 0; k<3; k+)glVertex2f(vertsk.x, vertsk.y);glEnd();void displayFcn(void)GLint nVerts = 3;wcPt2D verts3 = 50.0, 25.0 , 150.0, 25.0 , 100.0, 100.0 ;wcPt2D centroidPt;GLint k, xSum = 0, ySum = 0;for (k = 0; k<nVerts; k+)xSum += vertsk.x;ySum
10、 += vertsk.y;centroidPt.x = GLfloat(xSum) / GLfloat(nVerts);centroidPt.y = GLfloat(ySum) / GLfloat(nVerts);wcPt2D pivPt, fixedPt;pivPt = centroidPt;fixedPt = centroidPt;GLfloat tx = 0.0, ty = 100.0;GLfloat sx = 0.5, sy = 0.5;GLdouble theta = pi / 2.0;glClear(GL_COLOR_BUFFER_BIT);glColor3f(0.0, 0.0,
11、1.0);triangle(verts);/三角形matrix3x3SetIdentity(matComposite);scale2D(sx, sy, fixedPt);/縮小transformVerts2D(nVerts, verts);glColor3f(1.0, 0.0, 0.0);triangle(verts);matrix3x3SetIdentity(matComposite);rotate2D(pivPt, theta);/旋轉(zhuǎn)90transformVerts2D(nVerts, verts); glColor3f(1.0, 0.0, 0.0);triangle(verts);ma
12、trix3x3SetIdentity(matComposite);translate2D(tx, ty);/平移transformVerts2D(nVerts, verts); glColor3f(1.0, 0.0, 0.0);triangle(verts);matrix3x3SetIdentity(matComposite);transformVerts2D(nVerts, verts);glColor3f(1.0, 0.0, 0.0);triangle(verts);glFlush();void winReshapeFcn(GLint newWidth, GLint newHeight)g
13、lMatrixMode(GL_PROJECTION);gluOrtho2D(xwcMin, xwcMax, ywcMin, ywcMax);glClear(GL_COLOR_BUFFER_BIT);void main(int argc, char* argv)glutInit(&argc, argv);glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);glutInitWindowPosition(50, 50);glutInitWindowSize(winWidth, winHeight);glutCreateWindow("Geometr
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年撫順市稅務(wù)系統(tǒng)遴選面試真題附解析含答案
- 2024年事業(yè)單位考試四川省涼山彝族自治州《公共基礎(chǔ)知識(shí)》深度預(yù)測(cè)試題含解析
- 老年人醫(yī)藥消費(fèi)行為調(diào)查分析
- 老年衛(wèi)生健康宣教課件
- 老師職業(yè)介紹
- 老師關(guān)愛留守兒童課件
- 老師介紹自己的課件
- 房地產(chǎn)開發(fā)不定期按揭貸款借款合同
- 美食廣場(chǎng)承包經(jīng)營(yíng)與品牌整合管理合同
- 美術(shù)生班會(huì)課件
- 2025年天津市中考?xì)v史試卷(含答案)
- 2025秋初升高銜接新高一物理模擬卷-分班模擬卷(五)
- 2024年上海高中學(xué)業(yè)水平合格性考試歷史試卷真題(含答案)
- 2025年人教版七年級(jí)數(shù)學(xué)下冊(cè)期末測(cè)試卷
- 公司年終答謝宴策劃方案
- 小學(xué)一年級(jí)數(shù)學(xué)下冊(cè)應(yīng)用題100道
- 安徽省馬鞍山市2023-2024學(xué)年高一下學(xué)期期末教學(xué)質(zhì)量監(jiān)測(cè)化學(xué)試卷(含解析)
- 反詐騙(企業(yè)員工)講座培訓(xùn)課件
- T/CBMCA 019-2021醫(yī)用潔凈室裝飾材料技術(shù)標(biāo)準(zhǔn)
- 2025-2030中國(guó)微晶纖維素市場(chǎng)深度評(píng)估與需求潛力分析研究報(bào)告
- 2025年社會(huì)調(diào)查方法與實(shí)踐考試試題及答案
評(píng)論
0/150
提交評(píng)論