Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Re: how to find closest point on a segment/rectangle to a given point

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Re: how to find closest point on a segment/rectangle to a given point


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Re: how to find closest point on a segment/rectangle to a given point
  • Date: Thu, 23 Jun 2011 09:36:46 +0200

Take a kernel with exact constructions (like CGAL::Exact_predicates_exact_constructions_kernel).

Construct you lines with this kernel.
compute the vector orthogonal to those two lines (using cross_product
on their director vectors)
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Kernel_23_ref/Function_cross_product.html

Assume the vector is not 0 and take any a point on Line_1
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Kernel_23_ref/Class_Line_3.html
and construct the plane containing this line and having the computed
vector as orthogonal vector.
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Kernel_23_ref/Class_Plane_3.html

Take two points on Line_2 and project then on the plane. Construct the
line passing through the projected points and intersect it with Line_1
to get the first point.
http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Kernel_23_ref/Function_intersection.html
To get the second point construct the line containing the first point
with direction the computed vector. Intersect this line with Line_2 and
you will get the second point.

I agree that a closest_point method would be nice to have in CGAL.

Sebastien.

updog wrote:
I just find CGAL::squared_distance() would be useful.
However, is there a way to get the locations of the very pair of points
achieving the minimal squared distance?

--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/how-to-find-closest-point-on-a-segment-rectangle-to-a-given-point-tp3618761p3618911.html
Sent from the cgal-discuss mailing list archive at Nabble.com.





Archive powered by MHonArc 2.6.16.

Top of Page