Go to the documentation of this file.00001
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005
00006
00007 #include "HMatrix3D.h"
00008
00009 #include <vcl_iostream.h>
00010 #include <vcl_cassert.h>
00011
00012 #include <vnl/vnl_matlab_print.h>
00013 #include <vnl/vnl_inverse.h>
00014 #include <vnl/vnl_double_3x3.h>
00015 #include <vnl/vnl_double_3.h>
00016
00017 #include <mvl/HomgPrettyPrint.h>
00018 #include <mvl/HomgLine3D.h>
00019 #include <mvl/HomgOperator3D.h>
00020 #include <mvl/HomgPoint3D.h>
00021
00022
00023
00024
00025 HMatrix3D::HMatrix3D()
00026 {
00027 }
00028
00029
00030 HMatrix3D::HMatrix3D(const HMatrix3D& M):
00031 Base(M)
00032 {
00033 }
00034
00035
00036
00037
00038 HMatrix3D::HMatrix3D(vnl_double_4x4 const& M):
00039 Base(M)
00040 {
00041 }
00042
00043
00044
00045
00046 HMatrix3D::HMatrix3D(vcl_istream& s)
00047 {
00048 load(s);
00049 }
00050
00051
00052
00053
00054
00055
00056 HMatrix3D::HMatrix3D(vnl_double_3x3 const& M, vnl_double_3 const& m)
00057 {
00058 assert(M.rows() == 3);
00059 assert(M.columns() == 3);
00060 assert(m.size() == 3);
00061
00062 for (int r = 0; r < 3; ++r) {
00063 for (int c = 0; c < 3; ++c)
00064 (*this)(r, c) = M(r,c);
00065 (*this)(r, 3) = m(r);
00066 }
00067 for (int c = 0; c < 3; ++c)
00068 (*this)(3,c) = 0;
00069 (*this)(3,3) = 1;
00070 }
00071
00072
00073
00074
00075 HMatrix3D::HMatrix3D (const double* t_matrix) :
00076 Base(t_matrix)
00077 {
00078 }
00079
00080
00081 HMatrix3D::~HMatrix3D()
00082 {
00083 }
00084
00085
00086
00087
00088
00089
00090
00091 HomgPoint3D HMatrix3D::transform(const HomgPoint3D& x1) const
00092 {
00093 return HomgPoint3D ((*this) * x1.get_vector());
00094 }
00095
00096
00097
00098
00099
00100 HomgLine3D HMatrix3D::transform(const HomgLine3D& l1) const
00101 {
00102
00103
00104 HomgPoint3D p1((*this) * l1.get_point_finite().get_vector());
00105 HomgPoint3D p2((*this) * l1.get_point_infinite().get_vector());
00106
00107 return HomgLine3D(p1,p2);
00108 }
00109
00110
00111
00112 vcl_ostream& operator<<(vcl_ostream& s, const HMatrix3D& h)
00113 {
00114 if (HomgPrettyPrint::pretty)
00115 return vnl_matlab_print(s, (vnl_matrix<double> const&)h, "");
00116 else
00117 return s << (vnl_matrix<double> const&)h;
00118 }
00119
00120
00121 bool HMatrix3D::load(vcl_istream& s)
00122 {
00123 this->read_ascii(s);
00124 return s.good() || s.eof();
00125 }
00126
00127
00128 vcl_istream& operator>>(vcl_istream& s, HMatrix3D& H)
00129 {
00130 H.load(s);
00131 return s;
00132 }
00133
00134
00135
00136
00137
00138 double HMatrix3D::get (unsigned int row_index, unsigned int col_index) const
00139 {
00140 return vnl_double_4x4::get(row_index, col_index);
00141 }
00142
00143
00144
00145 void HMatrix3D::get (double *t_matrix) const
00146 {
00147 for (int row_index = 0; row_index < 4; row_index++)
00148 for (int col_index = 0; col_index < 4; col_index++)
00149 *t_matrix++ = vnl_double_4x4::get(row_index, col_index);
00150 }
00151
00152
00153
00154 void HMatrix3D::get (vnl_matrix<double>* t_matrix) const
00155 {
00156 *t_matrix = this->as_ref();
00157 }
00158
00159
00160
00161 HMatrix3D HMatrix3D::get_inverse() const
00162 {
00163 return vnl_inverse(*this);
00164 }