Static Public Member Functions | Static Private Member Functions
vgl_homg_operators_2d< T > Class Template Reference

2D homogeneous operations. More...

#include <vgl_homg_operators_2d.h>

List of all members.

Static Public Member Functions

static vnl_vector_fixed< T, 3 > get_vector (vgl_homg_point_2d< T > const &p)
 get a vnl_vector_fixed representation of a homogeneous object.
static vnl_vector_fixed< T, 3 > get_vector (vgl_homg_line_2d< T > const &l)
 get a vnl_vector_fixed representation of a homogeneous object.
static vnl_vector_fixed< T, 6 > get_vector (vgl_conic< T > const &c)
 get a vnl_vector_fixed representation of a homogeneous object.
static void unitize (vgl_homg_point_2d< T > &a)
 Normalize vgl_homg_point_2d<T> to unit magnitude.
static double angle_between_oriented_lines (const vgl_homg_line_2d< T > &line1, const vgl_homg_line_2d< T > &line2)
 Get the angle between two lines, a number between -PI and PI.
static double abs_angle (const vgl_homg_line_2d< T > &line1, const vgl_homg_line_2d< T > &line2)
 Get the 0 to pi/2 angle between two lines.
static T distance (const vgl_homg_point_2d< T > &point1, const vgl_homg_point_2d< T > &point2)
 Get the 2D distance between the two points.
static T distance_squared (const vgl_homg_point_2d< T > &point1, const vgl_homg_point_2d< T > &point2)
 Get the square of the 2D distance between the two points.
static T perp_dist_squared (const vgl_homg_point_2d< T > &point, const vgl_homg_line_2d< T > &line)
 Get the square of the perpendicular distance to a line.
static T perp_dist_squared (const vgl_homg_line_2d< T > &line, const vgl_homg_point_2d< T > &point)
static bool is_within_distance (const vgl_homg_point_2d< T > &p1, const vgl_homg_point_2d< T > &p2, double d)
 True if the points are closer than Euclidean distance d.
static double line_angle (const vgl_homg_line_2d< T > &line)
 Get the anticlockwise angle between a line and the x axis.
static vgl_homg_line_2d< T > join (const vgl_homg_point_2d< T > &point1, const vgl_homg_point_2d< T > &point2)
 Get the line through two points (the cross-product).
static vgl_homg_line_2d< T > join_oriented (const vgl_homg_point_2d< T > &point1, const vgl_homg_point_2d< T > &point2)
 Get the line through two points (the cross-product).
static vgl_homg_point_2d< T > intersection (const vgl_homg_line_2d< T > &line1, const vgl_homg_line_2d< T > &line2)
 Get the intersection point of two lines (the cross-product).
static vgl_homg_line_2d< T > perp_line_through_point (const vgl_homg_line_2d< T > &line, const vgl_homg_point_2d< T > &point)
 Get the perpendicular line to line which passes through point.
static vgl_homg_point_2d< T > perp_projection (const vgl_homg_line_2d< T > &line, const vgl_homg_point_2d< T > &point)
 Get the perpendicular projection of point onto line.
static vgl_homg_point_2d< T > midpoint (const vgl_homg_point_2d< T > &p1, const vgl_homg_point_2d< T > &p2)
 Return the midpoint of the line joining two homogeneous points.
static vgl_homg_point_2d< T > lines_to_point (const vcl_vector< vgl_homg_line_2d< T > > &lines)
 Intersect a set of 2D lines to find the least-square point of intersection.
static double cross_ratio (const vgl_homg_point_2d< T > &p1, const vgl_homg_point_2d< T > &p2, const vgl_homg_point_2d< T > &p3, const vgl_homg_point_2d< T > &p4)
 cross ratio of four collinear points.
static vgl_homg_point_2d< T > conjugate (const vgl_homg_point_2d< T > &a, const vgl_homg_point_2d< T > &b, const vgl_homg_point_2d< T > &c, double cr=-1.0)
 Conjugate point of three given collinear points.
static vnl_vector_fixed< T, 3 > most_orthogonal_vector (const vcl_vector< vgl_homg_line_2d< T > > &lines)
 compute most orthogonal vector with vnl_symmetric_eigensystem.
static vnl_vector_fixed< T, 3 > most_orthogonal_vector_svd (const vcl_vector< vgl_homg_line_2d< T > > &lines)
 compute most orthogonal vector with SVD.
static vgl_conic< T > vgl_conic_from_matrix (vnl_matrix_fixed< T, 3, 3 > const &mat)
 returns the vgl_conic which has the given matrix as its matrix.
static vnl_matrix_fixed< T, 3, 3 > matrix_from_conic (vgl_conic< T > const &)
 returns 3x3 matrix containing conic coefficients.
static vnl_matrix_fixed< T, 3, 3 > matrix_from_dual_conic (vgl_conic< T > const &)
 returns 3x3 matrix containing conic coefficients of dual conic.
static vcl_list
< vgl_homg_point_2d< T > > 
intersection (vgl_conic< T > const &c, vgl_homg_line_2d< T > const &l)
 Find all real intersection points of a conic and a line (between 0 and 2, including points at infinity).
static vcl_list
< vgl_homg_point_2d< T > > 
intersection (vgl_conic< T > const &c1, vgl_conic< T > const &c2)
 Find all real intersection points of two conics (between 0 and 4, including points at infinity).
static vcl_list
< vgl_homg_line_2d< T > > 
tangent_from (vgl_conic< T > const &c, vgl_homg_point_2d< T > const &p)
 Return the (at most) two tangent lines that pass through p and are tangent to the conic.
static vcl_list
< vgl_homg_line_2d< T > > 
common_tangents (vgl_conic< T > const &c1, vgl_conic< T > const &c2)
 Return the list of common tangent lines of two conics.
static vgl_homg_point_2d< T > closest_point (vgl_homg_line_2d< T > const &l, vgl_homg_point_2d< T > const &p)
 Return the point on the line closest to the given point.
static vgl_homg_point_2d< T > closest_point (vgl_conic< T > const &c, vgl_homg_point_2d< T > const &p)
 Return the point on the conic closest to the given point.
static vgl_homg_point_2d< T > closest_point (vgl_conic< T > const &c, vgl_point_2d< T > const &p)
 Return the point on the conic closest to the given point.
static T distance_squared (vgl_conic< T > const &c, vgl_homg_point_2d< T > const &p)
 Return the shortest squared distance between the conic and the point.
static vgl_box_2d< T > compute_bounding_box (vgl_conic< T > const &c)
 Compute the bounding box of an ellipse.

Static Private Member Functions

static vcl_list
< vgl_homg_point_2d< T > > 
do_intersect (vgl_conic< T > const &q, vgl_homg_line_2d< T > const &l)
 This function is called from within intersection(vgl_conic<T>,vgl_homg_line_2d<T>).
static vcl_list
< vgl_homg_point_2d< T > > 
do_intersect (vgl_conic< T > const &c1, vgl_conic< T > const &c2)
 This function is called from within intersection(vgl_conic<T>,vgl_conic<T>).

Detailed Description

template<class T>
class vgl_homg_operators_2d< T >

2D homogeneous operations.

Definition at line 32 of file vgl_homg_operators_2d.h.


Member Function Documentation

template<class T >
double vgl_homg_operators_2d< T >::abs_angle ( const vgl_homg_line_2d< T > &  line1,
const vgl_homg_line_2d< T > &  line2 
) [static]

Get the 0 to pi/2 angle between two lines.

Definition at line 162 of file vgl_homg_operators_2d.txx.

template<class T >
double vgl_homg_operators_2d< T >::angle_between_oriented_lines ( const vgl_homg_line_2d< T > &  line1,
const vgl_homg_line_2d< T > &  line2 
) [static]

Get the angle between two lines, a number between -PI and PI.

Although homogeneous coordinates are only defined up to scale, here it is assumed that a line with homogeneous coordinates (m) is at 180 degrees to a line (-m), and this is why the term "oriented_line" is used. However, the overall scale (apart from sign) is not significant.

Definition at line 185 of file vgl_homg_operators_2d.txx.

template<class T >
vgl_homg_point_2d< T > vgl_homg_operators_2d< T >::closest_point ( vgl_homg_line_2d< T > const &  l,
vgl_homg_point_2d< T > const &  p 
) [static]

Return the point on the line closest to the given point.

Definition at line 916 of file vgl_homg_operators_2d.txx.

template<class T >
vgl_homg_point_2d< T > vgl_homg_operators_2d< T >::closest_point ( vgl_conic< T > const &  c,
vgl_homg_point_2d< T > const &  p 
) [static]

Return the point on the conic closest to the given point.

Definition at line 768 of file vgl_homg_operators_2d.txx.

template<class T >
vgl_homg_point_2d< T > vgl_homg_operators_2d< T >::closest_point ( vgl_conic< T > const &  c,
vgl_point_2d< T > const &  pt 
) [static]

Return the point on the conic closest to the given point.

Still return a homogeneous point, even if the argument is non-homogeneous.

Definition at line 831 of file vgl_homg_operators_2d.txx.

template<class T >
vcl_list< vgl_homg_line_2d< T > > vgl_homg_operators_2d< T >::common_tangents ( vgl_conic< T > const &  c1,
vgl_conic< T > const &  c2 
) [static]

Return the list of common tangent lines of two conics.

This is done by finding the intersection points of the two dual conics, which are the duals of the common tangent lines. If one of the conics is degenerate, an empty list is returned.

Definition at line 748 of file vgl_homg_operators_2d.txx.

template<class T >
vgl_box_2d< T > vgl_homg_operators_2d< T >::compute_bounding_box ( vgl_conic< T > const &  c) [static]

Compute the bounding box of an ellipse.

This is done by finding the tangent lines to the ellipse from the two points at infinity (1,0,0) and (0,1,0).

Definition at line 842 of file vgl_homg_operators_2d.txx.

template<class T >
vgl_homg_point_2d< T > vgl_homg_operators_2d< T >::conjugate ( const vgl_homg_point_2d< T > &  a,
const vgl_homg_point_2d< T > &  b,
const vgl_homg_point_2d< T > &  c,
double  cr = -1.0 
) [static]

Conjugate point of three given collinear points.

If cross ratio cr is given (default: -1), the generalized conjugate point returned is such that the cross ratio ((x1,x2;x3,answer)) = cr.

If cross ratio cr is given (default: -1), the generalized conjugate point returned is such that ((x1,x2;x3,answer)) = cr.

Definition at line 382 of file vgl_homg_operators_2d.txx.

template<class T >
double vgl_homg_operators_2d< T >::cross_ratio ( const vgl_homg_point_2d< T > &  a,
const vgl_homg_point_2d< T > &  b,
const vgl_homg_point_2d< T > &  c,
const vgl_homg_point_2d< T > &  d 
) [static]

cross ratio of four collinear points.

Calculates the crossratio of four collinear points p1, p2, p3 and p4.

This number is projectively invariant, and it is the coordinate of p4 in the reference frame where p2 is the origin (coordinate 0), p3 is the unity (coordinate 1) and p1 is the point at infinity. This cross ratio is often denoted as ((p1, p2; p3, p4)) (which also equals ((p3, p4; p1, p2)) or ((p2, p1; p4, p3)) or ((p4, p3; p2, p1)) ) and is calculated as

                        p1 - p3   p2 - p3      (p1-p3)(p2-p4)
                        ------- : --------  =  --------------
                        p1 - p4   p2 - p4      (p1-p4)(p2-p3)
   

In principle, any single nonhomogeneous coordinate from the four points can be used as parameters for cross_ratio (but of course the same for all points). The most reliable answer will be obtained when the coordinate with the largest spacing is used, i.e., the one with smallest slope.

In this implementation, a least-squares result is calculated when the points are not exactly collinear.

This number is projectively invariant, and it is the coordinate of p4 in the reference frame where p2 is the origin (coordinate 0), p3 is the unity (coordinate 1) and p1 is the point at infinity. This cross ratio is often denoted as ((p1, p2; p3, p4)) (which also equals ((p3, p4; p1, p2)) or ((p2, p1; p4, p3)) or ((p4, p3; p2, p1)) ) and is calculated as

                        p1 - p3   p2 - p3      (p1-p3)(p2-p4)
                        ------- : --------  =  --------------
                        p1 - p4   p2 - p4      (p1-p4)(p2-p3)
   

In principle, any single nonhomogeneous coordinate from the four points can be used as parameters for cross_ratio (but of course the same for all points). The most reliable answer will be obtained when the coordinate with the largest spacing is used, i.e., the one with smallest slope.

Definition at line 359 of file vgl_homg_operators_2d.txx.

template<class T >
T vgl_homg_operators_2d< T >::distance ( const vgl_homg_point_2d< T > &  point1,
const vgl_homg_point_2d< T > &  point2 
) [static]

Get the 2D distance between the two points.

Definition at line 102 of file vgl_homg_operators_2d.txx.

template<class T >
T vgl_homg_operators_2d< T >::distance_squared ( const vgl_homg_point_2d< T > &  point1,
const vgl_homg_point_2d< T > &  point2 
) [static]

Get the square of the 2D distance between the two points.

Definition at line 110 of file vgl_homg_operators_2d.txx.

template<class T >
static T vgl_homg_operators_2d< T >::distance_squared ( vgl_conic< T > const &  c,
vgl_homg_point_2d< T > const &  p 
) [inline, static]

Return the shortest squared distance between the conic and the point.

Definition at line 193 of file vgl_homg_operators_2d.h.

template<class T >
vcl_list< vgl_homg_point_2d< T > > vgl_homg_operators_2d< T >::do_intersect ( vgl_conic< T > const &  q,
vgl_homg_line_2d< T > const &  l 
) [static, private]

This function is called from within intersection(vgl_conic<T>,vgl_homg_line_2d<T>).

The conic passed to this function MUST NOT be degenerate!

Definition at line 581 of file vgl_homg_operators_2d.txx.

template<class T >
vcl_list< vgl_homg_point_2d< T > > vgl_homg_operators_2d< T >::do_intersect ( vgl_conic< T > const &  c1,
vgl_conic< T > const &  c2 
) [static, private]

This function is called from within intersection(vgl_conic<T>,vgl_conic<T>).

The two conics passed to this function MUST NOT be degenerate!

Definition at line 453 of file vgl_homg_operators_2d.txx.

template<class T >
vnl_vector_fixed< T, 3 > vgl_homg_operators_2d< T >::get_vector ( vgl_homg_point_2d< T > const &  p) [static]

get a vnl_vector_fixed representation of a homogeneous object.

Definition at line 58 of file vgl_homg_operators_2d.txx.

template<class T >
vnl_vector_fixed< T, 3 > vgl_homg_operators_2d< T >::get_vector ( vgl_homg_line_2d< T > const &  l) [static]

get a vnl_vector_fixed representation of a homogeneous object.

Definition at line 64 of file vgl_homg_operators_2d.txx.

template<class T >
vnl_vector_fixed< T, 6 > vgl_homg_operators_2d< T >::get_vector ( vgl_conic< T > const &  c) [static]

get a vnl_vector_fixed representation of a homogeneous object.

Definition at line 70 of file vgl_homg_operators_2d.txx.

template<class T >
vgl_homg_point_2d< T > vgl_homg_operators_2d< T >::intersection ( const vgl_homg_line_2d< T > &  line1,
const vgl_homg_line_2d< T > &  line2 
) [static]

Get the intersection point of two lines (the cross-product).

Definition at line 230 of file vgl_homg_operators_2d.txx.

template<class T >
vcl_list< vgl_homg_point_2d< T > > vgl_homg_operators_2d< T >::intersection ( vgl_conic< T > const &  c,
vgl_homg_line_2d< T > const &  l 
) [static]

Find all real intersection points of a conic and a line (between 0 and 2, including points at infinity).

Return the (real) intersection points of a conic and a line.

Definition at line 640 of file vgl_homg_operators_2d.txx.

template<class T >
vcl_list< vgl_homg_point_2d< T > > vgl_homg_operators_2d< T >::intersection ( vgl_conic< T > const &  c1,
vgl_conic< T > const &  c2 
) [static]

Find all real intersection points of two conics (between 0 and 4, including points at infinity).

Definition at line 668 of file vgl_homg_operators_2d.txx.

template<class T >
static bool vgl_homg_operators_2d< T >::is_within_distance ( const vgl_homg_point_2d< T > &  p1,
const vgl_homg_point_2d< T > &  p2,
double  d 
) [inline, static]

True if the points are closer than Euclidean distance d.

Definition at line 74 of file vgl_homg_operators_2d.h.

template<class T >
vgl_homg_line_2d< T > vgl_homg_operators_2d< T >::join ( const vgl_homg_point_2d< T > &  point1,
const vgl_homg_point_2d< T > &  point2 
) [static]

Get the line through two points (the cross-product).

Definition at line 200 of file vgl_homg_operators_2d.txx.

template<class T >
vgl_homg_line_2d< T > vgl_homg_operators_2d< T >::join_oriented ( const vgl_homg_point_2d< T > &  p1,
const vgl_homg_point_2d< T > &  p2 
) [static]

Get the line through two points (the cross-product).

In this case, we assume that the points are oriented, and ensure the cross is computed with positive point omegas.

Definition at line 213 of file vgl_homg_operators_2d.txx.

template<class T >
double vgl_homg_operators_2d< T >::line_angle ( const vgl_homg_line_2d< T > &  line) [static]

Get the anticlockwise angle between a line and the x axis.

Definition at line 153 of file vgl_homg_operators_2d.txx.

template<class T >
vgl_homg_point_2d< T > vgl_homg_operators_2d< T >::lines_to_point ( const vcl_vector< vgl_homg_line_2d< T > > &  lines) [static]

Intersect a set of 2D lines to find the least-square point of intersection.

This finds the point $\bf x$ that minimizes $\|\tt L \bf x\|$, where $\tt L$ is the matrix whose rows are the lines. The implementation uses either vnl_scatter_3x3 (default) or vnl_svd (when at compile time VGL_HOMG_OPERATORS_2D_LINES_TO_POINT_USE_SVD has been set) to accumulate and compute the nullspace of $\tt L^\top \tt L$.

Definition at line 325 of file vgl_homg_operators_2d.txx.

template<class T >
vnl_matrix_fixed< T, 3, 3 > vgl_homg_operators_2d< T >::matrix_from_conic ( vgl_conic< T > const &  c) [static]

returns 3x3 matrix containing conic coefficients.

   [A,B,C,D,E,F] ->   [ A  B/2 D/2 ]
                      [ B/2 C  E/2 ]
                      [ D/2 E/2 F  ]
   

Definition at line 418 of file vgl_homg_operators_2d.txx.

template<class T >
vnl_matrix_fixed< T, 3, 3 > vgl_homg_operators_2d< T >::matrix_from_dual_conic ( vgl_conic< T > const &  c) [static]

returns 3x3 matrix containing conic coefficients of dual conic.

I.e., the inverse matrix (up to a scale factor) of the conic matrix.

Definition at line 436 of file vgl_homg_operators_2d.txx.

template<class T >
vgl_homg_point_2d< T > vgl_homg_operators_2d< T >::midpoint ( const vgl_homg_point_2d< T > &  p1,
const vgl_homg_point_2d< T > &  p2 
) [static]

Return the midpoint of the line joining two homogeneous points.

When one of the points is at infinity, that point is returned. When both points are at infinity, the invalid point (0,0,0) is returned.

Definition at line 271 of file vgl_homg_operators_2d.txx.

template<class T >
vnl_vector_fixed< T, 3 > vgl_homg_operators_2d< T >::most_orthogonal_vector ( const vcl_vector< vgl_homg_line_2d< T > > &  lines) [static]

compute most orthogonal vector with vnl_symmetric_eigensystem.

Definition at line 286 of file vgl_homg_operators_2d.txx.

template<class T >
vnl_vector_fixed< T, 3 > vgl_homg_operators_2d< T >::most_orthogonal_vector_svd ( const vcl_vector< vgl_homg_line_2d< T > > &  lines) [static]

compute most orthogonal vector with SVD.

Definition at line 301 of file vgl_homg_operators_2d.txx.

template<class T >
T vgl_homg_operators_2d< T >::perp_dist_squared ( const vgl_homg_point_2d< T > &  point,
const vgl_homg_line_2d< T > &  line 
) [static]

Get the square of the perpendicular distance to a line.

This is just the homogeneous form of the familiar $ \frac{a x + b y + c}{\sqrt{a^2+b^2}} $ : \[ d = {(l^ p)}{p_z{l_x^2 + l_y^2}} \] If either the point or the line are at infinity an error message is printed and Homg::infinity is returned.

This is just the homogeneous form of the familiar $ \frac{a x + b y + c}{\sqrt{a^2+b^2}} $ :

\[ d = \frac{(l^\top p)}{p_z\sqrt{l_x^2 + l_y^2}} \]

If either the point or the line are at infinity an error message is printed and vgl_homg::infinity is returned.

Definition at line 132 of file vgl_homg_operators_2d.txx.

template<class T >
static T vgl_homg_operators_2d< T >::perp_dist_squared ( const vgl_homg_line_2d< T > &  line,
const vgl_homg_point_2d< T > &  point 
) [inline, static]

Definition at line 69 of file vgl_homg_operators_2d.h.

template<class T >
vgl_homg_line_2d< T > vgl_homg_operators_2d< T >::perp_line_through_point ( const vgl_homg_line_2d< T > &  l,
const vgl_homg_point_2d< T > &  p 
) [static]

Get the perpendicular line to line which passes through point.

Params are line $(a,b,c)$ and point $(x,y,1)$. Then the cross product of $(x,y,1)$ and the line's direction $(a,b,0)$, called $(p,q,r)$ satisfies

$ap+bq=0$ (perpendicular condition) and

$px+qy+r=0$ (incidence condition).

Params are line $(a,b,c)$ and point $(x,y,1)$. Then the cross product of $(x,y,1)$ and the line's direction $(a,b,0)$, called $(p,q,r)$ satisfies

  • $ap+bq=0$ (perpendicular condition) and
  • $px+qy+r=0$ (incidence condition).

Definition at line 246 of file vgl_homg_operators_2d.txx.

template<class T >
vgl_homg_point_2d< T > vgl_homg_operators_2d< T >::perp_projection ( const vgl_homg_line_2d< T > &  line,
const vgl_homg_point_2d< T > &  point 
) [static]

Get the perpendicular projection of point onto line.

Definition at line 258 of file vgl_homg_operators_2d.txx.

template<class T >
vcl_list< vgl_homg_line_2d< T > > vgl_homg_operators_2d< T >::tangent_from ( vgl_conic< T > const &  c,
vgl_homg_point_2d< T > const &  p 
) [static]

Return the (at most) two tangent lines that pass through p and are tangent to the conic.

For points on the conic, exactly 1 line is returned: the tangent at that point. For points inside the conic, an empty list is returned. For points outside the conic, there are always two tangents returned. Found by intersecting the dual conic with the dual line. If the conic is degenerate, an empty list is returned, unless the point is on the conic (in which case the component is returned to which it belongs, or even both components in the exclusive case that the point is the centre).

Definition at line 716 of file vgl_homg_operators_2d.txx.

template<class T >
void vgl_homg_operators_2d< T >::unitize ( vgl_homg_point_2d< T > &  a) [static]

Normalize vgl_homg_point_2d<T> to unit magnitude.

Definition at line 86 of file vgl_homg_operators_2d.txx.

template<class T >
vgl_conic< T > vgl_homg_operators_2d< T >::vgl_conic_from_matrix ( vnl_matrix_fixed< T, 3, 3 > const &  mat) [static]

returns the vgl_conic which has the given matrix as its matrix.

   [A,B,C,D,E,F] <-   [ A  B/2 D/2 ]
                      [ B/2 C  E/2 ]
                      [ D/2 E/2 F  ]
   

Definition at line 404 of file vgl_homg_operators_2d.txx.


The documentation for this class was generated from the following files: