




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、貴州大學(xué)實驗報告學(xué)院:計算機科學(xué)與技術(shù) 專業(yè): 計算機科學(xué)與技術(shù) 班級:計科131姓名學(xué)號實驗組實驗時間指導(dǎo)教師黃初華成績實驗項目名稱圖形變換實驗?zāi)康膶嶒災(zāi)康耐ㄟ^本實驗,使學(xué)生了解并掌握在光柵顯示系統(tǒng)中直線的生成和顯示算法,熟悉相關(guān)開發(fā)平臺。為后繼實驗打下基礎(chǔ)。實驗要求對于設(shè)計性實驗,應(yīng)根據(jù)“由學(xué)生自行設(shè)計實驗方案并加以實現(xiàn)的實驗”內(nèi)涵要求,注意省略由學(xué)生自主設(shè)計的“實驗方案”。根據(jù)本實驗的特點、要求和具體條件,采用“以學(xué)生自主訓(xùn)練為主的開放模式組織教學(xué),還是采用集中授課形式”,須加以明確。實驗原理標(biāo)準(zhǔn)齊次坐標(biāo)(x,y,1) 二維變換的矩陣表示平移變換旋轉(zhuǎn)變換放縮變換l 平移變換只改變圖形的位
2、置,不改變圖形的大小。l 旋轉(zhuǎn)變換不改變圖形的形狀l 放縮變換引起圖形形狀的變化。復(fù)合變換結(jié)果與變換的順序有關(guān)(矩陣乘法不可交換實驗環(huán)境硬件平臺:PC軟件(推薦):Windows平臺,Visual stdio2013,openGL實驗步驟實驗步驟1. 掌握算法原理;2. 依據(jù)算法,編寫源程序并進行調(diào)試;3. 對運行結(jié)果進行保存與分析;4. 把源程序以文件的形式提交;5. 按格式書寫實驗報告。實驗內(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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權(quán)】 ISO 21384-4:2025 EN Uncrewed aircraft systems - Part 4: Vocabulary
- 【正版授權(quán)】 IEC 60974-4:2025 EN-FR Arc welding equipment - Part 4: Periodic inspection and testing
- 【正版授權(quán)】 ISO/IEC 25422:2025 EN Information technology - 3D Manufacturing Format (3MF) specification suite
- 【正版授權(quán)】 ISO/IEC TR 14143-3:2003 EN Information technology - Software measurement - Functional size measurement - Part 3: Verification of functional size measurement methods
- 【正版授權(quán)】 IEC 61156-11:2023/AMD1:2025 EN Amendment 1 - Multicore and symmetrical pair/quad cables for digital communications - Part 11: Symmetrical single pair cables with transmissio
- 2025至2030中國電窯行業(yè)產(chǎn)業(yè)運行態(tài)勢及投資規(guī)劃深度研究報告
- 2025至2030中國電池螺帽扳手行業(yè)產(chǎn)業(yè)運行態(tài)勢及投資規(guī)劃深度研究報告
- 2025至2030中國電動摩托車產(chǎn)業(yè)行業(yè)市場占有率及投資前景評估規(guī)劃報告
- 2025至2030中國豬飼料預(yù)混料行業(yè)產(chǎn)業(yè)運行態(tài)勢及投資規(guī)劃深度研究報告
- 2025至2030中國物流金融行業(yè)市場發(fā)展現(xiàn)狀分析及發(fā)展趨勢與投資前景報告
- 福建漳州安然燃氣有限公司招聘筆試題庫2025
- 2025年天津市中考歷史試卷(含答案)
- 2025年中國汽車檢測行業(yè)市場調(diào)查研究及投資前景預(yù)測報告
- 2025秋初升高銜接新高一物理模擬卷-分班模擬卷(五)
- 公司年終答謝宴策劃方案
- T/CIES 035-2024生鮮食用農(nóng)產(chǎn)品照明光源顯色性規(guī)范
- 充電站可行性研究報告
- 湖北中考英語真題單選題100道及答案
- 母嬰店轉(zhuǎn)讓協(xié)議書范本
- 2025-2030中國醫(yī)療IT行業(yè)市場深度調(diào)研及競爭格局與投資研究報告
- 2025-2030中國高超音速技術(shù)行業(yè)市場發(fā)展趨勢與前景展望戰(zhàn)略研究報告
評論
0/150
提交評論