Boost logo

Geometry :

Subject: [ggl] Re: within() to return true if point is on border?
From: Arash Partow (arash)
Date: 2011-04-11 04:00:16


On 11/04/2011 10:50 AM, Denis Pesotsky wrote:
> Dirty solution: http://paste.kde.org/10392/
> It works well, but slower that it could. Any nicer way?
>

The way you're going about it is pretty much the correct way, that said your point on line segment routine is very inefficient.

The algorithm should be something like this (assuming orientation predicate):

is point on line-segment(s1,s2) -> bool
{
    if point not in aabb of s1 s2 then
    {
       return false
    }

    return (orientation of point to s1-s2 == collinear)
}


Geometry list run by mateusz at loskot.net