Exemplo n.º 1
0
    def testGeometryCircle_arc_points(self):
        """arc_points() utility function"""

        def T(a,b):
            self.assert_(common.vert_equal(a,b))
        def F(a,b):
            self.assert_(not common.vert_equal(a,b))

        # test arc_points() finally
        T(arc_points(0,pi,1,1),
                (V(1,0),V(-1,0)))
        T(arc_points(pi,0,1,1),
                (V(-1,0),V(1,0)))

        # three points, note rotation is always anti-clockwise
        T(arc_points(0,pi,1,2),
                (V(1,0),V(0,1),V(-1,0)))
        T(arc_points(pi,0,1,2),
                (V(-1,0),V(0,-1),V(1,0)))

        # full circle
        T(arc_points(0,2*pi,1,4),
                (V(1,0),V(0,1),V(-1,0),V(0,-1),V(1,0)))
        T(arc_points(2*pi,0,1,4), # note same result as above
                (V(1,0),V(0,1),V(-1,0),V(0,-1),V(1,0)))

        T(arc_points(pi / 2,pi*1.5,0.5,4),
                (V(0,0.5),
                 V(-cos(radians(45))/2,sin(radians(45))/2),
                 V(-0.5,0),
                 V(-cos(radians(45))/2,-sin(radians(45))/2),
                 V(0,-0.5)))
Exemplo n.º 2
0
    def testGeometryCircle_arc_points(self):
        """arc_points() utility function"""
        def T(a, b):
            self.assert_(common.vert_equal(a, b))

        def F(a, b):
            self.assert_(not common.vert_equal(a, b))

        # test arc_points() finally
        T(arc_points(0, pi, 1, 1), (V(1, 0), V(-1, 0)))
        T(arc_points(pi, 0, 1, 1), (V(-1, 0), V(1, 0)))

        # three points, note rotation is always anti-clockwise
        T(arc_points(0, pi, 1, 2), (V(1, 0), V(0, 1), V(-1, 0)))
        T(arc_points(pi, 0, 1, 2), (V(-1, 0), V(0, -1), V(1, 0)))

        # full circle
        T(arc_points(0, 2 * pi, 1, 4),
          (V(1, 0), V(0, 1), V(-1, 0), V(0, -1), V(1, 0)))
        T(
            arc_points(2 * pi, 0, 1, 4),  # note same result as above
            (V(1, 0), V(0, 1), V(-1, 0), V(0, -1), V(1, 0)))

        T(arc_points(pi / 2, pi * 1.5, 0.5, 4),
          (V(0, 0.5), V(-cos(radians(45)) / 2,
                        sin(radians(45)) / 2), V(-0.5, 0),
           V(-cos(radians(45)) / 2, -sin(radians(45)) / 2), V(0, -0.5)))
Exemplo n.º 3
0
def make_line_vertexes(a,b,thickness,segments):
    # first find the angle of the given line
    d = b - a

    alpha = atan2(d[0,1],d[0,0])

    # create half-circles for either end
    arc_a = arc_points(alpha + pi/2,alpha - pi/2,float(thickness)/2,segments)  
    arc_b = arc_points(alpha - pi/2,alpha + pi/2,float(thickness)/2,segments)  

    # half circles aren't complete yet, need to shift them relative to the end
    # positions
    def t(vs,a):
        return [v + a for v in vs]
    arc_a = t(arc_a,a)
    arc_b = t(arc_b,b)

    return arc_a + arc_b
Exemplo n.º 4
0
def make_line_vertexes(a, b, thickness, segments):
    # first find the angle of the given line
    d = b - a

    alpha = atan2(d[0, 1], d[0, 0])

    # create half-circles for either end
    arc_a = arc_points(alpha + pi / 2, alpha - pi / 2,
                       float(thickness) / 2, segments)
    arc_b = arc_points(alpha - pi / 2, alpha + pi / 2,
                       float(thickness) / 2, segments)

    # half circles aren't complete yet, need to shift them relative to the end
    # positions
    def t(vs, a):
        return [v + a for v in vs]

    arc_a = t(arc_a, a)
    arc_b = t(arc_b, b)

    return arc_a + arc_b