diff -rc v6/Makefile v6.1/Makefile *** v6/Makefile Sun Nov 16 19:27:53 2008 --- v6.1/Makefile Wed Nov 19 02:59:21 2008 *************** *** 1,19 **** all: Pub/.copied ! VER=v6 SOURCES=makeindex.php.txt hilbert.py hilbert_test.py hilbert_pic.py \ Makefile ! DIFFS=v4_${VER}_diff.txt v5_${VER}_diff.txt PUBFILES=${SOURCES} ${DIFFS} index.html hilbert_thumb.gif hilbert_pic.pdf v4_${VER}_diff.txt: old/${VER}/.copied (cd old; diff -rc v4 ${VER} >../v4_${VER}_diff.txt; true) ! v5_${VER}_diff.txt: old/${VER}/.copied ! (cd old; diff -rc v5 ${VER} >../v5_${VER}_diff.txt; true) old/${VER}/.copied: ${SOURCES} cp ${SOURCES} old/${VER} --- 1,22 ---- all: Pub/.copied ! VERNUM=6.1 ! PREVNUM=6 ! VER=v${VERNUM} ! PREV=v${PREVNUM} SOURCES=makeindex.php.txt hilbert.py hilbert_test.py hilbert_pic.py \ Makefile ! DIFFS=v4_${VER}_diff.txt ${PREV}_${VER}_diff.txt PUBFILES=${SOURCES} ${DIFFS} index.html hilbert_thumb.gif hilbert_pic.pdf v4_${VER}_diff.txt: old/${VER}/.copied (cd old; diff -rc v4 ${VER} >../v4_${VER}_diff.txt; true) ! ${PREV}_${VER}_diff.txt: old/${VER}/.copied ! (cd old; diff -rc ${PREV} ${VER} >../${PREV}_${VER}_diff.txt; true) old/${VER}/.copied: ${SOURCES} cp ${SOURCES} old/${VER} *************** *** 26,32 **** index.html: ${SOURCES} ${DIFFS} rm -f index.html touch datefile ! php makeindex.php.txt >index.html chmod a-w index.html hilbert_pic.pdf: hilbert.py hilbert_pic.py --- 29,35 ---- index.html: ${SOURCES} ${DIFFS} rm -f index.html touch datefile ! php makeindex.php.txt ${VERNUM} >index.html chmod a-w index.html hilbert_pic.pdf: hilbert.py hilbert_pic.py diff -rc v6/hilbert_pic.py v6.1/hilbert_pic.py *** v6/hilbert_pic.py Sun Nov 16 19:27:53 2008 --- v6.1/hilbert_pic.py Wed Nov 19 02:59:21 2008 *************** *** 15,20 **** --- 15,27 ---- from hilbert import int_to_Hilbert, Hilbert_to_int + # unit_vector -- Unit vector in the same direction as ( dx, dy ), + # or (0,0) if given (0,0). + def unit_vector( dx, dy ): + d = sqrt( dx*dx + dy*dy ) + if d == 0: return 0, 0 + else: return dx / d, dy / d + def draw_hilbert_pic( c, size ): nD = 3 *************** *** 49,72 **** pt = 0+0j for d in range( 3 ): pt += stretch( xyz[d] ) * projection[d] ! return pt # Scale it... ! # NOTE: THIS MEANS LINE WIDTHS AND FONTS AREN'T IN POINTS ANY MORE. ! farcorner = project( ( size-1, size-1, size-1 ) ) ! stepsize = 6 * inch / farcorner.real c.scale( stepsize, stepsize ) point /= ( stepsize ) - prevpt = 0.+0.j # Collect 3D lines in a list: lines = [] ! prev_xyz = tuple( [0] * nD ) ! for i in range( 1, size*size*size ): pt_xyz = int_to_Hilbert( i, 3 ) lines.append( ( prev_xyz, pt_xyz ) ) prev_xyz = pt_xyz def avg_z( line ): start, end = line return( ( start[2] + end[2] ) * .5 ) --- 56,81 ---- pt = 0+0j for d in range( 3 ): pt += stretch( xyz[d] ) * projection[d] ! return ( pt.real, pt.imag ) # Scale it... ! # NOTE: THIS MEANS POINT != 1 FOR LINE WIDTHS AND FONTS. ! farcorner_x, farcorner_y = project( ( size-1, size-1, size-1 ) ) ! stepsize = 6. * inch / farcorner_x c.scale( stepsize, stepsize ) point /= ( stepsize ) # Collect 3D lines in a list: lines = [] ! prev_xyz = int_to_Hilbert( 0, 3 ) ! for i in range( 1, size ** 3 ): pt_xyz = int_to_Hilbert( i, 3 ) lines.append( ( prev_xyz, pt_xyz ) ) prev_xyz = pt_xyz + width = 48 * point / farcorner_x + shadow_width = width * 3 + def avg_z( line ): start, end = line return( ( start[2] + end[2] ) * .5 ) *************** *** 74,100 **** def highest_avg_z_first( line1, line2 ): return -cmp( avg_z( line1 ), avg_z( line2 ) ) - width = 48 * point / farcorner.real - # Display furthest-back-first, with white "shadows": lines.sort( highest_avg_z_first ) for line in lines: ! pt0 = project( line[0] ) ! pt1 = project( line[1] ) ! x0, y0 = pt0.real, pt0.imag ! x1, y1 = pt1.real, pt1.imag ! dx, dy = x1-x0, y1-y0 ! d = sqrt( dx*dx + dy*dy ) ! shadow_width = width * 3 ! if d < shadow_width * 2: ! continue ! dx, dy = dx / d, dy / d c.setLineWidth( shadow_width ) c.setStrokeColorRGB(255,255,255) - # The shadow is a little shorter than the black line: c.line( x0 + dx * shadow_width, y0 + dy * shadow_width, x1 - dx * shadow_width, y1 - dy * shadow_width ) c.setLineWidth( width ) c.setStrokeColorRGB(0,0,0) c.line( x0, y0, x1, y1 ) --- 83,102 ---- def highest_avg_z_first( line1, line2 ): return -cmp( avg_z( line1 ), avg_z( line2 ) ) # Display furthest-back-first, with white "shadows": lines.sort( highest_avg_z_first ) for line in lines: ! x0, y0 = project( line[0] ) ! x1, y1 = project( line[1] ) ! dx, dy = unit_vector( x1-x0, y1-y0 ) ! # The shadow is a little shorter than the black line: c.setLineWidth( shadow_width ) c.setStrokeColorRGB(255,255,255) c.line( x0 + dx * shadow_width, y0 + dy * shadow_width, x1 - dx * shadow_width, y1 - dy * shadow_width ) + + # Now the actual line: c.setLineWidth( width ) c.setStrokeColorRGB(0,0,0) c.line( x0, y0, x1, y1 ) diff -rc v6/makeindex.php.txt v6.1/makeindex.php.txt *** v6/makeindex.php.txt Sun Nov 16 19:27:53 2008 --- v6.1/makeindex.php.txt Wed Nov 19 02:59:21 2008 *************** *** 1,5 **** index.html ?>