The key to this is recognizing that you can think of each strand on a spiral as a combination of sine waves — one for the periodic part and one for the “depth” on the page. Once you have parameterized the problem this way, you can control every aspect of your spiral. The example below uses *
and #
to show different strands to illustrate this point. If you choose wavelengths that are not commensurate with integer values, you will get less than optimal results - but now you can play with the inputs to find what you consider the most aesthetically pleasing presentation.
from numpy import * amp = 10 length = 100 wavelength = 20 omega = (2*pi)/wavelength phi = wavelength*(0.5) X = arange(1,length) Y1 = round_(amp*(sin(omega*X) + 1)) Y2 = round_(amp*(sin(omega*X+phi) + 1)) offset = phi/2 Z1 = sin(omega*X + offset) Z2 = sin(omega*X + phi + offset) T1 = " ######### " T2 = " ********* " clen = len(T1) H = zeros((length,amp*2+clen),dtype='str') H[:,:] = " " for n,(y1,y2,z1,z2) in enumerate(zip(Y1,Y2,Z1,Z2)): H[n,y1:y1+clen] = list(T1) H[n,y2:y2+clen] = list(T2) # Overwrite if first helix is on top if z1>z2: H[n,y1:y1+clen] = list(T1) for line in H: print "".join(line)
These values give:
********* ######### ********* ######### ********* ######### ********* ######### ********* ######### ********* ######### ********* ######### ****** ######### ######### ######### **** ######### ********* ######### ********* ######### ********* ######### ********* ######### ********* ######### ********* ######### ********* ###### ********* ********* ********* #### ********* ######### ********* ######### ********* ######### ********* ######### ********* ######### ********* ######### ********* ######### ****** ######### #########
source share