The spiral of fractal

Source: Internet
Author: User

Twist a straight line into a spiral upward, and then twist the resulting spiral straight into a straight line to spiral upward so that an infinite loop is created. A fractal helix is generated.

Core code:

1 voidCfractalhelix::fractalhelix (Constvector3& Vstart,Constvector3& Vend, vector3*pvertices)2 {3Vector3 VDir = Vend-Vstart;4     floatLen = D3dxvec3length (&vDir);5     floatRadius = len*m_params[0];6 7     floatXZ = sqrtf (vdir.x*vdir.x + vdir.z*vdir.z);8     floatAngley =atan2f (XZ, vdir.y);9     floatAnglexz =atan2f (vdir.x, vdir.z);Ten  One     floatE =sin (angley); A     floatf =cos (angley); -  -     floatg =sin (anglexz); the     floath =cos (ANGLEXZ); -  -      for(inti =0; i < Circle_points_count; i++) -     { +Pvertices[i] = Vstart + vdir* (i*1.0f/circle_points_count); -  +         floatx0 =m_vsincos[i].y; A         floaty0 =-m_vsincos[i].x*e; at         floatZ0 = + m_vsincos[i].x*F; -  -         floatX1 = x0*h + z0*G; -         floatY1 =y0; -         floatZ1 =-x0*g + z0*h; -          inpvertices[i].x + = x1*radius; -Pvertices[i].y + = y1*radius; toPvertices[i].z + = z1*radius; +     } -}

The code is a little bit dizzy, in fact, it is to break a line, create a number of lines representing the curve, and then continue to iterate. But the code is a bit flawed, and some of the seams are too much too smooth.

Software:

The spiral of fractal

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.