Boost logo

Geometry :

Subject: Re: [geometry] Segment to Segment Distance
From: Barend Gehrels (barend_at_[hidden])
Date: 2012-05-25 07:06:47


On 25-5-2012 6:12, Dan Chianucci wrote:
> Hey Barend,
> Thanks for the quick reply.
> I've been trying to see if I can add this functionality, however the
> templates are killing me. I'm looking at how other algorithms are
> done, but I can't seem to find any actual "code". All I can find is
> template stuff. All trails I can find lead down to a call to
> apply(). Which I can't find where it is actually defined because the
> class it is being called on is defined in the template rather than
> explicitly. I guess what I am asking is where is the actual
> implementation of the algorithms. For instance, in the point to point
> distance operation, where is the sqrt( (x2-x1)^2 + (y2-y1)^2 )?
>
> Thanks,
> Dan C

Hi Dan,

There are several layers of templates indeed. Of course all have their
function, but it is difficult to begin with.

Nice that you try to add this.

Basically the actual calculation is done in distance_pythagoras.hpp.
This is a strategy, which is configured as the default for Cartesian.
But you don't see that directly from distance.hpp, because it might be
that the specified points are in another coordinate system (e.g. on
Earth) and they need another calculation.

A complicating factor is further that there are two types of strategies:
point-point and point-segment (those are also
coordinate-system-dependent). In your case you need that. That strategy
should in your case be called (I think) with the two points of one
segment to the other segment, and vice versa.

Hope this answer gives already some clues to continue, and otherwise
just mail again.

Regards, Barend


Geometry list run by mateusz at loskot.net