Boost logo

Geometry :

Subject: Re: [geometry] Call to geometry::within returns true when point is outside ring
From: Barend Gehrels (barend_at_[hidden])
Date: 2012-10-15 01:59:48


Op 15 okt. 2012 om 01:57 heeft "Rob K." <kashiraja_at_[hidden]> het volgende geschreven:

> Hi,
> I'm seeing some unexpected behavior in a call to within. In the code below I am checking if a coordinate (0,0) is within a ring. The ring is positioned to the right of the origin so within should return false, but it returns true.
> However, if the ring coordinates conform to a true rectangle (for example, all lines are parallel to either X or Y axis), the function returns false regardless of where the rectangle is positioned in the Y direction (as expected).
>
> Moving the ring along different offsets along the y-axis, it seems if any line intersects the x-axis at an angle, it returns true. E.g. in the test case below the top line is (4,0) to (6,-.1).
> I've just started using this library so it is possible I have over looked some assumption (I have made sure that the coordinates are listed in clockwise order at least).
>
> I a post a month or two ago that indicates that ::within might still not be fully functional? (http://boost-geometry.203548.n3.nabble.com/a-ring-concept-implementation-of-a-true-circle-td4025091.html#a4025110)
>

Hi,

Welcome to the list.

The post you mentioned was about circles, which is something different and indeed not fully implemented.

Your code uses an unclosed ring, therefore you get unexpected behaviour. Please close the ring explicitly, or use geometry::correct, or use the definition of an Open Ring.

Regards, Barend

Sent from iPad.
Barend Gehrels
www.barendgehrels.nl

>



Geometry list run by mateusz at loskot.net