예제 #1
0
def test_fuzz_bisect():
    N = 50

    for data in generate_fuzz_data(N, lines=2):
        l1, l2 = data.lines
        if l1.null() or l2.null() or Vertex(l1, l2).parallel() or Vertex(
                l1, l2).point.null():
            continue

        V = l1.vector()
        U = l2.vector()
        try:
            (U.norm() / V.norm()).sqrt()
        except ValueError:
            continue

        v0 = Vertex(l1, l2)
        bisectors = v0.bisect()
        s0 = v0.spread()

        s1 = Vertex(l1, bisectors.line1).spread()
        s2 = Vertex(l1, bisectors.line2).spread()
        s3 = Vertex(l2, bisectors.line1).spread()
        s4 = Vertex(l2, bisectors.line2).spread()

        assert bisectors.spread() == 1
예제 #2
0
def test_fuzz_bisect():
    N = 50

    for data in generate_fuzz_data(N, lines=2):
        l1, l2 = data.lines
        if l1.null() or l2.null() or Vertex(l1, l2).parallel() or Vertex(l1, l2).point.null():
            continue

        V = l1.vector()
        U = l2.vector()
        try:
            (U.norm()/V.norm()).sqrt()
        except ValueError:
            continue

        v0 = Vertex(l1, l2)
        bisectors = v0.bisect()
        s0 = v0.spread()

        s1 = Vertex(l1, bisectors.line1).spread()
        s2 = Vertex(l1, bisectors.line2).spread()
        s3 = Vertex(l2, bisectors.line1).spread()
        s4 = Vertex(l2, bisectors.line2).spread()
                
        assert bisectors.spread() == 1
예제 #3
0
def test_parallel():
    N = 20
    for data in generate_fuzz_data(N, lines=1):
        line = data.lines[0]
        if line.null():
            assert_raises(NullLineError, Vertex(line, line).spread)
        else:
            assert Vertex(line, line).spread() == 0
        assert Vertex(line, line).parallel()
예제 #4
0
    def add_grammola(self, evt):
        k = self.k.GetValue()
        l1 = self._get_line(self.lines1)
        l2 = self._get_line(self.lines2)

        if l1 and l2:
            vertex = Vertex(l1, l2)
            name = self.name.GetValue()
            grammola = vertex.grammola(k), name, "x", self.colours.GetValue()
            self.parent.object_panel.add_conic(grammola)
예제 #5
0
파일: wx_demo.py 프로젝트: marchon/pygeom
    def add_grammola(self, evt):
        k = self.k.GetValue()
        l1 = self._get_line(self.lines1)
        l2 = self._get_line(self.lines2)

        if l1 and l2:
            vertex = Vertex(l1, l2)
            name = self.name.GetValue()
            grammola = vertex.grammola(k), name, "x", self.colours.GetValue()
            self.parent.object_panel.add_conic(grammola)
예제 #6
0
def test_fuzz_altitude():
    N = 20
    for data in generate_fuzz_data(N, pointlines=1):
        pl = data.pointlines[0]

        if pl.line.null():
            assert_raises(NullLineError, pl.altitude)
        else:
            alt = pl.altitude()
            assert PointLine(pl.point, alt.line).on()
            assert Vertex(alt.line, pl.line).perpendicular()
            assert PointLine(alt.point, pl.line).on()
예제 #7
0
def test_fuzz_init():
    N = 20
    for data in generate_fuzz_data(N, geoms=2, lines=2, points=2):
        g0, g1 = data.geoms
        l0, l1 = data.lines
        p0, p1 = data.points

        ls0 = LineSegment(p0, p1)
        ls1 = LineSegment(p0, p1)
        assert ls0 == ls1

        v0 = Vertex(l0, l1)
        v1 = Vertex(l1, l0)
        assert v0 == v1

        if g0 != g1:
            l0.geometry = p0.geometry = g0
            l1.geometry = p1.geometry = g1
            assert_raises(GeometryError, Vertex, l0, l1)
            assert_raises(GeometryError, PointLine, p0, l1)
            assert_raises(GeometryError, LineSegment, p0, p1)
예제 #8
0
def test_fuzz_conic():
    N = 50
    for data in generate_fuzz_data(N, pointlines=1, spreads=1):
        try:
            focus_direc = data.pointlines[0]
            K = data.spreads[0]
            conic = focus_direc.conic(K)

            v1, v2, KK = conic.focus_directrix()

            dir = focus_direc.line
            focus = focus_direc.point

            assert K == KK
            assert v1 == focus_direc or v2 == focus_direc
            assert Vertex(v1.line, v2.line).parallel()

        except NullLineError:
            pass
        except ZeroDivisionError:
            #FIXME
            pass
예제 #9
0
def random_vertex(field, geometry):
    return Vertex(random_line(field, geometry), random_line(field, geometry))
예제 #10
0
파일: example.py 프로젝트: timleslie/pygeom
A = Point(f(3), f(7), geometry)
B = Point(f(4), f(12), geometry)
C = Point(f(9), f(2), geometry)

# Create the lines of the triangle
AB = LineSegment(A, B)
AC = LineSegment(A, C)
BC = LineSegment(B, C)

# Create the altitudes
alt_a = PointLine(A, BC.line).altitude().line
alt_b = PointLine(B, AC.line).altitude().line
alt_c = PointLine(C, AB.line).altitude().line

# Calculate the points of intersection of the altitudes
O_ab = Vertex(alt_a, alt_b).point
O_bc = Vertex(alt_b, alt_c).point
O_ca = Vertex(alt_c, alt_a).point

# Check that the points are indeed equal
assert O_ab == O_bc == O_ca
print "Orthocentre:", O_ab

# Find the circumcentre
C_a = BC.perp_bisector()
C_b = AC.perp_bisector()
C_0 = Vertex(C_a, C_b).point
print "Circumcentre:", C_0

# Check the quadrances
Q_a = LineSegment(A, C_0).quadrance()