2 #ifndef vgl_homg_point_2d_h_ 3 #define vgl_homg_point_2d_h_ 21 # include <vcl_msvc_warnings.h> 43 :
x_(px),
y_(py),
w_(pw) {}
79 (
x()*p.
w()==
w()*p.
x() &&
y()*p.
w()==
w()*p.
y() &&
y()*p.
x()==
x()*p.
y());
86 inline T
x()
const {
return x_; }
87 inline T
y()
const {
return y_; }
88 inline T
w()
const {
return w_; }
92 inline void set(T px, T py, T pw = (T)1)
93 {
x_ = px,
y_ = py,
w_ = pw; }
95 inline void set(T
const p[3]) {
x_ = p[0];
y_ = p[1];
w_ = p[2]; }
99 inline bool ideal(T tol = (T)0)
const 101 #define vgl_Abs(x) ((x)<0?-(x):(x)) // avoid #include of vcl_cmath.h AND vcl_cstdlib.h 125 template <
class T>
inline 131 template <
class T>
inline 135 assert(p1.
w() && p2.
w());
137 p1.
y()/p1.
w()-p2.
y()/p2.
w());
144 template <
class T>
inline 152 template <
class T>
inline 155 { p.
set(p.
x()+
v.x()*p.
w(), p.
y()+
v.y()*p.
w(), p.
w());
return p; }
159 template <
class T>
inline 166 template <
class T>
inline 169 {
return p += (-
v); }
197 template <
class T>
inline 202 return (p1.
x()*p2.
y()-p1.
y()*p2.
x())*p3.
w()
203 +(p3.
x()*p1.
y()-p3.
y()*p1.
x())*p2.
w()
204 +(p2.
x()*p3.
y()-p2.
y()*p3.
x())*p1.
w()==0;
215 template <
class T>
inline 219 {
return (p3-p1)/(p2-p1); }
226 template <
class T>
inline 230 {
return p1 + f*(p2-p1); }
238 template <
class T>
inline 243 p1.
y()*p2.
w() + p2.
y()*p1.
w(),
250 template <
class T>
inline 256 for (
int i=0; i<n; ++i) x+=
v[i].x()/
v[i].w(), y+=
v[i].y()/
v[i].w();
260 #define VGL_HOMG_POINT_2D_INSTANTIATE(T) extern "please include vgl/vgl_homg_point_2d.hxx first" 262 #endif // vgl_homg_point_2d_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.
a point in 2D nonhomogeneous space
Represents a homogeneous 2D line.
Direction vector in Euclidean 2D space, templated by type of element.
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.
bool ideal(T tol=(T) 0) const
Return true iff the point is at infinity (an ideal point).
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.
vgl_homg_point_2d(vgl_vector_2d< T >const &v)
Construct point at infinity from direction vector.
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_2d< T > const &p) const
the comparison operator.
vgl_homg_point_2d(T px, T py, T pw=(T) 1)
Construct from two (nonhomogeneous) or three (homogeneous) Types.
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 operator!=(vgl_homg_point_2d< T > const &other) const
bool is_ideal(l const &line, T tol=(T) 0)
Return true iff line is the line at infinity.
direction vector in Euclidean 2D space
void set(T px, T py, T pw=(T) 1)
Set x,y,w.
vgl_homg_point_2d(const T v[3])
Construct from homogeneous 3-array.
std::istream & operator>>(std::istream &is, vgl_orient_box_3d< Type > &p)
Read box from stream.
vgl_homg_point_2d(vgl_point_2d< T > const &p)
Construct from (non-homogeneous) vgl_point_2d<T>.
vgl_homg_point_2d()
Default constructor with (0,0,1).
Represents a homogeneous 2D point.
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.