Fill set of chaotic Fragment

Source: Internet
Author: User

A feature of generating an image through fragment is: writing an algorithm instead of generating any image, but generating an image or an algorithm. In short, when you write this algorithm or set relevant parameters, you can hardly guess what the image will look like. However, the image generation takes a long time and the parameters cannot be adjusted in real time. So I used the filling set method to calculate a small number of vertices first to display the approximate contour of the image. Confirm the parameters before generating the image. The so-called filling set is to randomly generate vertex positions. When the requirements are met, the vertex is retained; otherwise, the vertex is removed. Here we will fill in the set method to generate the Julia set, the mandeforo set and the Newton Iteration set.

(1) Julia set

// Fill Julia set // http://www.douban.com/note/230496472/class juliaset2: Public fractalequation {public: juliaset2 () {m_startx = 0.0f; m_starty = 0.0f; m_startz = 0.0f; m_parama = 0.11f; m_paramb = 0.615f; m_niteratecount = 80;} void iteratevalue (float X, float y, float Z, float & outx, float & outy, float & outz) const {x = outx = yf_rand_real (-1.0f, 1.0f); y = outy = yf_rand_real (-1.0f, 1.0f); float lengthsqr; float temp; int COUNT = 0; do {temp = x * x-y * Y + m_parama; y = 2 * x * Y + m_paramb; X = temp; lengthsqr = x * x + y * Y; count ++ ;}while (lengthsqr <4.0f) & (count <m_niteratecount); If (lengthsqr> 4.0f) {outx = 0.0f; outy = 0.0f;} outz = z;} bool isvalidparama () const {return true ;} bool isvalidparamb () const {return true;} PRIVATE: int m_niteratecount ;};

(2) Mandalay collection

// Mandalay collection // http://www.cnblogs.com/Ninputer/archive/2009/11/24/1609364.htmlclass mandelbrotset: Public fractalequation {public: sums () {m_startx = 0.0f; m_starty = 0.0f; m_startz = 0.0f; m_parama =-1.5f; m_paramb = 1.0f; m_paramc =-1.0f; m_paramd = 1.0f; m_niteratecount = 100;} void iteratevalue (float X, float y, float Z, float & outx, float & outy, float & outz) const {float Cr = m_parama + (m_paramb-m_parama) * (float) rand ()/rand_max); float CI = m_paramc + (m_paramd-m_paramc) * (float) rand ()/rand_max); outx = 0.0f; outy = 0.0f; float lengthsqr; float temp; int COUNT = 0; do {temp = outx * outx-outy * outy + CR; outy = 2 * outx * outy + ci; outx = temp; lengthsqr = outx * outx + outy * outy; count ++;} while (lengthsqr <4.0f) & (count <m_niteratecount); If (lengthsqr <4.0f) {outx = CR; outy = CI;} else {outx = 0.0f; outy = 0.0f ;} outz = z;} bool isvalidparama () const {return true;} bool isvalidparamb () const {return true;} bool isvalidparamc () const {return true;} bool isvalidparamd () const {return true;} PRIVATE: int m_niteratecount ;};

(3) Newton Iteration set

// Newton Iteration // http://www.douban.com/note/230496472/class newtoniterate: Public fractalequation {public: newtoniterate () {m_startx = 0.0f; m_starty = 0.0f; m_startz = 0.0f; m_parama = 1.0f; bytes = 64 ;} void iteratevalue (float X, float y, float Z, float & outx, float & outy, float & outz) const {x = outx = yf_rand_real (-m_parama, m_parama ); y = outy = yf_rand_real (-m_parama, m_parama); float x X, YY, D, TMP; For (INT I = 0; I <m_niteratecount; I ++) {xx = x * X; YY = y * Y; D = 3.0f * (xx-yy) + 4.0f * XX * YY); If (fabsf (d) <epsilon) {d = D> 0.0f? Epsilon:-Epsilon;} TMP = x; X = 0.666667f * x + (xx-yy)/d; y = 0.666667f * Y-2.0f * TMP * Y/d ;} if (x <0.0f) {outx = 0.0f; outy = 0.0f;} outz = z;} bool isvalidparama () const {return true;} PRIVATE: int m_niteratecount ;};

 

(4)

For the definition of the base class fractalequation, see chaos and fractal.

Several more images:

 

--

Fill set of chaotic Fragment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.