Esempio n. 1
0
 def __init__(self):
     #super().__init__()
     #self.l=Line(Point.null(),math.pi/2+1e-1)
     self.s = Segment.createFromTuples((-1, 0), (-1, 1),
                                       color=mycolors.GREEN,
                                       width=2)
     print(self.s.angle == math.pi / 2)
     print(self.s.line.angle, self.s.line.point)
     self.p = Point.null(color=mycolors.RED, fill=True)
     self.projection = None
Esempio n. 2
0
def oldcrossSquareCircle(square, circle):
    """Determine if a square is crossing a circle."""
    p, s = square
    c, r = circle
    px, py = p
    cx, cy = c
    sg = Segment.createFromTuples(p, c)
    l = sg.length
    a = sg.angle
    #x=n*math.cos(a)
    #n=x/math.cos(a)
    if -math.pi / 4 <= abs(a) < 3 * math.pi / 4:
        n = s / (2 * math.sin(a))
    else:
        n = s / (2 * math.cos(a))
    return l - r < n
Esempio n. 3
0
                p2 = e2.cross(e1)
                if p1 or p2:
                    self.context.console(p1, p2)
                    e1.color = mycolors.RED
                    e2.color = mycolors.RED

    def rotate(self):
        for element in self.group:
            element.rotate(self.angle)

    def show(self):
        # self.group[0].showWithinCorners(self.context)
        self.square.show(self.context)
        corners = self.square.getCorners()
        #print(corners)
        for e in self.group:
            if isinstance(e, Line):
                e.showWithinCorners(self.context, [-1, -1, 2, 2])
            else:
                e.show(self.context)


if __name__ == "__main__":
    l1 = Line.random()
    l2 = Line.random()
    s = Segment.random()
    s1 = Segment.createFromTuples((-1, 0), (1, 0))
    s2 = Segment.createFromTuples((0, -1), (0, 1))
    m = AbstractTester(s, s1, s2, l1)
    m()