PGF_py.py with ZEN style.

# -*- coding: utf-8 -*-
#!/usr/bin/python

## Imports
from PGF import *
from GeoUtils import *
import itertools
import math
from Eukleides import *

dirdic = {
"s" : "north" ,
"n" : "south" ,
"w" : "east" ,
"e" : "west" ,
}

def drawnode(f,x,y,letter,myanchor="n",colour='black'):
    f.draw(node(x,y,"$%s$"%letter,anchor=dirdic[myanchor]),col=colour)

## Main Programm
def main():

    # 3 Points a,b & c:
    a = Point( 0, 1 )
    b = Point( 7, 2 )
    c = Point( 5, 6 )
    
    t = Triangle.Pt( a, b, c )
    
    g   = t.gravityCenter()
    ccc = t.circumCenter()
    h   = t.orthoCenter()
    cci = t.inscribedCenter()
    
    i_ac = Point.Projection( cci, a,c )
    i_ab = Point.Projection( cci, a,b )
    i_bc = Point.Projection( cci, b,c )

    pied_biss_ab = Point.inter(c,cci, a,b)
    pied_biss_ac = Point.inter(b,cci, a,c)
    pied_biss_bc = Point.inter(a,cci, b,c)
    
    f = figure()
    #completeGrid(f,0,0,8,7,s1=1)


    f.draw(t,fill='red!20',fopa=0.4)
    f.draw(circle(g.x,g.y,0.05),fill='blue!20',fopa=0.5)
    
    labels = (("A",'w','black'),("B",'e','black'),("C",'n','black'),("G",'s','black'),("O",'s','red'),("H",'s','black'),("I",'s','blue'))
    for pt,lab in zip((a,b,c,g,ccc,h,cci),labels) :
        f.draw(circle(pt.x,pt.y,0.05),fill='blue!20',fopa=0.8)
        drawnode(f,pt.x,pt.y,lab[0],lab[1],lab[2])
    
    for pt in (a,b,c):
        f.draw(polypoints((ccc.x,ccc.y),(pt.x,pt.y)),style='dashed',col='red')
        
    for pt in (i_ab,i_bc,i_ac):
        f.draw(polypoints((cci.x,cci.y),(pt.x,pt.y)),style='dashed',col='blue')
        
    f.draw(circle(ccc.x,ccc.y,dist(ccc,a)),col='orange',fill='orange!20',fopa=0.4)
    f.draw(circle(cci.x,cci.y,dist(cci,i_ab)),col='blue',fill='blue!20',fopa=0.2)

    # Bissectrices
    f.draw( seg(a,pied_biss_bc),col='green!80')
    f.draw( seg(b,pied_biss_ac),col='green!50')
    f.draw( seg(c,pied_biss_ab),col='green!20')

    f.end()
    f.save('kibpic')

if __name__ == "__main__":
    main()

Posted on 2012-02-25 18:01 with python in 0.060 sec.