def zad1(): a = 100.0 B = (0, 0) C = (a, 0) A = (a / 3, a / 2) ps = PS() ps.translate(200, 200) trojkat(ps, A, B, C) print ps.gen() with open("cevy.ps", "w") as cevy: cevy.write(ps.gen())
def zad2(): a = 100.0 B = (0, 0) C = (a, 0) A = (a / 3, a / 2) ps = PS() ps.translate(200, 200) trojkat(ps, A, B, C) trojkat2(ps, A, B, C) print ps.gen() with open("euler.ps", "w") as euler: euler.write(ps.gen())
def podzial_odcinka(): a = 100.0 b = (a ** 2 + (a / 2) ** 2) ** 0.5 c = b - a / 2 p = PS() p.translate(200, 200) p.newpath() p.moveto(0, 0) p.rline(a, 0) p.colour(1, 0, 0) p.stroke() p.newpath() p.moveto(a, 0) p.rline(c, 0) p.colour(0, 1, 0) p.stroke() p.newpath() p.moveto(0, 0) p.rline(0, a) p.rline(a, 0) p.rline(0, -a) p.moveto(a / 2, 0) p.rline(0, a) p.colour(0, 0, 0) p.stroke() p.newpath() p.moveto(a / 2, 0) p.line(a, a) p.dash() p.colour(0, 0, 0) p.stroke() p.newpath() a2 = math.degrees(math.atan(a / (a / 2))) p.arc(a / 2, 0, b, 0, a2) p.stroke() p.setfont() p.newpath() p.moveto(-5, -10) p.text("A") p.moveto(a / 2 - 5, -10) p.text("B") p.moveto(a - 5, -10) p.text("C") p.moveto(a + c - 5, -10) p.text("D") p.moveto(a - 5, a + 5) p.text("E") print p.gen() odcinek = open("odcinek.ps", "w") odcinek.write(p.gen()) odcinek.close()
def wpisany(): a = 100.0 h = a * math.sqrt(3) / 2.0 R = h * 2.0 / 3.0 A = (0.0, 0.0) B = (a, 0) C = (a / 2, h) G = (a / 2.0, h / 3.0) D = (math.cos(math.radians(60)) * a / 2.0, math.sin(math.radians(60)) * a / 2.0) E = (B[0] + math.cos(math.radians(120)) * a / 2.0, B[1] + math.sin(math.radians(120)) * a / 2.0) Fx = a / 2 + math.sqrt(R ** 2 - (D[0] - G[1] ) ** 2) - 1 F = (Fx, D[1]) p = PS() p.translate(200, 200) p.setfont() p.moveto(0, 0) p.line(*B) p.line(*C) p.line(*A) p.stroke() p.arc(G[0], G[1], R, 0, 360) p.stroke() p.arc(G[0], G[1], 0.1, 0, 360) p.stroke() p.colour(1, 0, 0) p.moveto(*D) p.line(*E) p.stroke() p.colour(0, 1, 0) p.moveto(*E) p.line(*F) p.stroke() p.colour(0, 0, 0) p.moveto(*A) p.rmoveto(-10, -10) p.text("A") p.moveto(*B) p.rmoveto(5, -10) p.text("B") p.moveto(*C) p.rmoveto(0, 5) p.text("C") p.moveto(*D) p.rmoveto(5, -10) p.text("D") p.moveto(*E) p.rmoveto(-10, -10) p.text("E") p.moveto(*F) p.rmoveto(-10, -10) p.text("F") print p.gen() with open("wpisany.ps", "w") as wpisany: wpisany.write(p.gen())
def pole(a, b, c): return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]) n = int(raw_input("POdaj liczbe wierzcholkow: ")) w = [] for i in range(n): tmp = raw_input("Podaj w%d w formacie x,y np: 6,8: ") tmp = tmp.split(',') print tmp w.append((float(tmp[0].strip()), float(tmp[1].strip()))) suma = 0 for i in range(n - 1): suma += pole(w[0], w[i], w[i + 1]) suma /= 2.0 print suma p = PS() p.setfont() p.translate(200, 200) p.newpath() p.moveto(*w[0]) for i in w: p.line(*i) p.line(*w[0]) p.stroke() p.moveto(0,-50) p.text("Pole = %f" % suma) with open("pole.ps", "w") as pole: pole.write(p.gen())
b+= math.pi * 2 print math.degrees(a), math.degrees(b) #while not stos[-3][1] <= stos[-2][1] and not stos[-2][1] <= stos[-1][1]: if a<b: print "Usuwam", stos[-2] del(stos[-2]) print "" print "****" pprint(stos) factor = 15 p = PS() p.setfont() p.translate(200, 200) for i in pkt: p.newpath() p.arc(factor * i[0], factor * i[1], 2, 0, 360) p.stroke() p.newpath() print stos[0][0][0] p.moveto(factor * stos[0][0][0], factor * stos[0][0][1]) for i in stos[1:]: i = i[0] p.line(factor * i[0], factor * i[1]) p.stroke()