Go to the documentation of this file.00001
00002 #ifndef vgl_infinite_line_3d_h_
00003 #define vgl_infinite_line_3d_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <vcl_iosfwd.h>
00018 #include <vgl/vgl_vector_2d.h>
00019 #include <vgl/vgl_vector_3d.h>
00020 #include <vgl/vgl_point_3d.h>
00021 #include <vgl/vgl_line_segment_3d.h>
00022 #include <vgl/vgl_line_3d_2_points.h>
00023
00024
00025
00026
00027
00028 template <class Type>
00029 class vgl_infinite_line_3d
00030 {
00031 vgl_vector_2d<Type> x0_;
00032 vgl_vector_3d<Type> t_;
00033 public:
00034
00035 inline vgl_infinite_line_3d() {}
00036
00037
00038 inline vgl_infinite_line_3d(vgl_infinite_line_3d<Type> const& l)
00039 : x0_(l.x0()), t_(l.direction()) {}
00040
00041
00042 inline vgl_infinite_line_3d(vgl_vector_2d<Type> const& x_0,
00043 vgl_vector_3d<Type> const& direction)
00044 : x0_(x_0), t_(direction) {}
00045
00046
00047 vgl_infinite_line_3d(vgl_point_3d<Type> const& p1,
00048 vgl_point_3d<Type> const& p2);
00049
00050
00051 vgl_infinite_line_3d(vgl_point_3d<Type> const& p,
00052 vgl_vector_3d<Type> const& direction);
00053
00054
00055 inline vgl_infinite_line_3d(vgl_line_segment_3d<Type> const& ls)
00056 {
00057 vgl_infinite_line_3d<Type> inf_l(ls.point1(), ls.point2());
00058 x0_ = inf_l.x0(); t_ = inf_l.direction();
00059 }
00060
00061
00062 inline vgl_infinite_line_3d(vgl_line_3d_2_points<Type> const& ls)
00063 {
00064 vgl_infinite_line_3d<Type> inf_l(ls.point1(), ls.point2());
00065 x0_ = inf_l.x0(); t_ = inf_l.direction();
00066 }
00067
00068
00069 inline ~vgl_infinite_line_3d() {}
00070
00071
00072 inline vgl_vector_2d<Type> x0() const { return x0_; }
00073 inline vgl_vector_3d<Type> direction() const
00074 { return t_/static_cast<Type>(t_.length()); }
00075
00076
00077 inline bool operator==(vgl_infinite_line_3d<Type> const& l) const
00078 { return (this==&l) || (direction() == l.direction() && x0() == l.x0()); }
00079
00080 inline bool operator!=(vgl_infinite_line_3d<Type>const& other) const
00081 { return !operator==(other); }
00082
00083
00084 inline void set(vgl_vector_2d<Type> const& x_0, vgl_vector_3d<Type> const& direction)
00085 { x0_ = x_0; t_ = direction; }
00086
00087
00088 vgl_point_3d<Type> point() const;
00089
00090
00091
00092 vgl_point_3d<Type> point_t(const double t) const { return point() + t*direction(); }
00093
00094
00095 bool contains(const vgl_point_3d<Type>& p ) const;
00096
00097
00098 void compute_uv_vectors(vgl_vector_3d<Type>& u, vgl_vector_3d<Type>& v) const;
00099 };
00100
00101
00102
00103 template <class Type>
00104 vcl_ostream& operator<<(vcl_ostream& s, const vgl_infinite_line_3d<Type>& p);
00105
00106
00107
00108 template <class Type>
00109 vcl_istream& operator>>(vcl_istream& is, vgl_infinite_line_3d<Type>& p);
00110 #define VGL_INFINITE_LINE_3D_INSTANTIATE(T) extern "please include vgl/vgl_infinite_line_3d.txx first"
00111
00112 #endif // vgl_infinite_line_3d_h_