Boost logo

Geometry :

Subject: [ggl] Point in triangle test available?
From: Barend Gehrels (barend.gehrels)
Date: 2010-12-02 13:29:46


Ha Hartmut,

Op 1-12-2010 21:20, Hartmut Kaiser schreef:
>>> Does Boost.Geometry have a pre-canned 'point in triangle' test
>>> available? I could come up with one myself easily, but asking might
>>> allow me to stay lazy :-P
>> There is point in polygon, of course. I'm not sure of the syntax
>> required, however.
> I understand that, but point in triangle is usually simpler (I don't
> need to
> sort my points for that), and additionally faster (as I could use the
> barycentric coordinate).

There is no one pre-canned indeed. As Mateusz mailed, the
c04_a_custom_triangle_example shows how things can be specialized for a
triangle.

I don't think it will be much faster; points are not sorted for the
point-in-polygon test. There are three algorithms provided, the winding
(slightly slower but able to detect border case), and two crossing
algorithms. By default, the winding algorithm is used because it
correctly detects if a point is located on the border, and returns false
then.

Regards, Barend


Geometry list run by mateusz at loskot.net