def lengraph(figno):
    if figno in (1, 2):
        eps_prologue(15, 47, 585, 543)
	th0, th1 = pi / 2, pi / 2
	yscale = 900
	ytic = .05
	ymax = 10
    elif figno == 3:
        eps_prologue(15, 47, 585, 592)
	th0, th1 = pi / 3, pi / 3
	yscale = 500
	ytic = .1
	ymax = 10
    x0 = 42
    xscale = 7.5 * 72
    y0 = 72
    print '/Times-Roman 12 selectfont'
    print '/ss 1.5 def'
    print '/circle { ss 0 moveto currentpoint exch ss sub exch ss 0 360 arc } bind def'
    print '.5 setlinewidth'
    print x0, y0, 'moveto', xscale, '0 rlineto 0', yscale * ytic * ymax, 'rlineto', -xscale, '0 rlineto closepath stroke'
    for i in range(0, 11):
        print x0 + .1 * i * xscale, y0, 'moveto 0 6 rlineto stroke'
        print x0 + .1 * i * xscale, y0 + ytic * ymax * yscale, 'moveto 0 -6 rlineto stroke'
        print x0 + .1 * i * xscale, y0 - 12, 'moveto'
        print '(%.1g) dup stringwidth exch -.5 mul exch rmoveto show' % (.1 * i)
    for i in range(0, 11):
        print x0, y0 + ytic * i * yscale, 'moveto 6 0 rlineto stroke'
        print x0 + xscale, y0 + ytic * i * yscale, 'moveto -6 0 rlineto stroke'
        print x0 - 3, y0 + ytic * i * yscale - 3.5, 'moveto'
        print '(%.2g) dup stringwidth exch neg exch rmoveto show' % (ytic * i)
    print x0 + .25 * xscale, y0 - 24, 'moveto (chordlen / arclen) show'
    print x0 - 14, y0 + ytic * ymax * yscale + 10, 'moveto /Symbol 12 selectfont (l) show'
    if figno in (1, 2):
	print x0 + 2 / pi * xscale, y0 - 18, 'moveto'
	print '(2/p) dup stringwidth exch -.5 mul exch rmoveto show'
    print 'gsave [3] 0 setdash'
    print x0, y0 + .25 * yscale, 'moveto', xscale, '0 rlineto stroke'
    if figno == 3:
	print x0, y0 + .5 * yscale, 'moveto', xscale, '0 rlineto stroke'
	xinterest = .81153
	print x0 + xinterest * xscale, y0, 'moveto 0', yscale * .5, 'rlineto stroke'
    print 'grestore'
    print '.75 setlinewidth'
    if 1:
	if figno in (1, 2):
	    costscale = .01 * yscale
	elif figno == 3:
	    costscale = .0187 * yscale
        lenresult = lenplot(figno, th0, th1)
        cmd = 'moveto'
        for x, y, cost in lenresult:
            print x0 + xscale * x, y0 + yscale * y, cmd
            cmd = 'lineto'
        print 'stroke'
	if figno in (2, 3):
            cmd = 'moveto'
            for x, y, cost in lenresult:
                print x0 + xscale * x, y0 + costscale * cost, cmd
                cmd = 'lineto'
            print 'stroke'
            cmd = 'moveto'
            for x, y, cost in lenresult:
                print x0 + xscale * x, y0 + costscale * x * cost, cmd
                cmd = 'lineto'
            print 'stroke'
            print '/Times-Roman 12 selectfont'
	    if figno == 2:
		xlm, ylm = .75, 7
		xls, yls = .42, 15
	    elif figno == 3:
		xlm, ylm = .6, 3
		xls, yls = .37, 15
            print x0 + xscale * xlm, y0 + costscale * ylm, 'moveto'
            print '(MEC cost) show'
            print x0 + xscale * xls, y0 + costscale * yls, 'moveto'
            print '(SIMEC cost) show'
    if figno == 1:
        minis = [(.05, 5, -5),
             (.26, -40, 10),
             (.4569466, -5, -10),
             (.55, 35, 12),
             
             (.6026, -60, 45),
             (.6046, -60, 15),
             (.6066, -60, -15),
             
             (.6213, -22, 10),
             (.6366198, 15, 22),
             (.66, 20, 10),
             (.9, 0, -10)]
    elif figno == 2:
        minis = [(.4569466, -5, -10),
             (.6366198, 15, 22)]
    elif figno == 3:
	minis = [(.741, 55, -10),
		 (.81153, -30, 20),
		 (.8270, 20, 30)]

    for yy, xo, yo in minis:
	fnl = mk_y_fnl(th0, th1, yy)
	params = solve_mec_3constr(fnl)
	k, lam1, lam2 = params
        if lam2 < 0:
            mymaxk = k
        else:
            mymaxk = sqrt(k * k + 4 * lam2)
        lam = abs(lam2) / (mymaxk * mymaxk)
        x = x0 + xscale * yy
        y = y0 + yscale * lam
	print 'gsave %g %g translate circle fill' % (x, y)
        print '%g %g translate 0.15 dup scale' % (xo, yo)
        print '-306 -396 translate'
        print '2 setlinewidth'
        if yy < .6 or yy > .61:
            s = 2
        elif yy == .6046:
            s = 2.8
        else:
            s = 5
	xys, cost, x, y, th = run_elastica(-s, s, k, lam1, lam2, 100)
        print 'gsave [10] 0 setdash'
	plot(xys)
        print 'grestore 6 setlinewidth'
	xys, cost, x, y, th = run_elastica(-.5, .5, k, lam1, lam2, 100)
	plot(xys)
	print 'grestore'
        
    print 'showpage'
    eps_trailer()
dataset/ETHPy150Open google/roboto/third_party/spiro/curves/mecsolve.py/lengraph/original