core/vnl/vnl_cross_product_matrix.h
Go to the documentation of this file.
00001 // This is core/vnl/vnl_cross_product_matrix.h
00002 #ifndef vnl_cross_product_matrix_h_
00003 #define vnl_cross_product_matrix_h_
00004 //:
00005 // \file
00006 // \brief 3x3 cross-product matrix of vector
00007 // \author Andrew W. Fitzgibbon, Oxford RRG
00008 // \date   19 Sep 96
00009 //
00010 // \verbatim
00011 //  Modifications
00012 //   4/4/01 LSB (Manchester) Tidied Documentation
00013 //   27 Jun 2003 - Peter Vanroose - made set() inlined and removed .cxx file.
00014 //   24 Oct 2010 - Peter Vanroose - mutators and setters now return *this
00015 // \endverbatim
00016 //
00017 //-----------------------------------------------------------------------------
00018 
00019 #include <vnl/vnl_vector_fixed.h>
00020 #include <vnl/vnl_double_3x3.h>
00021 
00022 //: Calculates the 3x3 skew symmetric cross product matrix from a vector.
00023 //
00024 // vnl_cross_product_matrix(e) is the matrix [e]_ x:
00025 // \verbatim
00026 //     0    -e_3   e_2
00027 //     e_3   0    -e_1
00028 //    -e_2   e_1   0
00029 // \endverbatim
00030 class vnl_cross_product_matrix : public vnl_double_3x3
00031 {
00032  public:
00033   typedef vnl_double_3x3 base;
00034 
00035   vnl_cross_product_matrix(vnl_vector_fixed<double,3> const& v) { set(v.data_block()); }
00036   vnl_cross_product_matrix(vnl_vector<double> const& v) { set(v.data_block()); }
00037   vnl_cross_product_matrix(const double* v) { set(v); }
00038   vnl_cross_product_matrix(vnl_cross_product_matrix const& that): base(that) {}
00039  ~vnl_cross_product_matrix() {}
00040 
00041   vnl_cross_product_matrix& operator=(const vnl_cross_product_matrix& that) {
00042     base::operator= (that);
00043     return *this;
00044   }
00045 
00046   //: Construct a vnl_cross_product_matrix from a C-array of 3 doubles.
00047   //  Overrides a method in vnl_matrix.
00048   inline vnl_cross_product_matrix& set(const double* v)
00049   {
00050     double const& e1 = v[0];
00051     double const& e2 = v[1];
00052     double const& e3 = v[2];
00053 
00054     vnl_cross_product_matrix & E = *this;
00055 
00056     E(0,0) =   0; E(0,1) = -e3; E(0,2) =  e2;
00057     E(1,0) =  e3; E(1,1) =   0; E(1,2) = -e1;
00058     E(2,0) = -e2; E(2,1) =  e1; E(2,2) =   0;
00059 
00060     return *this;
00061   }
00062 };
00063 
00064 #endif // vnl_cross_product_matrix_h_