2 #ifndef vgl_homg_point_3d_h_ 3 #define vgl_homg_point_3d_h_ 23 # include <vcl_msvc_warnings.h> 66 :
x_(that.
x()),
y_(that.
y()),
z_(that.
z()),
w_(that.
w()) {}
74 set(that.
x(),that.
y(),that.
z(),that.
w());
85 inline Type
x()
const {
return x_; }
86 inline Type
y()
const {
return y_; }
87 inline Type
z()
const {
return z_; }
88 inline Type
w()
const {
return w_; }
92 inline void set(Type px, Type py, Type pz, Type pw = (Type)1)
95 inline void set(Type
const p[4]) {
x_=p[0];
y_=p[1];
z_=p[2];
w_=p[3]; }
99 inline bool ideal(Type tol = (Type)0)
const 101 #define vgl_Abs(x) ((x)<0?-(x):(x)) // avoid #include of vcl_cmath.h AND vcl_cstdlib.h 113 std::cerr <<
"vgl_homg_point_3d::get_nonhomogeneous - point at infinity\n";
132 x_ =
x() * new_w /
w();
133 y_ =
y() * new_w /
w();
134 z_ =
z() * new_w /
w();
145 template <
class Type>
150 template <
class Type>
158 template <
class Type>
inline 163 template <
class Type>
inline 169 return ((p1.
x()*p2.
y()-p1.
y()*p2.
x())*p3.
z()
170 +(p3.
x()*p1.
y()-p3.
y()*p1.
x())*p2.
z()
171 +(p2.
x()*p3.
y()-p2.
y()*p3.
x())*p1.
z())*p4.
w()
172 -((p4.
x()*p1.
y()-p4.
y()*p1.
x())*p2.
z()
173 +(p2.
x()*p4.
y()-p2.
y()*p4.
x())*p1.
z()
174 +(p1.
x()*p2.
y()-p1.
y()*p2.
x())*p4.
z())*p3.
w()
175 +((p3.
x()*p4.
y()-p3.
y()*p4.
x())*p1.
z()
176 +(p1.
x()*p3.
y()-p1.
y()*p3.
x())*p4.
z()
177 +(p4.
x()*p1.
y()-p4.
y()*p1.
x())*p3.
z())*p2.
w()
178 -((p2.
x()*p3.
y()-p2.
y()*p3.
x())*p4.
z()
179 +(p4.
x()*p2.
y()-p4.
y()*p2.
x())*p3.
z()
180 +(p3.
x()*p4.
y()-p3.
y()*p4.
x())*p2.
z())*p1.
w() == 0;
186 template <
class Type>
inline 190 assert(p1.
w() && p2.
w());
192 p1.
y()/p1.
w()-p2.
y()/p2.
w(),
193 p1.
z()/p1.
w()-p2.
z()/p2.
w());
200 template <
class Type>
inline 206 p.
z()+
v.z()*p.
w(), p.
w());
212 template <
class Type>
inline 216 p.
set(p.
x()+
v.x()*p.
w(),p.
y()+
v.y()*p.
w(),p.
z()+
v.z()*p.
w(),p.
w());
return p;
221 template <
class Type>
inline 228 template <
class Type>
inline 231 {
return p += (-
v); }
259 template <
class Type>
272 template <
class Type>
inline 276 {
return (p3-p1)/(p2-p1); }
284 template <
class Type>
inline 288 {
return p1 + f*(p2-p1); }
296 template <
class Type>
inline 301 p1.
y()*p2.
w() + p2.
y()*p1.
w() ,
302 p1.
z()*p2.
w() + p2.
z()*p1.
w() ,
309 template <
class Type>
inline 314 Type x = 0, y = 0, z = 0;
315 for (
int i=0; i<n; ++i)
316 x+=
v[i].x()/
v[i].w(), y+=
v[i].y()/
v[i].w(), z+=
v[i].z()/
v[i].w();
320 #define VGL_HOMG_POINT_3D_INSTANTIATE(T) extern "please include vgl/vgl_homg_point_3d.hxx first" 322 #endif // vgl_homg_point_3d_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.
bool rescale_w(Type new_w=Type(1))
vgl_homg_point_3d(const Type v[4])
Construct from homogeneous 4-array.
vgl_homg_point_3d(Type px, Type py, Type pz, Type pw=(Type) 1)
Construct from three (nonhomogeneous) or four (homogeneous) Types.
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.
vgl_homg_point_3d(vgl_vector_3d< Type >const &v)
Construct point at infinity from direction vector.
bool get_nonhomogeneous(double &vx, double &vy, double &vz) const
Represents a homogeneous 3D plane.
void set(Type const p[4])
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.
Represents a cartesian 3D point.
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.
Represents a homogeneous 3D point.
bool operator!=(vgl_homg_point_3d< Type >const &other) const
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?.
a point in 3D nonhomogeneous space
vgl_homg_point_3d(vgl_point_3d< Type > const &p)
Construct from (non-homogeneous) vgl_point_3d<Type>.
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 coplanar(l const &l1, l const &l2)
Are two lines coplanar, i.e., do they intersect?.
bool operator==(vgl_homg_point_3d< Type > const &other) const
the comparison operator.
std::istream & operator>>(std::istream &is, vgl_orient_box_3d< Type > &p)
Read box from stream.
void set(Type px, Type py, Type pz, Type pw=(Type) 1)
Set x,y,z,w.
vgl_homg_point_3d()
Default constructor with (0,0,0,1).
bool ideal(Type tol=(Type) 0) const
Return true iff the point is at infinity (an ideal 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.