コード例 #1
0
ファイル: polygon.py プロジェクト: gunnups/pyFormex
    def run():
        from plugins.trisurface import fillBorder
        clear()

        ## layout(3,2)
        ## for i in range(2):
        ##     viewport(i)
        ##     clear()
        ##     smoothwire()

        ans = ask("Read curve or create random?", ["Read", "Random", "Cancel"])

        PL = None
        if ans == "Random":
            PL = randomPL(n=5, r=0.7, noise=0.0)
        elif ans == "Read":
            PL = readPL()

        if PL is None:
            return

        PG = Polygon(PL.coords).reverse()
        X = PG.coords
        #drawNumbers(X)
        draw(PL, color=cyan, linewidth=3)

        v = normalize(PG.vectors())
        #drawVectors(PG.coords,v,color=red,linewidth=2)

        a = PG.angles()
        ae = PG.externalAngles()
        ai = PG.internalAngles()

        print("Direction angles:", a)
        print("External angles:", ae)
        print("Internal angles:", ai)

        print("Sum of external angles: ", ae.sum())
        print("The polygon is convex: %s" % PG.isConvex())

        ## viewport(2)
        S = PG.fill()
        draw(S, color=red)
        #drawNumbers(S)
        drawText(S.check(), 100, 20)
コード例 #2
0
ファイル: polygon.py プロジェクト: dladd/pyFormex
    def run():
        from plugins.trisurface import fillBorder
        clear()

        ## layout(3,2)
        ## for i in range(2):
        ##     viewport(i)
        ##     clear()
        ##     smoothwire()

        ans = ask("Read curve or create random?",["Read","Random","Cancel"])

        PL = None
        if ans == "Random":
            PL = randomPL(n=5,r=0.7,noise=0.0)
        elif ans == "Read":
            PL = readPL()

        if PL is None:
            return

        PG = Polygon(PL.coords).reverse()
        X = PG.coords
        #drawNumbers(X)
        draw(PL,color=cyan,linewidth=3)

        v = normalize(PG.vectors())
        #drawVectors(PG.coords,v,color=red,linewidth=2)

        a = PG.angles()
        ae = PG.externalAngles()
        ai = PG.internalAngles()

        print("Direction angles:", a)
        print("External angles:", ae)
        print("Internal angles:", ai)

        print("Sum of external angles: ",ae.sum())
        print("The polygon is convex: %s" % PG.isConvex())

        ## viewport(2)
        S = PG.fill()
        draw(S,color=red)
        #drawNumbers(S)
        drawText(S.check(),100,20)
コード例 #3
0
 def draw(self,*args,**kargs):
     draw(self.coords,*args,**kargs)
コード例 #4
0
def drawVectors(P, v, d=1.0, color="red"):
    v = normalize(v)
    Q = P + v
    F = connect([Formex(P), Formex(Q)])
    return draw(F, color=color, linewidth=3)
コード例 #5
0
ファイル: geometry.py プロジェクト: gunnups/pyFormex
 def draw(self,*args,**kargs):
     draw(self.coords,*args,**kargs)