コード例 #1
0
def test_point():
    poly1 = [(1,1), (1,-1), (-1,-1), (-1,1)]
    poly2 = [(2,2), (1,-1), (-1,-1), (-1,1)]
    assert helpers.pointInPolygon(0, 0, poly1)
    assert helpers.pointInPolygon(12, 12, poly1) == False
    assert helpers.pointInPolygon(0, 0, [(0,0), (1,1)]) == False

    helpers.nxutils = nxutils
    matplotlib.__version__ = '1.1'  # matplotlib.nxutils
    assert helpers.polygonsOverlap(poly1, poly2)
    del(helpers.nxutils)

    matplotlib.__version__ = '0.0'    # pure python
    assert helpers.polygonsOverlap(poly1, poly2)
    matplotlib.__version__ = mpl_version
コード例 #2
0
def test_point():
    poly1 = [(1, 1), (1, -1), (-1, -1), (-1, 1)]
    poly2 = [(2, 2), (1, -1), (-1, -1), (-1, 1)]
    assert helpers.pointInPolygon(0, 0, poly1)
    assert (helpers.pointInPolygon(12, 12, poly1) is False)
    assert (helpers.pointInPolygon(0, 0, [(0, 0), (1, 1)]) is False)

    if have_nxutils:
        helpers.nxutils = nxutils
        matplotlib.__version__ = '1.1'  # matplotlib.nxutils
        assert helpers.polygonsOverlap(poly1, poly2)
        del helpers.nxutils

    matplotlib.__version__ = '0.0'  # pure python
    assert helpers.polygonsOverlap(poly1, poly2)
    matplotlib.__version__ = mpl_version
コード例 #3
0
    def overlaps(self, polygon):
        """Determines if this stimulus intersects another one. If `polygon` is
        another stimulus instance, then the vertices and location of that stimulus
        will be used as the polygon. Overlap detection is only approximate; it
        can fail with pointy shapes. Returns `True` if the two shapes overlap.

        Note that, if your stimulus uses a mask (such as a Gaussian blob) then
        this is not accounted for by the `overlaps` method; the extent of the
        stimulus is determined purely by the size, pos, and orientation settings
        (and by the vertices for shape stimuli).

        See coder demo, shapeContains.py
        """
        if self.needVertexUpdate:
            self._calcVerticesRendered()
        if self.ori:
            polyRendered = self._getPolyAsRendered()
            return polygonsOverlap(polyRendered, polygon)
        else:
            return polygonsOverlap(self, polygon)
コード例 #4
0
ファイル: basevisual.py プロジェクト: rpbaxter/psychopy
    def overlaps(self, polygon):
        """Determines if this stimulus intersects another one. If `polygon` is
        another stimulus instance, then the vertices and location of that stimulus
        will be used as the polygon. Overlap detection is only approximate; it
        can fail with pointy shapes. Returns `True` if the two shapes overlap.

        Note that, if your stimulus uses a mask (such as a Gaussian blob) then
        this is not accounted for by the `overlaps` method; the extent of the
        stimulus is determined purely by the size, pos, and orientation settings
        (and by the vertices for shape stimuli).

        See coder demo, shapeContains.py
        """
        return polygonsOverlap(self, polygon)
コード例 #5
0
    def overlaps(self, polygon):
        """Returns `True` if this stimulus intersects another one.

        If `polygon` is
        another stimulus instance, then the vertices and location of that stimulus
        will be used as the polygon. Overlap detection is typically very good, but it
        can fail with very pointy shapes in a crossed-swords configuration.

        Note that, if your stimulus uses a mask (such as a Gaussian blob) then
        this is not accounted for by the `overlaps` method; the extent of the
        stimulus is determined purely by the size, pos, and orientation settings
        (and by the vertices for shape stimuli).

        See coder demo, shapeContains.py
        """
        return polygonsOverlap(self, polygon)
コード例 #6
0
ファイル: image.py プロジェクト: Gianluigi/psychopy
    def overlaps(self, polygon):
        """Determines if the image overlaps another image or shape (`polygon`).

        See :class:`~psychopy.visual.ShapeStim` `.overlaps()`.
        """
        return polygonsOverlap(self, polygon)