Defines | Functions
core/vgl/vgl_intersection.txx File Reference
#include "vgl_intersection.h"
#include <vcl_limits.h>
#include <vcl_cassert.h>
#include <vcl_cmath.h>
#include <vgl/vgl_point_2d.h>
#include <vgl/vgl_line_2d.h>
#include <vgl/vgl_line_3d_2_points.h>
#include <vgl/vgl_line_segment_2d.h>
#include <vgl/vgl_line_segment_3d.h>
#include <vgl/vgl_ray_3d.h>
#include <vgl/vgl_vector_3d.h>
#include <vgl/vgl_box_2d.h>
#include <vgl/vgl_box_3d.h>
#include <vgl/vgl_polygon.h>
#include <vgl/vgl_plane_3d.h>
#include <vgl/vgl_distance.h>
#include <vgl/vgl_tolerance.h>
#include <vgl/vgl_lineseg_test.txx>
#include <vcl_vector.h>

Go to the source code of this file.

Defines

#define vgl_intersection_txx_
#define VGL_INTERSECTION_BOX_INSTANTIATE(T)
#define VGL_INTERSECTION_INSTANTIATE(T)

Functions

bool vgl_near_zero (double x)
bool vgl_near_eq (double x, double y)
template<class T >
vgl_box_2d< T > vgl_intersection (vgl_box_2d< T > const &b1, vgl_box_2d< T > const &b2)
 Return the intersection of two boxes (which is itself is a box, possibly the empty box).
template<class T >
bool vgl_intersection (vgl_box_3d< T > const &box, vgl_infinite_line_3d< T > const &line_3d, vgl_point_3d< T > &p0, vgl_point_3d< T > &p1)
 Return true if line intersects box. If so, compute intersection points.
template<class T >
bool vgl_intersection (vgl_box_3d< T > const &box, vgl_ray_3d< T > const &ray, vgl_point_3d< T > &p0, vgl_point_3d< T > &p1)
 Return true if ray intersects box. If so, compute intersection points.
template<class T >
bool vgl_intersection (vgl_box_3d< T > const &b, vgl_plane_3d< T > const &plane)
 Return true if a box and plane intersect in 3D.
template<class T >
vgl_box_3d< T > vgl_intersection (vgl_box_3d< T > const &b1, vgl_box_3d< T > const &b2)
 Return the intersection of two boxes (which is itself either a box, or empty).
template<class Type >
bool vgl_intersection (const vgl_box_2d< Type > &box, const vgl_line_2d< Type > &line, vgl_point_2d< Type > &p0, vgl_point_2d< Type > &p1)
 compute the intersection of an infinite line with *this box.
template<class Type >
unsigned int vgl_intersection (const vgl_box_2d< Type > &box, const vgl_line_segment_2d< Type > &line_seg, vgl_point_2d< Type > &p0, vgl_point_2d< Type > &p1)
 Returns the number of intersections of a line segment with a box, up to two are returned in p0 and p1.
template<class T >
vgl_point_3d< T > vgl_intersection (vgl_line_3d_2_points< T > const &l1, vgl_line_3d_2_points< T > const &l2)
 Return the intersection point of two concurrent lines.
template<class T >
bool vgl_intersection (vgl_line_segment_3d< T > const &l1, vgl_line_segment_3d< T > const &l2, vgl_point_3d< T > &i_pnt)
 Return the intersection point of segments of two concurrent lines.
template<class T >
bool vgl_intersection (vgl_line_3d_2_points< T > const &l1, vgl_line_segment_3d< T > const &l2, vgl_point_3d< T > &i_pnt)
 Return the intersection point of segments of two concurrent lines.
template<class T >
bool vgl_intersection (vgl_infinite_line_3d< T > const &l1, vgl_infinite_line_3d< T > const &l2, vgl_point_3d< T > &i_pnt)
 Return the intersection point of two lines, if concurrent.
template<class T >
bool vgl_intersection (vgl_ray_3d< T > const &r1, vgl_ray_3d< T > const &r2, vgl_point_3d< T > &i_pnt)
 Return the intersection point of rays. Returns false if rays are parallel or intersect outside of positive ray domain.
template<class T >
vgl_point_3d< T > vgl_intersection (vgl_line_3d_2_points< T > const &line, vgl_plane_3d< T > const &plane)
 Return the intersection point of a line and a plane.
template<class T >
bool vgl_intersection (vgl_line_segment_3d< T > const &line, vgl_plane_3d< T > const &plane, vgl_point_3d< T > &i_pt)
 Return the intersection point of a line and a plane.
template<class T >
bool vgl_intersection (vgl_infinite_line_3d< T > const &line, vgl_plane_3d< T > const &plane, vgl_point_3d< T > &i_pt)
 Return the intersection point of a line and a plane.
template<class T >
bool vgl_intersection (vgl_ray_3d< T > const &ray, vgl_plane_3d< T > const &plane, vgl_point_3d< T > &i_pt)
 Return the intersection point of a ray and a plane.
template<class T >
bool vgl_intersection (const vgl_line_2d< T > &line0, const vgl_line_2d< T > &line1, vgl_point_2d< T > &intersection_point)
 Return the intersection point of two lines. Return false if lines are parallel.
template<class T >
bool vgl_intersection (vgl_plane_3d< T > const &plane0, vgl_plane_3d< T > const &plane1, vgl_infinite_line_3d< T > &line)
 Return the intersection line of two planes. Returns false if planes.
template<class T >
vgl_point_3d< T > vgl_intersection (const vgl_plane_3d< T > &p1, const vgl_plane_3d< T > &p2, const vgl_plane_3d< T > &p3)
 Return the intersection point of three planes.
template<class T >
bool vgl_intersection (vgl_point_2d< T > const &p1, vgl_point_2d< T > const &p2, vgl_point_2d< T > const &q1, vgl_point_2d< T > const &q2, double tol)
 Return true if any point on [p1,p2] is within tol of [q1,q2].
template<class T >
bool vgl_intersection (const vgl_box_2d< T > &b, const vgl_polygon< T > &poly)
 Return true if the box and polygon regions intersect, regions include boundaries.
template<class T >
vcl_vector< vgl_point_2d< T > > vgl_intersection (vgl_box_2d< T > const &b, vcl_vector< vgl_point_2d< T > > const &p)
 Return the points from the list that lie inside the box.
template<class T >
vcl_vector< vgl_point_2d< T > > vgl_intersection (vcl_vector< vgl_point_2d< T > > const &p, vgl_box_2d< T > const &b)
 Return the points from the list that lie inside the box.
template<class T >
vcl_vector< vgl_point_3d< T > > vgl_intersection (vgl_box_3d< T > const &b, vcl_vector< vgl_point_3d< T > > const &p)
 Return the points from the list that lie inside the box.
template<class T >
vcl_vector< vgl_point_3d< T > > vgl_intersection (vcl_vector< vgl_point_3d< T > > const &p, vgl_box_3d< T > const &b)
 Return the points from the list that lie inside the box.
template<class T >
vcl_vector< vgl_point_2d< T > > vgl_intersection (vgl_polygon< T > const &poly, vgl_line_2d< T > const &line)
 Find the intersections of a line with a polygon( can have multiple sheets).

Detailed Description

Author:
Gamze Tunali

Definition in file vgl_intersection.txx.


Define Documentation

#define VGL_INTERSECTION_BOX_INSTANTIATE (   T)
Value:
template vgl_box_2d<T > vgl_intersection(vgl_box_2d<T > const&,vgl_box_2d<T > const&); \
template vgl_box_3d<T > vgl_intersection(vgl_box_3d<T > const&,vgl_box_3d<T > const&); \
template vcl_vector<vgl_point_2d<T > > vgl_intersection(vgl_box_2d<T > const&,vcl_vector<vgl_point_2d<T > > const&); \
template vcl_vector<vgl_point_2d<T > > vgl_intersection(vcl_vector<vgl_point_2d<T > > const&,vgl_box_2d<T > const&); \
template vcl_vector<vgl_point_3d<T > > vgl_intersection(vgl_box_3d<T > const&,vcl_vector<vgl_point_3d<T > > const&); \
template vcl_vector<vgl_point_3d<T > > vgl_intersection(vcl_vector<vgl_point_3d<T > > const&,vgl_box_3d<T > const&); \
template bool vgl_intersection(vgl_box_2d<T > const&,vgl_line_2d<T > const&,vgl_point_2d<T >&,vgl_point_2d<T >&); \
template bool vgl_intersection(vgl_box_3d<T > const&,vgl_plane_3d<T > const&); \
template bool vgl_intersection(vgl_box_3d<T > const&,vgl_infinite_line_3d<T > const&,vgl_point_3d<T >&,vgl_point_3d<T >&);\
template bool vgl_intersection(vgl_box_3d<T > const&,vgl_ray_3d<T > const&,vgl_point_3d<T >&,vgl_point_3d<T >&)

Definition at line 1057 of file vgl_intersection.txx.

#define VGL_INTERSECTION_INSTANTIATE (   T)
Value:
template vgl_point_3d<T > vgl_intersection(vgl_line_3d_2_points<T > const&,vgl_line_3d_2_points<T > const&); \
template bool vgl_intersection(vgl_line_segment_3d<T > const&,vgl_line_segment_3d<T > const&,vgl_point_3d<T >&); \
template bool vgl_intersection(vgl_line_3d_2_points<T > const&,vgl_line_segment_3d<T > const&,vgl_point_3d<T >&); \
template bool vgl_intersection(vgl_ray_3d<T > const&,vgl_ray_3d<T > const&,vgl_point_3d<T >&); \
template vgl_point_3d<T > vgl_intersection(vgl_line_3d_2_points<T > const&,vgl_plane_3d<T > const&); \
template bool vgl_intersection(vgl_line_segment_3d<T > const&,vgl_plane_3d<T > const&,vgl_point_3d<T >&); \
template bool vgl_intersection(vgl_infinite_line_3d<T > const&,vgl_plane_3d<T > const&,vgl_point_3d<T >&); \
template bool vgl_intersection(vgl_ray_3d<T > const& ray, vgl_plane_3d<T > const& plane, vgl_point_3d<T > & i_pt); \
template bool vgl_intersection(vgl_infinite_line_3d<T > const&,vgl_infinite_line_3d<T > const&,vgl_point_3d<T >&); \
template vgl_point_3d<T > vgl_intersection(vgl_plane_3d<T > const&,vgl_plane_3d<T > const&,vgl_plane_3d<T > const&); \
template unsigned vgl_intersection(vgl_box_2d<T > const&,vgl_line_segment_2d<T > const&,vgl_point_2d<T >&,vgl_point_2d<T >&); \
template bool vgl_intersection(vgl_line_2d<T > const&,vgl_line_2d<T > const&,vgl_point_2d<T >&); \
template bool vgl_intersection(vgl_point_2d<T > const&,vgl_point_2d<T > const&,vgl_point_2d<T > const&,vgl_point_2d<T > const&,double); \
template bool vgl_intersection(vgl_box_2d<T > const&,vgl_polygon<T > const&); \
template bool vgl_intersection(vgl_plane_3d<T > const&,vgl_plane_3d<T > const&,vgl_line_segment_3d<T > &); \
template bool vgl_intersection(vgl_plane_3d<T > const&,vgl_plane_3d<T > const&,vgl_infinite_line_3d<T >&); \
template vcl_vector<vgl_point_2d<T > > vgl_intersection(vgl_polygon<T > const&, vgl_line_2d<T > const&); \
VGL_INTERSECTION_BOX_INSTANTIATE(T)

Definition at line 1069 of file vgl_intersection.txx.

#define vgl_intersection_txx_

Definition at line 3 of file vgl_intersection.txx.


Function Documentation

template<class T >
vgl_box_2d<T> vgl_intersection ( vgl_box_2d< T > const &  b1,
vgl_box_2d< T > const &  b2 
)

Return the intersection of two boxes (which is itself is a box, possibly the empty box).

Return the intersection of two boxes (which is itself either a box, or empty).

Definition at line 36 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( vgl_box_3d< T > const &  box,
vgl_infinite_line_3d< T > const &  line_3d,
vgl_point_3d< T > &  p0,
vgl_point_3d< T > &  p1 
)

Return true if line intersects box. If so, compute intersection points.

Definition at line 49 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( vgl_box_3d< T > const &  box,
vgl_ray_3d< T > const &  ray,
vgl_point_3d< T > &  p0,
vgl_point_3d< T > &  p1 
)

Return true if ray intersects box. If so, compute intersection points.

If ray origin is inside box then p0==p1

Definition at line 167 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( vgl_box_3d< T > const &  b,
vgl_plane_3d< T > const &  plane 
)

Return true if a box and plane intersect in 3D.

Definition at line 198 of file vgl_intersection.txx.

template<class T >
vgl_box_3d<T> vgl_intersection ( vgl_box_3d< T > const &  b1,
vgl_box_3d< T > const &  b2 
)

Return the intersection of two boxes (which is itself either a box, or empty).

Definition at line 230 of file vgl_intersection.txx.

template<class Type >
bool vgl_intersection ( const vgl_box_2d< Type > &  box,
const vgl_line_2d< Type > &  line,
vgl_point_2d< Type > &  p0,
vgl_point_2d< Type > &  p1 
)

compute the intersection of an infinite line with *this box.

p0 and p1 are the intersection points In the normal case (no degeneracies) there are six possible intersection combinations:

  
                  C01 /    CY     \ C11
                     /     |       \           .
         ymax  -----/------|--------\-----
              |    /       |         \    |
              |   /        |          \   |
              |  /         |           \  | \  .
              | /          |            \ |  \_ Bounding Box
              |/           |             \|
              /            |              \    .
             /|            |              |\   .
             ---------------------------------- CX
            \ |            |              /
             \|            |             /|
              \            |            / |
              |\           |           /  |
              | \          |          /   |
              |  \         |         /    |
         xmin  ---\--------|--------/-----   xmax
         ymin      \       |       /
                C00 \             / C10
   

Definition at line 269 of file vgl_intersection.txx.

template<class Type >
unsigned int vgl_intersection ( const vgl_box_2d< Type > &  box,
const vgl_line_segment_2d< Type > &  line_seg,
vgl_point_2d< Type > &  p0,
vgl_point_2d< Type > &  p1 
)

Returns the number of intersections of a line segment with a box, up to two are returned in p0 and p1.

Definition at line 426 of file vgl_intersection.txx.

template<class T >
vgl_point_3d<T> vgl_intersection ( vgl_line_3d_2_points< T > const &  l1,
vgl_line_3d_2_points< T > const &  l2 
)

Return the intersection point of two concurrent lines.

Allows intersection points outside the line segments Throws an assertion if lines not concurrent

Definition at line 451 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( vgl_line_segment_3d< T > const &  l1,
vgl_line_segment_3d< T > const &  l2,
vgl_point_3d< T > &  i_pnt 
)

Return the intersection point of segments of two concurrent lines.

Return the intersection point of segments of two concurrent lines. Returns false if the intersection point is not inside both line segments.

Definition at line 474 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( vgl_line_3d_2_points< T > const &  l1,
vgl_line_segment_3d< T > const &  l2,
vgl_point_3d< T > &  i_pnt 
)

Return the intersection point of segments of two concurrent lines.

Return the intersection point of segments of a concurrent line and line segment pair. Returns false if the intersection point is not inside both line segments.

Definition at line 495 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( vgl_infinite_line_3d< T > const &  l1,
vgl_infinite_line_3d< T > const &  l2,
vgl_point_3d< T > &  i_pnt 
)

Return the intersection point of two lines, if concurrent.

Return the intersection point of infinite lines, if concurrent.

Definition at line 515 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( vgl_ray_3d< T > const &  r1,
vgl_ray_3d< T > const &  r2,
vgl_point_3d< T > &  i_pnt 
)

Return the intersection point of rays. Returns false if rays are parallel or intersect outside of positive ray domain.

Definition at line 528 of file vgl_intersection.txx.

template<class T >
vgl_point_3d<T> vgl_intersection ( vgl_line_3d_2_points< T > const &  line,
vgl_plane_3d< T > const &  plane 
)

Return the intersection point of a line and a plane.

Definition at line 544 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( vgl_line_segment_3d< T > const &  line,
vgl_plane_3d< T > const &  plane,
vgl_point_3d< T > &  i_pt 
)

Return the intersection point of a line and a plane.

Definition at line 584 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( vgl_infinite_line_3d< T > const &  line,
vgl_plane_3d< T > const &  plane,
vgl_point_3d< T > &  i_pt 
)

Return the intersection point of a line and a plane.

Definition at line 624 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( vgl_ray_3d< T > const &  ray,
vgl_plane_3d< T > const &  plane,
vgl_point_3d< T > &  i_pt 
)

Return the intersection point of a ray and a plane.

Definition at line 662 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( const vgl_line_2d< T > &  line0,
const vgl_line_2d< T > &  line1,
vgl_point_2d< T > &  intersection_point 
)

Return the intersection point of two lines. Return false if lines are parallel.

Definition at line 701 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( vgl_plane_3d< T > const &  plane0,
vgl_plane_3d< T > const &  plane1,
vgl_infinite_line_3d< T > &  line 
)

Return the intersection line of two planes. Returns false if planes.

are effectively parallel

Definition at line 726 of file vgl_intersection.txx.

template<class T >
vgl_point_3d<T> vgl_intersection ( const vgl_plane_3d< T > &  p1,
const vgl_plane_3d< T > &  p2,
const vgl_plane_3d< T > &  p3 
)

Return the intersection point of three planes.

Definition at line 804 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( vgl_point_2d< T > const &  p1,
vgl_point_2d< T > const &  p2,
vgl_point_2d< T > const &  q1,
vgl_point_2d< T > const &  q2,
double  tol 
)

Return true if any point on [p1,p2] is within tol of [q1,q2].

Tests two line segments for intersection or near intersection (within given tolerance).

Author:
Dan jackson

Definition at line 817 of file vgl_intersection.txx.

template<class T >
bool vgl_intersection ( const vgl_box_2d< T > &  b,
const vgl_polygon< T > &  poly 
)

Return true if the box and polygon regions intersect, regions include boundaries.

Definition at line 910 of file vgl_intersection.txx.

template<class T >
vcl_vector<vgl_point_2d<T> > vgl_intersection ( vgl_box_2d< T > const &  b,
vcl_vector< vgl_point_2d< T > > const &  p 
)

Return the points from the list that lie inside the box.

Definition at line 957 of file vgl_intersection.txx.

template<class T >
vcl_vector<vgl_point_2d<T> > vgl_intersection ( vcl_vector< vgl_point_2d< T > > const &  p,
vgl_box_2d< T > const &  b 
)

Return the points from the list that lie inside the box.

Definition at line 971 of file vgl_intersection.txx.

template<class T >
vcl_vector<vgl_point_3d<T> > vgl_intersection ( vgl_box_3d< T > const &  b,
vcl_vector< vgl_point_3d< T > > const &  p 
)

Return the points from the list that lie inside the box.

Definition at line 985 of file vgl_intersection.txx.

template<class T >
vcl_vector<vgl_point_3d<T> > vgl_intersection ( vcl_vector< vgl_point_3d< T > > const &  p,
vgl_box_3d< T > const &  b 
)

Return the points from the list that lie inside the box.

Definition at line 999 of file vgl_intersection.txx.

template<class T >
vcl_vector<vgl_point_2d<T> > vgl_intersection ( vgl_polygon< T > const &  poly,
vgl_line_2d< T > const &  line 
)

Find the intersections of a line with a polygon( can have multiple sheets).

Definition at line 1010 of file vgl_intersection.txx.

bool vgl_near_eq ( double  x,
double  y 
) [inline]

Definition at line 31 of file vgl_intersection.txx.

bool vgl_near_zero ( double  x) [inline]

Definition at line 30 of file vgl_intersection.txx.