Classes | Defines | Functions
core/vgl/vgl_homg_point_1d.h File Reference

a point in homogeneous 1-D space, i.e., a homogeneous pair (x,w) More...

#include <vcl_iosfwd.h>
#include <vcl_cassert.h>
#include <vcl_vector.h>

Go to the source code of this file.

Classes

class  vgl_homg_point_1d< T >
 Represents a homogeneous 1-D point, i.e., a homogeneous pair (x,w). More...

Defines

#define vgl_Abs(x)   (x<0?-x:x)
#define VGL_HOMG_POINT_1D_INSTANTIATE(T)   extern "please include vgl/vgl_homg_point_1d.txx first"

Functions

template<class T >
vcl_ostream & operator<< (vcl_ostream &s, vgl_homg_point_1d< T > const &p)
 Write "<vgl_homg_point_1d (x,w) > " to stream.
template<class T >
vcl_istream & operator>> (vcl_istream &s, vgl_homg_point_1d< T > &p)
 Read x w from stream.
template<class T >
bool is_ideal (vgl_homg_point_1d< T > const &p, T tol=T(0))
 Return true iff the point is at infinity (an ideal point).
template<class T >
operator- (vgl_homg_point_1d< T > const &p1, vgl_homg_point_1d< T > const &p2)
 The difference of two points is the distance between the two.
template<class T >
vgl_homg_point_1d< T > operator+ (vgl_homg_point_1d< T > const &p, T v)
 Adding a number to a 1-D point translates that point.
template<class T >
vgl_homg_point_1d< T > & operator+= (vgl_homg_point_1d< T > &p, T v)
 Adding a number to a 1-D point translates that point.
template<class T >
vgl_homg_point_1d< T > operator- (vgl_homg_point_1d< T > const &p, T v)
 Subtracting a number from a point is the same as adding the inverse number.
template<class T >
vgl_homg_point_1d< T > & operator-= (vgl_homg_point_1d< T > &p, T v)
 Subtracting a number from a point is the same as adding the inverse number.
template<class T >
double cross_ratio (vgl_homg_point_1d< T >const &p1, vgl_homg_point_1d< T >const &p2, vgl_homg_point_1d< T >const &p3, vgl_homg_point_1d< T >const &p4)
 cross ratio of four points.
template<class T >
double ratio (vgl_homg_point_1d< T > const &p1, vgl_homg_point_1d< T > const &p2, vgl_homg_point_1d< T > const &p3)
 Return the relative distance to p1 wrt p1-p2 of p3.
template<class T >
bool collinear (vgl_homg_point_1d< T > const &, vgl_homg_point_1d< T > const &, vgl_homg_point_1d< T > const &)
 Are three points collinear? This is always true.
template<class T >
vgl_homg_point_1d< T > midpoint (vgl_homg_point_1d< T > const &p1, vgl_homg_point_1d< T > const &p2, T f=0.5)
 Return the point at a given ratio wrt two other points.
template<class T >
vgl_homg_point_1d< T > centre (vgl_homg_point_1d< T > const &p1, vgl_homg_point_1d< T > const &p2)
 Return the point at the centre of gravity of two given points.
template<class T >
vgl_homg_point_1d< T > centre (vcl_vector< vgl_homg_point_1d< T > > const &v)
 Return the point at the centre of gravity of a set of given points.

Detailed Description

a point in homogeneous 1-D space, i.e., a homogeneous pair (x,w)

Author:
Peter Vanroose
Date:
8 July 2001
   Modifications
   

Definition in file vgl_homg_point_1d.h.


Define Documentation

#define vgl_Abs (   x)    (x<0?-x:x)
#define VGL_HOMG_POINT_1D_INSTANTIATE (   T)    extern "please include vgl/vgl_homg_point_1d.txx first"

Definition at line 213 of file vgl_homg_point_1d.h.


Function Documentation

template<class T >
vgl_homg_point_1d< T > centre ( vgl_homg_point_1d< T > const &  p1,
vgl_homg_point_1d< T > const &  p2 
) [inline]

Return the point at the centre of gravity of two given points.

Identical to midpoint(p1,p2). If one point or both points are at infinity, that point is returned.

Definition at line 193 of file vgl_homg_point_1d.h.

template<class T >
vgl_homg_point_1d< T > centre ( vcl_vector< vgl_homg_point_1d< T > > const &  v) [inline]

Return the point at the centre of gravity of a set of given points.

There are no rounding errors when T is e.g. int, if all w() are 1.

Definition at line 204 of file vgl_homg_point_1d.h.

template<class T >
bool collinear ( vgl_homg_point_1d< T > const &  ,
vgl_homg_point_1d< T > const &  ,
vgl_homg_point_1d< T > const &   
) [inline]

Are three points collinear? This is always true.

Definition at line 171 of file vgl_homg_point_1d.h.

template<class T >
double cross_ratio ( vgl_homg_point_1d< T >const &  p1,
vgl_homg_point_1d< T >const &  p2,
vgl_homg_point_1d< T >const &  p3,
vgl_homg_point_1d< T >const &  p4 
) [inline]

cross ratio of four points.

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)
   

If three of the given points coincide, the cross ratio is not defined.

Definition at line 149 of file vgl_homg_point_1d.h.

template<class T >
bool is_ideal ( vgl_homg_point_1d< T > const &  p,
tol = T(0) 
) [inline]

Return true iff the point is at infinity (an ideal point).

The method checks whether |w| <= tol * |x|

Definition at line 92 of file vgl_homg_point_1d.h.

template<class T >
vgl_homg_point_1d< T > midpoint ( vgl_homg_point_1d< T > const &  p1,
vgl_homg_point_1d< T > const &  p2,
f = 0.5 
) [inline]

Return the point at a given ratio wrt two other points.

By default, the mid point (ratio=0.5) is returned. Note that the third argument is T, not double, so the midpoint of e.g. two vgl_homg_point_1d<int> is not a valid concept. But the reflection point of p2 wrt p1 is: in that case f=-1.

Definition at line 183 of file vgl_homg_point_1d.h.

template<class T >
vgl_homg_point_1d< T > operator+ ( vgl_homg_point_1d< T > const &  p,
v 
) [inline]

Adding a number to a 1-D point translates that point.

If the point is at infinity, nothing happens. Note that number + point is not defined! It's always point + number.

Definition at line 109 of file vgl_homg_point_1d.h.

template<class T >
vgl_homg_point_1d< T > & operator+= ( vgl_homg_point_1d< T > &  p,
v 
) [inline]

Adding a number to a 1-D point translates that point.

If the point is at infinity, nothing happens.

Definition at line 116 of file vgl_homg_point_1d.h.

template<class T >
T operator- ( vgl_homg_point_1d< T > const &  p1,
vgl_homg_point_1d< T > const &  p2 
) [inline]

The difference of two points is the distance between the two.

This function is only valid if the points are not at infinity.

Definition at line 98 of file vgl_homg_point_1d.h.

template<class T >
vgl_homg_point_1d< T > operator- ( vgl_homg_point_1d< T > const &  p,
v 
) [inline]

Subtracting a number from a point is the same as adding the inverse number.

Definition at line 122 of file vgl_homg_point_1d.h.

template<class T >
vgl_homg_point_1d< T > & operator-= ( vgl_homg_point_1d< T > &  p,
v 
) [inline]

Subtracting a number from a point is the same as adding the inverse number.

Definition at line 128 of file vgl_homg_point_1d.h.

template<class T >
vcl_ostream & operator<< ( vcl_ostream &  s,
vgl_homg_point_1d< T > const &  p 
)

Write "<vgl_homg_point_1d (x,w) > " to stream.

template<class T >
vcl_istream & operator>> ( vcl_istream &  s,
vgl_homg_point_1d< T > &  p 
)

Read x w from stream.

template<class T >
double ratio ( vgl_homg_point_1d< T > const &  p1,
vgl_homg_point_1d< T > const &  p2,
vgl_homg_point_1d< T > const &  p3 
) [inline]

Return the relative distance to p1 wrt p1-p2 of p3.

p2 should not equal p1. This is the coordinate of p3 in the affine 1D reference frame (p1,p2). If p3=p1, the ratio is 0; if p1=p3, the ratio is 1. The mid point of p1 and p2 has ratio 0.5. Note that the return type is double, not T, since the ratio of e.g. two int's need not be an int.

Definition at line 163 of file vgl_homg_point_1d.h.