I'm trying to test whether or not the origin is contained inside the following triangle

inscribed inside a circle:

th = array([ 2.3913423, 5.3133123, 1.8516171])

p=patch.Polygon(array([cos(th),sin(th)]).T)

p.contains_point((0,0))

returns 0

but,

matplotlib.nxutils.points_inside_poly([[0,0]],p.get_path().vertices)

returns True

What am I missing here?

Thanks!

I'm trying to test whether or not the origin is contained inside the

following triangle

inscribed inside a circle:

th = array([ 2.3913423, 5.3133123, 1.8516171])

p=patch.Polygon(array([cos(th),sin(th)]).T)

What do you mean by "patch" here?

I tested

p=Polygon(array([cos(th),sin(th)]).T)

p.contains_point((0,0))

and the answer is 1.

Jerzy Karczmarczuk

## ···

Le 13/02/2012 17:47, reckoner a écrit :

I can confirm this for both the current development branch and v1.1.x. Strange…

Ben Root

## ···

On Mon, Feb 13, 2012 at 1:33 PM, reckoner <reckoner@…287…> wrote:

Here’s a better example:

th= array([ 4.65542641, 5.32920696, 2.20928291])

p=patch.Polygon(array([cos(th),sin(th)]).T)

print p.contains_point((0,0))

1

print matplotlib.nxutils.pnpoly(0,0,p.get_path().vertices)

0

Thanks!

reckoner:

```
>>> th= array([ 4.65542641, 5.32920696,
```

2.20928291])

```
>>> p=patch.Polygon(array([cos(th),sin(th)]).T)
>>> print p.contains_point((0,0))
1
>>> print
```

matplotlib.nxutils.pnpoly(0,0,p.get_path().vertices)

```
0
Thanks!
```

```
I can confirm this for both the current development branch and
```

v1.1.x. Strange…

```
Ben Root
```

```
HYPOTHESIS (I have no time to check now everything..., I did my
```

best.)

```
If radius=None, it is converted into radius=1 in contains_point (in
```

Patch).

```
(This is the linewidth !)
I am not sure whether it is ok, i.e. in pixels. If this value is
```

considered to be relative to axes, it is enormous!

```
p.contains_point((0,0),radius=0.01)
gives 0 as it should.
Jerzy Karczmarczuk
P.S. I suggest anyway that reckoner submits a complete program with
```

imports. What is “patch”??

Jerzy is right. contains() and contains_point() both takes a radius argument as this function is intended for use when mouse-clicking. If no radius is given, it uses the object’s linewidth and passes it to the path’s contains_point() function with its transform. I *suspect* that the problem is that the transforms haven’t been fully defined yet and might be incorrectly testing this.

This needs a bit more investigation to see if this is the intended behavior or if something needs to be fixed.

As a side note, “patch” is an imported module via “from matplotlib import patches as patch”. Not standard among mpl devs, but not out of the ordinary.

Ben Root

## ···

On Mon, Feb 13, 2012 at 2:59 PM, Jerzy Karczmarczuk <jerzy.karczmarczuk@…3937…> wrote:

reckoner:

```
>>> th= array([ 4.65542641, 5.32920696,
```

2.20928291])

```
>>> p=patch.Polygon(array([cos(th),sin(th)]).T)
>>> print p.contains_point((0,0))
1
>>> print
```

matplotlib.nxutils.pnpoly(0,0,p.get_path().vertices)

```
0
Thanks!
```

```
I can confirm this for both the current development branch and
```

v1.1.x. Strange…

```
Ben Root
```

```
HYPOTHESIS (I have no time to check now everything..., I did my
```

best.)

```
If radius=None, it is converted into radius=1 in contains_point (in
```

Patch).

```
(This is the linewidth !)
I am not sure whether it is ok, i.e. in pixels. If this value is
```

considered to be relative to axes, it is enormous!

```
p.contains_point((0,0),radius=0.01)
gives 0 as it should.
Jerzy Karczmarczuk
P.S. I suggest anyway that reckoner submits a complete program with
```

imports. What is “patch”??