Go to the documentation of this file.00001
00002 #ifndef Homg3D_h_
00003 #define Homg3D_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <mvl/Homg.h>
00023 #include <vnl/vnl_double_4.h>
00024 #include <vnl/vnl_vector.h>
00025 #include <vcl_cassert.h>
00026
00027 class Homg3D : public Homg
00028 {
00029 public:
00030
00031
00032
00033 Homg3D() {}
00034 Homg3D(const Homg3D& that):homg_vector_(that.homg_vector_) {}
00035 Homg3D(double px, double py, double pz, double pw = 1): homg_vector_(px,py,pz,pw) {}
00036 Homg3D(const vnl_vector<double>& v): homg_vector_(v) { }
00037 Homg3D(const vnl_vector_fixed<double,4>& v): homg_vector_(v) { }
00038 ~Homg3D() {}
00039
00040 Homg3D& operator=(const Homg3D& that) { homg_vector_ = that.homg_vector_; return *this; }
00041
00042
00043
00044
00045 vnl_double_4 get_vector() const { return vnl_double_4(x(),y(),z(),w()); }
00046 vnl_double_4& asVector() { return homg_vector_; }
00047
00048
00049 void get(double *x_ptr, double *y_ptr, double *z_ptr, double *w_ptr) const
00050 {
00051 if (x_ptr) *x_ptr = x();
00052 if (x_ptr) *y_ptr = y();
00053 if (x_ptr) *z_ptr = z();
00054 if (x_ptr) *w_ptr = w();
00055 }
00056
00057
00058 inline double x() const { return homg_vector_[0]; }
00059
00060
00061 inline double y() const { return homg_vector_[1]; }
00062
00063
00064 inline double z() const { return homg_vector_[2]; }
00065
00066
00067 inline double w() const { return homg_vector_[3]; }
00068
00069 private:
00070
00071 double get_x() const { return homg_vector_[0]; }
00072
00073 double get_y() const { return homg_vector_[1]; }
00074
00075 double get_z() const { return homg_vector_[2]; }
00076
00077 double get_w() const { return homg_vector_[3]; }
00078 public:
00079
00080
00081 void set(double px, double py, double pz, double pw = 1) {
00082 homg_vector_[0] = px;
00083 homg_vector_[1] = py;
00084 homg_vector_[2] = pz;
00085 homg_vector_[3] = pw;
00086 }
00087
00088
00089 void set(const vnl_vector_fixed<double,4>& v) { set(v[0],v[1],v[2],v[3]); }
00090
00091
00092 void set(const vnl_vector<double>& v) { set(v[0],v[1],v[2],v[3]); }
00093
00094
00095 void set(unsigned int idx, double v) { assert(idx<=3); homg_vector_[idx]=v; }
00096
00097
00098 bool operator==(Homg3D const& p) const { return homg_vector_ == p.get_vector(); }
00099
00100
00101 protected:
00102
00103 vnl_double_4 homg_vector_;
00104 };
00105
00106 #endif // Homg3D_h_