We have it in 3D but not in 2D.

What you can do is project the point onto the supporting line,

check whether the point is inside the segment and if not pick

the endpoint of the segment that is the closest to the

projected point.

Something like this (I did not try to compile it):

typedef CGAL::EPECK K;

K::Segment_2 s;

K::Point_2 query;

K::Construct_projected_point_2 project;

K::Point_3 proj = project(s.supporting_line(), query);

if (!s.has_on(proj))

{

proj = CGAL::compare_distance_to_point(proj, s[0], s[1]) ==

CGAL::SMALLER ? s[0]:s[1];

}

Sebastien.

On 03/10/2017 12:34 AM, Renato Silveira wrote:

> Is there a function that returns the closest point (2D) on a segment

> (2D) to a given point (2D)?

>

> Thank you in advance,

> Renato

>

> --

> */Renato Silveira

> /*

> Ph.D. in Computer Science

> Informatics Institute - UFRGS

> Porto Alegre - RS - Brazil

>

http://www.inf.ufrgs.br/~rsilveira--

You are currently subscribed to cgal-discuss.

To unsubscribe or access the archives, go to

https://sympa.inria.fr/sympa/info/cgal-discuss