【正文】
lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB)。 // select and realize our palette hPal = SelectPalette(hDC, hPal, FALSE)。 = 0。 else if (biBits = 8) biBits = 8。 // bits per pixel // check if bitmap handle is valid if (!hBitmap) return NULL。 // return handle to the bitmap return hBitmap。 nWidth = nX2 nX。 nX2 = lpRectright。 // coordinates of rectangle to grab int nWidth, nHeight。 // get the current palette hPalette = GetSystemPalette()。 lpRectbottom = 。 = lpRectbottom。 HANDLE hDib = (GetSafeHwnd(), NowRect)。 2, 位圖的復(fù)制和剪切。然后需要確定當(dāng)前客戶區(qū)域的大小,而這個(gè)可以使用函數(shù) void GetClientRect( LPRECT lpRect ) const。 如果 i 1000? , 結(jié)束循環(huán)。 最后一個(gè)重要的影響因素是初始值 , 典型的初始值 X 和 Y 在 20和 20 之間 。 且 每 個(gè) 格 子 的 初 始 狀 態(tài) 均 為 0 ,即 F(x,y)=0 ,設(shè)0 0 0 0/ 2 , / 2 , ( , ) 1x a y a F x y? ? ?,將此網(wǎng)格的中心部分 00( , )xy 點(diǎn)為中心,將 00( , )xy以 外的點(diǎn)分成若干層次,緊靠 00( , )xy 的 8 個(gè)點(diǎn)為第一層,緊靠第一層外面的 16點(diǎn) 為第二層,緊靠第二層外面的 24 個(gè)點(diǎn)為第三層,以此類推,一直到最外面一層。又因?yàn)樘右輹r(shí)間算法繪制 Julia 集和繪制 Mandelbrot 集的步驟都是一樣的,差別只體現(xiàn)在步驟 ○ 3 ,即由 ( , )nnxy 計(jì)算出 11( , )nnxy??這一步。m a x m a x m a x****p p x pq q x qp p x pq p x p? ? ?? ? ?? ? ?? ? ?理學(xué)學(xué)士學(xué)位論文 第二章 分形 相關(guān) 理 論 問題 9 1 0 0 c os s i n 0 1 00 1 0 * s i n c os 0 * 0 10 0 1 0 0 1 0 0 1c os s i n ( 1 c os ) s i ns i n c os ( 1 c os ) s i n0 0 1rrrrxyxyyx????? ? ? ?? ? ? ???? ? ? ? ? ?? ? ? ? ? ???? ? ? ? ? ?? ? ? ? ? ?? ? ? ? ? ?? ? ????????? 轉(zhuǎn)換成式子如下: 39。 繞坐標(biāo)原點(diǎn)旋轉(zhuǎn)。xMa x = tm pD oub l e + x* ne w P oint .x。xM a x = xMi n + t m pDoubl e 。 ^運(yùn)算在這里表示按位異或運(yùn)算符,它 對(duì)運(yùn)算符兩邊的數(shù)字的每一個(gè)位進(jìn)行計(jì)算,如果兩個(gè)位不同的話,那么運(yùn)算結(jié)果就為 1,否則為 0。 if ((green amp。 green = k +m_nBlue。 ○ 6 讀完所有參數(shù)空間的點(diǎn)( p,q),結(jié)束循環(huán)。著色方案將在下面作詳細(xì)介紹。 Julia 集的逃逸時(shí)間算法如下: 假設(shè)繪圖窗口的寬度為 width,高度為 height。 當(dāng) 0| | 1z ? 時(shí),很顯然, z 是平面單位圓上的點(diǎn)。一方面,分形理 論推動(dòng)了計(jì)算機(jī)繪圖方法的迅速發(fā)展,使計(jì)算機(jī)在信息壓縮及模仿自然現(xiàn)象中的各種奇妙圖形發(fā)揮了重要的作用;另一方面,計(jì)算機(jī)的應(yīng)用也大大地推動(dòng)了分形理論的發(fā)展,并且由于模擬分形圖成功而展現(xiàn)出優(yōu)美的分形圖像,迅速提高了分形這門新興科學(xué)的聲望,擴(kuò)大了她的影響。分形存在于這中間區(qū)域。 在某些電化學(xué)反應(yīng)中,電極附近成績(jī)的固態(tài)物質(zhì),以不規(guī)則的樹枝形狀向外增長(zhǎng)。曼德勃羅想 用此詞來描述自然界中傳統(tǒng)歐氏幾何不能描述的一大類復(fù)雜不規(guī)則的幾何對(duì)象,例如,曲折的海岸線,起伏的山脈,變幻的浮云,縱橫的血管等,它們有一個(gè)共同的特點(diǎn)就是極不規(guī)則或極不光滑,直觀而粗略地說,這些對(duì)象都是分形。t be defined exactly. Say in a simple way, if one part of an object is affine with another part of this, we can say this object is a fractal. From 1975 Benoit Mandelbrot published his works Fractal: Form, Chance and Dimension, the theory of fractal is wildly used in physics, chemistry, biology, medicine, puter science etc. And this topic dedicate for the use of fractal theory in puter. Because the beauty of the fractal picture, if drawing in a good way, you can get a perfect picture, so the picture can be used for dress, porcelain, and so on. This topic point of the escaping time algorithm is the main way of drawing the fractal picture, but also show a new way to render the fractal picture in detail, it can give the picture more smoothly color change, thereby it give the picture more aesthetic feeling. Further, this topic explain the use of puter graphics theory in the fractal picture39。 因?yàn)榉中螆D形有極強(qiáng)的藝術(shù)性,繪制得當(dāng),可以產(chǎn)生非常漂亮的圖片,因此可以用于裝飾,包裝,服裝等需要藝術(shù)圖案的場(chǎng)所。分形已經(jīng)廣泛應(yīng)用于物理、化學(xué)、生物、醫(yī)學(xué)、計(jì)算機(jī)科學(xué)等諸多領(lǐng)域,而本文著眼于分形理論與計(jì)算機(jī)知識(shí)的結(jié)合。 關(guān)鍵詞 :分形,矢量變換, Julia 集, Mandelbrot 集 ,逃逸時(shí)間算法 理學(xué)學(xué)士學(xué)位論文 A b s t r a c t IV ABSTRACT Fractal is a geometrical subject. It studies a subset of Euclidean geometry and can39。這個(gè)詞意為不規(guī)則的,破碎的,分?jǐn)?shù)的。這種布朗粒子軌跡的分維是 2,大大高于它的拓?fù)渚S數(shù) 1。大小兩端都受到一定特征尺度的限制,中間有三個(gè)數(shù)量級(jí)的無標(biāo)度區(qū)。分形幾何與計(jì)算機(jī)科學(xué)的結(jié)合就是一個(gè)明顯的例證。 當(dāng) 0| | 1z ? 時(shí),通過上面的計(jì)算,可以得知,此時(shí) z 會(huì)趨向于 ? 。 圖 逃逸時(shí)間算法繪制 Julia 集與 Mandelbrot 集 1, 從逃逸時(shí)間算法的角度來看, Julia 集的內(nèi)部收斂于某一個(gè)點(diǎn)或者幾個(gè)點(diǎn),而 Julia 集的外部隨著逃逸時(shí)間 t 的增加將發(fā)散至 ?,其逃逸邊界就是 Julia集。 ○ 5 對(duì)點(diǎn) ( , )xynn 著色, 并轉(zhuǎn)至下一步,再頭從做步驟 ○ 2 。 ○ 5 對(duì)點(diǎn) ( , )pqnn著色,轉(zhuǎn)至 下一點(diǎn),步驟 ○ 1 。 red = k + m_nGreen。 0x1FF) 0xFF) red = red ^ 0x1FF。運(yùn)算在這里表示按位與運(yùn)算符,它對(duì)運(yùn)算符兩邊的數(shù)字的每一個(gè)位進(jìn)行計(jì)算,如果兩個(gè)位都為 1 的話,那么運(yùn)算結(jié)果就為 1,否則為 0。那么就可以得到如下式子: t m pDoubl e = xMa x xMi nxM i n = xMi n x * ( ne wP oi nt .x ol dP oi nt .x) 。已知 m a x m i n( ) /( 1 )x x x w id th? ? ? ?,m a x m in( ) /( 1 )y y y h e igh t? ? ? ?, min *tp p x p? ? ?, min *tq q y q? ? ? ,其中0,1, 2.. . 1txn??, 0,1, 2... 1tyn??,可以得出: minmin**p p x pq q y q? ? ?? ? ? 從而可得: 用計(jì)算機(jī)語言來描述就是: xMin = xMin + x* ol dP oint .x。 3, Julia 集的旋轉(zhuǎn): 由計(jì)算機(jī)圖形學(xué)可知,在二維平面上按指定位置 rr(x,y) 旋轉(zhuǎn),需要經(jīng)過三個(gè)步驟: 平移對(duì)象使移動(dòng)點(diǎn)位置移到坐標(biāo)原點(diǎn)。39。 4, 將 Julia 集壓縮到 Mandelbrot 集的收斂區(qū)域,要將 Julia 集壓縮到Mandelbrot 集收斂區(qū)域中, 需要先對(duì)前面繪制 Julia 集算法中提到的 ( , )nnxy進(jìn)行 Mandelbrot 集算法變換,然后再進(jìn)行 Julia 集算法變換。為了使用二維元胞自動(dòng)機(jī)繪圖,假定有一個(gè) aa? 的網(wǎng)絡(luò),其左上角的格子為( 0,0),右下角的格子為( a1,a1),這樣主要是為了對(duì)應(yīng)計(jì)算機(jī)的屏幕坐 標(biāo) 。 如果 b 有一個(gè)輕微增長(zhǎng)到 , 軌跡會(huì)膨脹 , 或者螺旋向外至無限 ; 如果 b 有一個(gè)輕微的減小 , 比如 , 那么軌跡會(huì)收縮至奇異吸引子 (The attractor points)。 ○ 3 如果 i1000, 對(duì)點(diǎn) (x*20,y*20)著色,返回步驟 ○ 2 。得到。 ○ 3 將位圖保存到磁盤,這個(gè)操作比較簡(jiǎn)單,創(chuàng)建一個(gè)使用用戶輸入的文件名的文件,然后將圖形寫入文件即可。NowRect)。 = lpRectright。 lpRectright = 。 // check for a valid bitmap handle if (!hBitmap) return NULL。 // handles to deicedependent bitmaps int nX, nY, nX2, nY2。 nY = lpRecttop。 if (nY2 yScrn) nY2 = yScrn。 DeleteDC(hMemDC)。 // handle to DC WORD biBits。 else if (biBits = 4) biBits = 4。 = BI_RGB。 // get a DC hDC = GetDC(NULL)。 return NULL。bi) + 。 } // lock memory block and get pointer to it */ lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB)。 // clean up GlobalUnlock(hDIB)。 // file handle for opened file DWORD dwDIBSize。 } // Check to see if we39。 // Now calculate the size of the image // It39。t we // fill in the biSizeImage field (this will fix any .BMP files which // have this field incorrect). lpBIbiSizeImage = dwBmBitsSize。dwWritten, NULL)。 程序概況 本程序共分為以下四個(gè)主菜單: 1, 文件:主要是有關(guān)文件的