Exemplo n.º 1
0
    def norm(self):
        """Return the angle of a vector with the [1,0] direction in cartesian coordonnates."""
        return Vector.polar([self.x, self.y])[0]

    def __xor__(self, other):
        """Return the angle between two vectors."""
        return self.angle() - other.angle()

    def __invert__(self):
        """Return the unit vector."""
        n, a = self.polar()


if __name__ == "__main__":
    window = Window("Vector")
    p1 = Point(50, 100)
    p2 = Point(500, 400)
    p3 = Point(300, 200)
    v1 = Vector(p1, p2)
    v2 = 0.8 * v1
    p4 = v2(p1)
    v2.color = (255, 0, 0)
    p4.color = (0, 255, 0)
    v1.show(p1, window)
    v2 %= 0.3
    v2.show(p1, window)
    p2.show(window)
    p4.show(window)
    window()
Exemplo n.º 2
0
 def show(self,window):
     """Show the material point on the window."""
     position=self.getPosition()
     x,y=position
     point=Point(x,y)
     point.show(window)
Exemplo n.º 3
0
        surface.control()
        surface.clear()
        surface.show()

        #Actions
        l1.rotate(0.01, p2)
        l2.rotate(-0.02, p1)
        p = l1 | l2
        o = Point(0, 0)
        p3 = l2.projectPoint(o)

        #Show
        surface.draw.window.print("l1.angle: " + str(l1.angle), (10, 10))
        surface.draw.window.print("l2.angle: " + str(l2.angle), (10, 30))

        o.show(surface, color=mycolors.GREY)
        o.showText(surface, "origin")

        p3.showText(surface, "origin's projection")
        p3.show(surface, color=mycolors.LIGHTGREY)

        if p:
            p.show(surface, color=mycolors.RED)
            p.showText(surface, "intersection point", color=mycolors.RED)

        p1.show(surface)
        p1.showText(surface, "p1")

        p2.show(surface)
        p2.showText(surface, "p2")