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