#include "vgl_closest_point.h"#include <vgl/vgl_distance.h>#include <vgl/vgl_line_2d.h>#include <vgl/vgl_homg_line_2d.h>#include <vgl/vgl_point_2d.h>#include <vgl/vgl_point_3d.h>#include <vgl/vgl_homg_point_2d.h>#include <vgl/vgl_homg_point_3d.h>#include <vgl/vgl_plane_3d.h>#include <vgl/vgl_homg_plane_3d.h>#include <vgl/vgl_homg_line_3d_2_points.h>#include <vgl/vgl_line_3d_2_points.h>#include <vgl/vgl_line_segment_3d.h>#include <vgl/vgl_polygon.h>#include <vcl_cassert.h>#include <vcl_cmath.h>Go to the source code of this file.
Defines | |
| #define | vgl_closest_point_txx_ |
| #define | DIST_SQR_TO_LINE_SEG_2D(T, x1, y1, x2, y2, x, y) vgl_distance2_to_linesegment(x1, y1, x2, y2, x, y ); |
| #define | DIST_SQR_TO_LINE_SEG_3D(T, x1, y1, z1, x2, y2, z2, x, y, z) vgl_distance2_to_linesegment(x1, y1, z1, x2, y2, z2, x, y, z ); |
| #define | VGL_CLOSEST_POINT_INSTANTIATE(T) |
Functions | |
| template<class T > | |
| void | vgl_closest_point_to_linesegment (T &ret_x, T &ret_y, T x1, T y1, T x2, T y2, T x0, T y0) |
| Closest point to (x,y) on the line segment (x1,y1)-(x2,y2). | |
| template<class T > | |
| void | vgl_closest_point_to_linesegment (T &ret_x, T &ret_y, T &ret_z, T x1, T y1, T z1, T x2, T y2, T z2, T x, T y, T z) |
| Closest point to (x,y,z) on the line segment (x1,y1,z1)-(x2,y2,z2). | |
| template<class T > | |
| int | vgl_closest_point_to_non_closed_polygon (T &ret_x, T &ret_y, T const px[], T const py[], unsigned int n, T x, T y) |
| Closest point to (x,y) on open polygon (px[i],py[i]). | |
| template<class T > | |
| int | vgl_closest_point_to_non_closed_polygon (T &ret_x, T &ret_y, T &ret_z, T const px[], T const py[], T const pz[], unsigned int n, T x, T y, T z) |
| Closest point to (x,y,z) on open polygon (px[i],py[i],pz[i]). | |
| template<class T > | |
| int | vgl_closest_point_to_closed_polygon (T &ret_x, T &ret_y, T const px[], T const py[], unsigned int n, T x, T y) |
| Closest point to (x,y) on closed polygon (px[i],py[i]). | |
| template<class T > | |
| int | vgl_closest_point_to_closed_polygon (T &ret_x, T &ret_y, T &ret_z, T const px[], T const py[], T const pz[], unsigned int n, T x, T y, T z) |
| Closest point to (x,y,z) on closed polygon (px[i],py[i],pz[i]). | |
| template<class T > | |
| vgl_point_2d< T > | vgl_closest_point_origin (vgl_line_2d< T > const &l) |
| Return the point on the given line closest to the origin. | |
| template<class T > | |
| vgl_homg_point_2d< T > | vgl_closest_point_origin (vgl_homg_line_2d< T > const &l) |
| Return the point on the given line closest to the origin. | |
| template<class T > | |
| vgl_point_3d< T > | vgl_closest_point_origin (vgl_plane_3d< T > const &pl) |
| Return the point on the given plane closest to the origin. | |
| template<class T > | |
| vgl_homg_point_3d< T > | vgl_closest_point_origin (vgl_homg_plane_3d< T > const &pl) |
| Return the point on the given plane closest to the origin. | |
| template<class T > | |
| vgl_homg_point_3d< T > | vgl_closest_point_origin (vgl_homg_line_3d_2_points< T > const &l) |
| Return the point on the given line closest to the origin. | |
| template<class T > | |
| vgl_point_3d< T > | vgl_closest_point_origin (vgl_line_3d_2_points< T > const &l) |
| Return the point on the given line closest to the origin. | |
| template<class T > | |
| vgl_point_2d< T > | vgl_closest_point (vgl_line_2d< T > const &l, vgl_point_2d< T > const &p) |
| Return the point on the given line closest to the given point. | |
| template<class T > | |
| vgl_homg_point_2d< T > | vgl_closest_point (vgl_homg_line_2d< T > const &l, vgl_homg_point_2d< T > const &p) |
| Return the point on the given line closest to the given point. | |
| template<class T > | |
| vgl_point_3d< T > | vgl_closest_point (vgl_plane_3d< T > const &l, vgl_point_3d< T > const &p) |
| Return the point on the given plane closest to the given point. | |
| template<class T > | |
| vgl_homg_point_3d< T > | vgl_closest_point (vgl_homg_plane_3d< T > const &l, vgl_homg_point_3d< T > const &p) |
| Return the point on the given plane closest to the given point. | |
| template<class T > | |
| vgl_point_2d< T > | vgl_closest_point (vgl_polygon< T > const &poly, vgl_point_2d< T > const &point, bool closed) |
| Return the point on the given polygon closest to the given point. | |
| template<class T > | |
| vcl_pair< vgl_homg_point_3d< T > , vgl_homg_point_3d< T > > | vgl_closest_points (vgl_homg_line_3d_2_points< T > const &line1, vgl_homg_line_3d_2_points< T > const &line2) |
| Return the two points of nearest approach of two 3D lines, one on each line. | |
| template<class T > | |
| vgl_homg_point_3d< T > | vgl_closest_point (vgl_homg_line_3d_2_points< T > const &l, vgl_homg_point_3d< T > const &p) |
| Return the point on the given line which is closest to the given point. | |
| template<class T > | |
| double | vgl_closest_point_t (vgl_line_3d_2_points< T > const &l, vgl_point_3d< T > const &p) |
| Return the point on the given line which is closest to the given point. | |
| template<class T > | |
| vgl_point_3d< T > | vgl_closest_point (vgl_line_3d_2_points< T > const &l, vgl_point_3d< T > const &p) |
| Return the point on the given line which is closest to the given point. | |
| template<class T > | |
| vcl_pair< vgl_point_3d< T > , vgl_point_3d< T > > | vgl_closest_points (const vgl_line_3d_2_points< T > &l1, const vgl_line_3d_2_points< T > &l2, bool *unique) |
| Return the points of closest approach on 2 3D lines. | |
| template<class T > | |
| vcl_pair< vgl_point_3d< T > , vgl_point_3d< T > > | vgl_closest_points (vgl_line_segment_3d< T > const &l1, vgl_line_segment_3d< T > const &l2, bool *unique) |
| Return the points of closest approach on 2 3D line segments. | |
Variables | |
| const double | SMALL_DOUBLE = 1e-12 |
Definition in file vgl_closest_point.txx.
| #define DIST_SQR_TO_LINE_SEG_2D | ( | T, | |
| x1, | |||
| y1, | |||
| x2, | |||
| y2, | |||
| x, | |||
| y | |||
| ) | vgl_distance2_to_linesegment(x1, y1, x2, y2, x, y ); |
Definition at line 44 of file vgl_closest_point.txx.
| #define DIST_SQR_TO_LINE_SEG_3D | ( | T, | |
| x1, | |||
| y1, | |||
| z1, | |||
| x2, | |||
| y2, | |||
| z2, | |||
| x, | |||
| y, | |||
| z | |||
| ) | vgl_distance2_to_linesegment(x1, y1, z1, x2, y2, z2, x, y, z ); |
Definition at line 46 of file vgl_closest_point.txx.
| #define VGL_CLOSEST_POINT_INSTANTIATE | ( | T | ) |
Definition at line 598 of file vgl_closest_point.txx.
| #define vgl_closest_point_txx_ |
Definition at line 3 of file vgl_closest_point.txx.
| vgl_point_2d<T> vgl_closest_point | ( | vgl_line_2d< T > const & | l, |
| vgl_point_2d< T > const & | p | ||
| ) |
Return the point on the given line closest to the given point.
Definition at line 242 of file vgl_closest_point.txx.
| vgl_homg_point_2d<T> vgl_closest_point | ( | vgl_homg_line_2d< T > const & | l, |
| vgl_homg_point_2d< T > const & | p | ||
| ) |
Return the point on the given line closest to the given point.
Definition at line 252 of file vgl_closest_point.txx.
| vgl_point_3d<T> vgl_closest_point | ( | vgl_plane_3d< T > const & | l, |
| vgl_point_3d< T > const & | p | ||
| ) |
Return the point on the given plane closest to the given point.
Definition at line 263 of file vgl_closest_point.txx.
| vgl_homg_point_3d<T> vgl_closest_point | ( | vgl_homg_plane_3d< T > const & | l, |
| vgl_homg_point_3d< T > const & | p | ||
| ) |
Return the point on the given plane closest to the given point.
Definition at line 276 of file vgl_closest_point.txx.
| vgl_point_2d<T> vgl_closest_point | ( | vgl_polygon< T > const & | poly, |
| vgl_point_2d< T > const & | point, | ||
| bool | closed = true |
||
| ) |
Return the point on the given polygon closest to the given point.
If the third argument is "false", the edge from last to first point of each polygon sheet is not considered part of the polygon.
Definition at line 286 of file vgl_closest_point.txx.
| vgl_homg_point_3d<T> vgl_closest_point | ( | vgl_homg_line_3d_2_points< T > const & | l, |
| vgl_homg_point_3d< T > const & | p | ||
| ) |
Return the point on the given line which is closest to the given point.
If the given point is at infinity, the point at infinity of the line is returned.
Definition at line 370 of file vgl_closest_point.txx.
| vgl_point_3d<T> vgl_closest_point | ( | vgl_line_3d_2_points< T > const & | l, |
| vgl_point_3d< T > const & | p | ||
| ) |
Return the point on the given line which is closest to the given point.
Definition at line 405 of file vgl_closest_point.txx.
| vgl_point_2d<T> vgl_closest_point_origin | ( | vgl_line_2d< T > const & | l | ) |
Return the point on the given line closest to the origin.
Definition at line 186 of file vgl_closest_point.txx.
| vgl_homg_point_2d<T> vgl_closest_point_origin | ( | vgl_homg_line_2d< T > const & | l | ) |
Return the point on the given line closest to the origin.
Definition at line 193 of file vgl_closest_point.txx.
| vgl_point_3d<T> vgl_closest_point_origin | ( | vgl_plane_3d< T > const & | pl | ) |
Return the point on the given plane closest to the origin.
Definition at line 200 of file vgl_closest_point.txx.
| vgl_homg_point_3d<T> vgl_closest_point_origin | ( | vgl_homg_plane_3d< T > const & | pl | ) |
Return the point on the given plane closest to the origin.
Definition at line 207 of file vgl_closest_point.txx.
| vgl_homg_point_3d<T> vgl_closest_point_origin | ( | vgl_homg_line_3d_2_points< T > const & | l | ) |
Return the point on the given line closest to the origin.
Definition at line 214 of file vgl_closest_point.txx.
| vgl_point_3d<T> vgl_closest_point_origin | ( | vgl_line_3d_2_points< T > const & | l | ) |
Return the point on the given line closest to the origin.
Definition at line 228 of file vgl_closest_point.txx.
| double vgl_closest_point_t | ( | vgl_line_3d_2_points< T > const & | l, |
| vgl_point_3d< T > const & | p | ||
| ) |
Return the point on the given line which is closest to the given point.
The closest point is expressed in parametric form.
Definition at line 388 of file vgl_closest_point.txx.
| int vgl_closest_point_to_closed_polygon | ( | T & | ret_x, |
| T & | ret_y, | ||
| T const | px[], | ||
| T const | py[], | ||
| unsigned int | n, | ||
| T | x, | ||
| T | y | ||
| ) |
Closest point to (x,y) on closed polygon (px[i],py[i]).
Also returns the index of the polygon line segment where this point lies.
Definition at line 144 of file vgl_closest_point.txx.
| int vgl_closest_point_to_closed_polygon | ( | T & | ret_x, |
| T & | ret_y, | ||
| T & | ret_z, | ||
| T const | px[], | ||
| T const | py[], | ||
| T const | pz[], | ||
| unsigned int | n, | ||
| T | x, | ||
| T | y, | ||
| T | z | ||
| ) |
Closest point to (x,y,z) on closed polygon (px[i],py[i],pz[i]).
Also returns the index of the polygon line segment where this point lies.
Definition at line 164 of file vgl_closest_point.txx.
| void vgl_closest_point_to_linesegment | ( | T & | ret_x, |
| T & | ret_y, | ||
| T | x1, | ||
| T | y1, | ||
| T | x2, | ||
| T | y2, | ||
| T | x0, | ||
| T | y0 | ||
| ) |
Closest point to (x,y) on the line segment (x1,y1)-(x2,y2).
Definition at line 52 of file vgl_closest_point.txx.
| void vgl_closest_point_to_linesegment | ( | T & | ret_x, |
| T & | ret_y, | ||
| T & | ret_z, | ||
| T | x1, | ||
| T | y1, | ||
| T | z1, | ||
| T | x2, | ||
| T | y2, | ||
| T | z2, | ||
| T | x, | ||
| T | y, | ||
| T | z | ||
| ) |
Closest point to (x,y,z) on the line segment (x1,y1,z1)-(x2,y2,z2).
Definition at line 81 of file vgl_closest_point.txx.
| int vgl_closest_point_to_non_closed_polygon | ( | T & | ret_x, |
| T & | ret_y, | ||
| T const | px[], | ||
| T const | py[], | ||
| unsigned int | n, | ||
| T | x, | ||
| T | y | ||
| ) |
Closest point to (x,y) on open polygon (px[i],py[i]).
Also returns the index of the polygon line segment where this point lies.
Definition at line 109 of file vgl_closest_point.txx.
| int vgl_closest_point_to_non_closed_polygon | ( | T & | ret_x, |
| T & | ret_y, | ||
| T & | ret_z, | ||
| T const | px[], | ||
| T const | py[], | ||
| T const | pz[], | ||
| unsigned int | n, | ||
| T | x, | ||
| T | y, | ||
| T | z | ||
| ) |
Closest point to (x,y,z) on open polygon (px[i],py[i],pz[i]).
Also returns the index of the polygon line segment where this point lies.
Definition at line 126 of file vgl_closest_point.txx.
| vcl_pair<vgl_homg_point_3d<T>, vgl_homg_point_3d<T> > vgl_closest_points | ( | vgl_homg_line_3d_2_points< T > const & | line1, |
| vgl_homg_line_3d_2_points< T > const & | line2 | ||
| ) |
Return the two points of nearest approach of two 3D lines, one on each line.
There are 3 cases: the lines intersect (hence these two points are equal); the lines are parallel (an infinite number of solutions viz all points); the lines are neither parallel nor do they intersect (the general case). This method handles all 3 cases. In all cases, a pair of points is returned; in case 1, the two returned points are equal; in case 2, both points are the common point at infinity of the two lines.
Note that case 2 also comprises the case where the given lines are identical. Hence, when observing a point at infinity as a return value, one should interpret this as "all points are closest points".
| line1 | |
| line2 |
This routine is adapted from code written by Paul Bourke and available online at http://astronomy.swin.edu.au/~pbourke/geometry/lineline3d/
Definition at line 319 of file vgl_closest_point.txx.
| vcl_pair<vgl_point_3d<T>, vgl_point_3d<T> > vgl_closest_points | ( | const vgl_line_3d_2_points< T > & | l1, |
| const vgl_line_3d_2_points< T > & | l2, | ||
| bool * | unique = 0 |
||
| ) |
Return the points of closest approach on 2 3D lines.
Uses non-homogeneous representations.
| unique | If provided, will be set to true if the returned points are unique, otherwise many solutions exist and the returned points are an arbitrary choice. The distance between the points is still valid, however. |
Definition at line 423 of file vgl_closest_point.txx.
| vcl_pair<vgl_point_3d<T>, vgl_point_3d<T> > vgl_closest_points | ( | const vgl_line_segment_3d< T > & | l1, |
| const vgl_line_segment_3d< T > & | l2, | ||
| bool * | unique = 0 |
||
| ) |
Return the points of closest approach on 2 3D line segments.
Uses non-homogeneous representations.
| unique | If provided, will be set to true if the returned points are unique, otherwise many solutions exist and the returned points are an arbitrary choice. The distance between the points is still valid, however. |
Definition at line 474 of file vgl_closest_point.txx.
| const double SMALL_DOUBLE = 1e-12 |
Definition at line 30 of file vgl_closest_point.txx.
1.7.5.1