計算機圖形學實習指導_第1頁
計算機圖形學實習指導_第2頁
計算機圖形學實習指導_第3頁
計算機圖形學實習指導_第4頁
計算機圖形學實習指導_第5頁
已閱讀5頁,還剩11頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、第五章形變1 “ransMoveprivatevoidder,EventArgsID=11;um= Graphics 第五章形變1 “ransMoveprivatevoidder,EventArgsID=11;um= Graphics g = CreateGraphics();/ (100,100);/ sgroup);/成了平移變換。具體做法是在Form1_MouseClickifum=2) = ififum0)/保X= Y= else/fori=0;i4;sgroupi.X+=ififum0)/保X= Y= else/fori=0;i=2)um = 0;/ (150,1505-1(150,

2、15011 010sin 001001011 = 0sin102e11 010sin 001001011 = 0sin102e,privatevoidder,EventArgsID=12;um= Graphics g = CreateGraphics();/ ifum=2)um0;/ifID12)/旋ifum = 0)/X= Y= else/doubleif(e.XX&e.Yif(e.XX&e.Yaifum = 0)/X= Y= else/doubleif(e.XX&e.Yif(e.XX&e.Ya= elseif(e.XX&e.Ya= Y)/(double)(e.XMatrixmyMatrix

3、=new/創(chuàng)建平移量為(-x0, -y0) /a /右乘一個平移量為(x0, y0) Graphics g = CreateGraphics();/g.Transform = myMatrix;/ sgroup);/ifum=2)um = 0;/ Graphics g = CreateGraphics();/g.Transform = myMatrix;/ sgroup);/ifum=2)um = 0;/ (100,10010010001001011 = 10010001001011 = 10 101 3先建 ,(F) Form2.CS點擊解決方案欄目中Form2.CS,打開“Form2.cs

4、MyFormOKCancel publicvoidder,EventArgsxscale=yscale=publicvoidder,EventArgsxscalepublicvoidder,EventArgsxscale=yscale=publicvoidder,EventArgsxscaleyscalepublicpartialclassMyForm:privatefloatxscale,publicpublicpartialclassMyForm:privatefloatxscale,publicfloatgetreturnthis.xscale;publicfloatgetreturnt

5、his.yscale;publicpublicxscale=(float)1.0;yscale= ransScpublicpublicxscale=(float)1.0;yscale= ransScaleprivatevoidID=floatxs,der,EventArgsID =float xs,MyFormmyfnewMyForm(); /if(myf.ShowDialog()=myf.Close(); /如果選擇的是“取消”,則關閉 xs=myf.Xscale; ys=myf.Yscale; xs=myf.Xscale; ys=myf.Yscale; GraphicsgCreateGra

6、phics();/psgroup0=newP sgroup1=newP sgroup2=newxs=myf.Xscale; ys=myf.Yscale; GraphicsgCreateGraphics();/psgroup0=newP sgroup1=newP sgroup2=newsgroup3=newpMatrixmyMatrixnewMatrix();/建立矩陣變量,為計算復合矩陣做準備 myMatrix.Translate(-100, -100);/根據(jù)縮放中心,建立平移矩陣 myMatrix.Scale(xs, ys, MatrixOrder.Append);/右乘縮放矩陣 myMa

7、trix.Translate(100, 100, MatrixOrder.Append);/右乘平移矩陣g.TransformmyMatrix;/g.DrawPolygon(Pens.Blue, (X1,Y1Y11 10010 1 000(X1,Y1Y11 10010 1 0000101010 1010 = arctg = ransSymetryprivatevoidder,EventArgsID=14;um=Graphicsg=CreateGraphics();/p=Pp ifum2um0;/ID14)/ifum0)/X=Y=p=Pp ifum2um0;/ID14)/ifum0)/X=Y=G

8、raphicsg=CreateGraphics(); XXifum=2)0;/ privatevoidif(x1x2&y1y2)/排除兩點重合的情況 doubleif(x1x2&y1y2)/特殊角 angle = 3.1415926 / 2.0;elseif(x1x2&y1y2)/特殊角 angle3.1415926 / 2.0*3.0;angle=angle=angletan(double)(y2-y1)/(double)(x2-180.03.1415926/MatrixmyMatrixangle=angle=angletan(double)(y2-y1)/(double)(x2-180.0

9、3.1415926/MatrixmyMatrixnewMatrix();/myMatrix.Translate(-x1,y1);/MatrixMyM1newMatrix(1,0,0,-1,0,0);/創(chuàng) myMatrix.Translate(x1,y1,MatrixOrder.Append);/GraphicsgCreateGraphics();/g.TransformmyMatrix;/用得到的復合矩陣對圖形進行變換g.DrawPolygon(Pens.Blue, (X1,Y1將坐標系逆時針旋轉(zhuǎn)XX軸為基軸(Y軸為依賴軸)Y11 10010 1 010001010100 1 10101 10

10、010 1 010001010100 1 1010 ransShearprivatevoidder,EventArgsID=15;um=Graphicsg=CreateGraphics();/p=Pp ifum=2)um0;/if ID =ID15)/對稱變換和錯切變if um = 0)/保X= Y= Graphicsg=CreateGraphics(); Xif um = 2)um0;/完畢,清零,為下一次做準privatevoidXif um = 2)um0;/完畢,清零,為下一次做準privatevoidif(x1x2&y1y2)/排除兩點重合的情況 doubleif(x1x2&y1y2)/特殊角 angle = 3.1415926 / 2.0;elseif(x1x2&y1y2)/特殊角 angle3.1415926 / 2.0*3.0;angle=angle=angletan(double)(y2-y1)/(double)(x2-180.03.1415926/MatrixmyMatrixnewMatrix();/myMatrix.Translate(-x1,y1);/myMatrix.Shear(float1.0,0,MatrixOrder.Append);/e(floatangle,MatrixOrder.

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論