2 #ifndef vgl_homg_point_1d_h_ 3 #define vgl_homg_point_1d_h_ 17 # include <vcl_msvc_warnings.h> 38 #if 0 // the compiler defaults are better... 47 set(p.
x(),p.
w());
return *
this; }
52 return this==&p ||
x()*p.
w() ==
w()*p.
x(); }
57 inline T
x()
const {
return x_; }
58 inline T
w()
const {
return w_; }
62 inline void set(T px, T pw) {
x_ = px,
w_ = pw; }
63 inline void set(T
const p[2]) {
x_ = p[0];
w_ = p[1]; }
67 inline bool ideal(T tol = T(0))
const {
68 #define vgl_Abs(x) ((x)<0?-(x):(x)) // avoid #include of vcl_cmath.h AND vcl_cstdlib.h 91 template <
class T>
inline 97 template <
class T>
inline 100 assert(p1.
w() && p2.
w());
101 return p1.
x()/p1.
w()-p2.
x()/p2.
w();
108 template <
class T>
inline 115 template <
class T>
inline 117 { p.
set(p.
x()+
v*p.
w(), p.
w());
return p; }
121 template <
class T>
inline 127 template <
class T>
inline 129 {
return p += (-
v); }
148 template <
class T>
inline 151 {
return (p1.
x()*p3.
w()-p3.
x()*p1.
w())*(p2.
x()*p4.
w()-p4.
x()*p2.
w())
152 /((p1.
x()*p4.
w()-p4.
x()*p1.
w())*(p2.
x()*p3.
w()-p3.
x()*p2.
w())); }
162 template <
class T>
inline 166 {
return (p3-p1)/(p2-p1); }
170 template <
class T>
inline 182 template <
class T>
inline 186 {
return p1 + f*(p2-p1); }
192 template <
class T>
inline 196 if (p1 == p2)
return p1;
203 template <
class T>
inline 209 for (
int i=0; i<n; ++i) x+=
v[i].x()/
v[i].w();
213 #define VGL_HOMG_POINT_1D_INSTANTIATE(T) extern "please include vgl/vgl_homg_point_1d.hxx first" 215 #endif // vgl_homg_point_1d_h_
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.
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.
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.
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.
std::ostream & operator<<(std::ostream &s, vgl_orient_box_3d< Type > const &p)
Write box to stream.
void set(T px, T pw)
Set x,w.
bool operator!=(vgl_homg_point_1d< T > const &p) const
vgl_homg_point_1d(const T v[2])
Construct from homogeneous 2-array.
bool collinear(l const &l1, vgl_homg_point_3d< Type > const &p)
Does a line pass through a point, i.e., are the point and the line collinear?.
bool operator==(vgl_homg_point_1d< T > const &p) const
comparison.
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.
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.
bool is_ideal(l const &line, T tol=(T) 0)
Return true iff line is the line at infinity.
bool ideal(T tol=T(0)) const
Return true iff the point is at infinity (an ideal point).
std::istream & operator>>(std::istream &is, vgl_orient_box_3d< Type > &p)
Read box from stream.
Represents a homogeneous 1-D point, i.e., a homogeneous pair (x,w).
vgl_homg_point_1d()
Default constructor with (0,1).
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.
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.
vgl_homg_point_1d(T px, T pw=T(1))
Construct from one (nonhomogeneous) or two (homogeneous) T's.