Go to the documentation of this file.00001
00002 #ifndef vgl_homg_plane_3d_h
00003 #define vgl_homg_plane_3d_h
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <vcl_iosfwd.h>
00024 #include <vgl/vgl_fwd.h>
00025 #include <vgl/vgl_vector_3d.h>
00026 #include <vcl_cassert.h>
00027
00028
00029 template <class Type>
00030 class vgl_homg_plane_3d
00031 {
00032
00033 Type a_;
00034 Type b_;
00035 Type c_;
00036 Type d_;
00037
00038 public:
00039 inline vgl_homg_plane_3d () {}
00040
00041
00042 inline vgl_homg_plane_3d(Type ta, Type tb, Type tc, Type td) : a_(ta), b_(tb), c_(tc), d_(td) {}
00043
00044
00045 inline vgl_homg_plane_3d(const Type v[4]) : a_(v[0]), b_(v[1]), c_(v[2]), d_(v[3]) {}
00046
00047
00048 vgl_homg_plane_3d (vgl_plane_3d<Type> const& pl);
00049
00050
00051
00052 vgl_homg_plane_3d (vgl_vector_3d<Type> const& n, vgl_homg_point_3d<Type> const& p);
00053
00054
00055 vgl_homg_plane_3d (vgl_homg_point_3d<Type> const& p1,
00056 vgl_homg_point_3d<Type> const& p2,
00057 vgl_homg_point_3d<Type> const& p3);
00058
00059
00060 vgl_homg_plane_3d (vgl_homg_line_3d_2_points<Type> const& l1,
00061 vgl_homg_line_3d_2_points<Type> const& l2);
00062
00063
00064
00065
00066 inline Type a() const {return a_;}
00067 inline Type nx() const {return a_;}
00068
00069 inline Type b() const {return b_;}
00070 inline Type ny() const {return b_;}
00071
00072 inline Type c() const {return c_;}
00073 inline Type nz() const {return c_;}
00074
00075 inline Type d() const {return d_;}
00076
00077
00078 inline void set(Type ta,Type tb,Type tc,Type td) { assert(ta||tb||tc||td);a_=ta;b_=tb;c_=tc;d_=td; }
00079
00080
00081 bool operator==( vgl_homg_plane_3d<Type> const& pl) const;
00082 inline bool operator!=( vgl_homg_plane_3d<Type>const& pl) const { return !operator==(pl); }
00083
00084
00085
00086
00087 inline bool ideal(Type tol = (Type)0) const
00088 {
00089 #define vgl_Abs(x) (x<0?-x:x) // avoid #include of vcl_cmath.h AND vcl_cstdlib.h
00090 return vgl_Abs(a()) <= tol * vgl_Abs(d()) &&
00091 vgl_Abs(b()) <= tol * vgl_Abs(d()) &&
00092 vgl_Abs(c()) <= tol * vgl_Abs(d());
00093 #undef vgl_Abs
00094 }
00095
00096 inline vgl_vector_3d<double> normal() const { return normalized(vgl_vector_3d<double>(a(),b(),c())); }
00097
00098
00099 void normalize();
00100 };
00101
00102
00103
00104
00105 template <class Type>
00106 inline bool is_ideal(vgl_homg_plane_3d<Type> const& p, Type tol=(Type)0) { return p.ideal(tol); }
00107
00108
00109
00110 template <class Type>
00111 vcl_ostream& operator<<(vcl_ostream& s, const vgl_homg_plane_3d<Type>& p);
00112
00113 template <class Type>
00114 vcl_istream& operator>>(vcl_istream& is, vgl_homg_plane_3d<Type>& p);
00115
00116 #define VGL_HOMG_PLANE_3D_INSTANTIATE(T) extern "please include vgl/vgl_homg_plane_3d.txx first"
00117
00118 #endif // vgl_homg_plane_3d_h