An algorithm is used to generate a taiji figure

Source: Internet
Author: User

A few days ago the article "100 images generated by the program", incredibly no Taiji figure, this is how classic images. Therefore, the algorithm for generating Taiji figure is specifically described in this article. I've been writing about Tai Chi before. Mathematical graphics (1.23) The Taiji line, then hoped to be able to depict the shape of the Taiji figure in a curved way, but it was not very successful. The use of images, the generation of Taiji figure is relatively easy, first on the code:

1UnsignedintCpixeltaijiyinyang::calculatepixel (unsignedintX, unsignedinty)2 {3     floatRadius1 = m_params[0];4     floatRadius2 = radius1*m_params[1];5 6     floatRR = radius1*Radius1;7 8UnsignedintBlack =0xff000000;9UnsignedintWhite =0xFFFFFFFF;TenUnsignedintGray =0xff808080; One  A     floati =512.0f-x; -     floatj =512.0f-y; -  the     if((I*i + j*j) >RR) -     { -         returnGray; -     } +  -     floatT = j + radius1*0.5f; +     floattt = t*t + i*i; A     if(TT < radius2*radius2) at     { -         returnWhite ; -     } -     Else if(TT < rr*0.25f) -     { -         returnBlack; in     } -  tot = j-radius1*0.5f; +tt = t*t + i*i; -     if(TT < radius2*radius2) the     { *         returnBlack; $     }Panax Notoginseng     Else if(TT < rr*0.25f) -     { the         returnWhite ; +     } A  the     if(I <0.0f) +     { -         returnWhite ; $     } $     Else -     { -         returnBlack; the     } -}

Again

Software: Why mathematical image Generation tool, in which the outer ring radius and inner ring radius of the Taiji figure can be adjusted in the software as shown in:

Related articles:

The beauty of the algorithm---100 images generated by the program, there is always a piece that makes you feel amazing [top]

The beauty of the algorithm---100 images generated by the program, there is always a piece that makes you feel amazing [next]

An algorithm is used to generate a taiji figure

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.