2 #ifndef vgl_homg_operators_1d_hxx_ 3 #define vgl_homg_operators_1d_hxx_ 8 #include <vnl/vnl_vector_fixed.h> 9 #include <vnl/vnl_matrix_fixed.h> 12 # include <vcl_msvc_warnings.h> 18 return vnl_vector_fixed<T,2>(p.
x(),p.
w());
27 T x1 = a.
x(), w1 = a.
w();
28 T x2 = b.
x(), w2 = b.
w();
29 T x3 = c.
x(), w3 = c.
w();
30 T x4 = d.
x(), w4 = d.
w();
31 T n = (x1*w3-x3*w1)*(x2*w4-x4*w2);
32 T m = (x1*w4-x4*w1)*(x2*w3-x3*w2);
34 std::cerr <<
"cross_ratio not defined: three of the given points coincide\n";
41 T x1 = a.
x(), w1 = a.
w();
42 T x2 = b.
x(), w2 = b.
w();
49 T x1 = a.
x(), w1 = a.
w();
50 T x2 = b.
x(), w2 = b.
w();
57 double norm = std::sqrt (a.
x()*a.
x() + a.
w()*a.
w());
59 std::cerr <<
"vgl_homg_operators_1d<T>::unitize() -- Zero length vector\n";
63 a.
set(T(a.
x()*norm), T(a.
w()*norm));
70 T x1 = a.
x(), w1 = a.
w();
71 T x2 = b.
x(), w2 = b.
w();
72 if (w1 == 0 || w2 == 0) {
73 std::cerr <<
"vgl_homg_operators_1d<T>::distance() -- point at infinity";
77 return (x1 > x2) ? x1-x2 : x2-x1;
84 T d = distance(point1,point2);
92 T x1 = a.
x(), w1 = a.
w();
93 T x2 = b.
x(), w2 = b.
w();
101 T a = x1 - x3; T b = x2 - x3; T c = T(a-cr*b);
103 return T((x2*a-cr*x1*b)/c);
113 T x1 = a.
x(), w1 = a.
w();
114 T x2 = b.
x(), w2 = b.
w();
115 T x3 = c.
x(), w3 = c.
w();
116 T k = x1*w3 - x3*w1, m = x2*w3 - x3*w2;
126 m(1,0)*p.
x()+m(1,1)*p.
w());
129 #undef VGL_HOMG_OPERATORS_1D_INSTANTIATE 130 #define VGL_HOMG_OPERATORS_1D_INSTANTIATE(T) \ 131 template class vgl_homg_operators_1d<T >; \ 132 template vgl_homg_point_1d<T > operator*(vnl_matrix_fixed<T,2,2> const& m, vgl_homg_point_1d<T > const& p) 134 #endif // vgl_homg_operators_1d_hxx_ static void unitize(vgl_homg_point_1d< T > &a)
Normalize vgl_homg_point_1d<T> to unit magnitude.
static T cross(const vgl_homg_point_1d< T > &a, const vgl_homg_point_1d< T > &b)
Cross product of two homogeneous points.
static T conjugate(T x1, T x2, T x3, double cr=-1)
Calculate the projective conjugate point of three given points.
static double cross_ratio(const vgl_homg_point_1d< T > &a, const vgl_homg_point_1d< T > &b, const vgl_homg_point_1d< T > &c, const vgl_homg_point_1d< T > &d)
cross ratio of four 1D points.
void set(T px, T pw)
Set x,w.
General purpose support class for vgl_homg_ classes.
static vnl_vector_fixed< T, 2 > get_vector(vgl_homg_point_1d< T > const &p)
get a vnl_vector_fixed representation of a homogeneous object.
static T dot(const vgl_homg_point_1d< T > &a, const vgl_homg_point_1d< T > &b)
Dot product of two homogeneous points.
static T distance_squared(const vgl_homg_point_1d< T > &point1, const vgl_homg_point_1d< T > &point2)
Get the square of the distance between the two points.
vgl_homg_point_1d< T > operator *(vnl_matrix_fixed< T, 2, 2 > const &m, vgl_homg_point_1d< T > const &p)
Transform a point through a 2x2 projective transformation matrix.
General purpose support class for vgl_homg_ classes.
Represents a homogeneous 1-D point, i.e., a homogeneous pair (x,w).
static T distance(const vgl_homg_point_1d< T > &point1, const vgl_homg_point_1d< T > &point2)
Get the distance between the two points.
static vgl_homg_point_1d< T > midpoint(const vgl_homg_point_1d< T > &p1, const vgl_homg_point_1d< T > &p2)
Return the midpoint of two homogeneous points.