contrib/oxl/mvl/HomgPoint3D.h
Go to the documentation of this file.
00001 // This is oxl/mvl/HomgPoint3D.h
00002 #ifndef HomgPoint3D_h_
00003 #define HomgPoint3D_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief Homogeneous 4-vector representing a 3D point
00010 //
00011 // A class to hold a homogeneous 4-vector for a 3D point.
00012 //
00013 // \verbatim
00014 //  Modifications:
00015 //   Peter Vanroose - 11 Mar 97 - added operator==
00016 // \endverbatim
00017 
00018 #include <vnl/vnl_double_3.h>
00019 #include <mvl/Homg3D.h>
00020 #include <vcl_iosfwd.h>
00021 
00022 class HomgPoint3D : public Homg3D
00023 {
00024  public:
00025   // Constructors/Initializers/Destructors-----------------------------------
00026 
00027   HomgPoint3D () {}
00028   HomgPoint3D (const HomgPoint3D& p): Homg3D(p) {}
00029   HomgPoint3D (const vnl_vector<double>& p): Homg3D(p) {}
00030   HomgPoint3D (const vnl_vector_fixed<double,4>& p): Homg3D(p) {}
00031   //: Constructor. The homogeneous parameter w defaults to 1.
00032   HomgPoint3D (double x, double y, double z, double w=1.0) : Homg3D(x,y,z,w) {}
00033  ~HomgPoint3D () {}
00034 
00035   // Data Access-------------------------------------------------------------
00036 
00037   //: Return true iff the point is the point at infinity.
00038   //  If tol == 0, w() must be exactly 0.
00039   //  Otherwise, tol is used as tolerance value (default: 1e-12),
00040   //  and $|w| <= \mbox{tol} \times min(|x|,|y|,|z|)$ is checked.
00041   inline bool ideal(double tol = 1e-12) const {
00042 #define mvl_abs(x) ((x)<0?-(x):(x))
00043     return mvl_abs(w()) <= tol*mvl_abs(x()) && mvl_abs(w()) <= tol*mvl_abs(y()) && mvl_abs(w()) <= tol*mvl_abs(z());
00044 #undef mvl_abs
00045   }
00046 
00047   bool get_nonhomogeneous(double& x, double& y, double& z) const;
00048   vnl_double_3 get_double3() const;
00049   double radius() const { return get_double3().magnitude(); }
00050   bool rescale_w(double new_w = 1.0);
00051   double squared_radius() const { return get_double3().squared_magnitude(); }
00052 };
00053 
00054 vcl_ostream& operator<<(vcl_ostream& s, const HomgPoint3D& );
00055 
00056 #endif // HomgPoint3D_h_