vnl_cross_product_matrix.h
Go to the documentation of this file.
1 // This is core/vnl/vnl_cross_product_matrix.h
2 #ifndef vnl_cross_product_matrix_h_
3 #define vnl_cross_product_matrix_h_
4 //:
5 // \file
6 // \brief 3x3 cross-product matrix of vector
7 // \author Andrew W. Fitzgibbon, Oxford RRG
8 // \date 19 Sep 96
9 //
10 // \verbatim
11 // Modifications
12 // 4/4/01 LSB (Manchester) Tidied Documentation
13 // 27 Jun 2003 - Peter Vanroose - made set() inlined and removed .cxx file.
14 // 24 Oct 2010 - Peter Vanroose - mutators and setters now return *this
15 // \endverbatim
16 //
17 //-----------------------------------------------------------------------------
18 
19 #include <vnl/vnl_vector_fixed.h>
20 #include <vnl/vnl_double_3x3.h>
21 #include "vnl/vnl_export.h"
22 
23 //: Calculates the 3x3 skew symmetric cross product matrix from a vector.
24 //
25 // vnl_cross_product_matrix(e) is the matrix [e]_ x:
26 // \verbatim
27 // 0 -e_3 e_2
28 // e_3 0 -e_1
29 // -e_2 e_1 0
30 // \endverbatim
32 {
33  public:
34  typedef vnl_double_3x3 base;
35 
37  vnl_cross_product_matrix(vnl_vector<double> const& v) { set(v.data_block()); }
38  vnl_cross_product_matrix(const double* v) { set(v); }
40  ~vnl_cross_product_matrix() = default;
41 
43  base::operator= (that);
44  return *this;
45  }
46 
47  //: Construct a vnl_cross_product_matrix from a C-array of 3 doubles.
48  // Overrides a method in vnl_matrix.
49  inline vnl_cross_product_matrix& set(const double* v)
50  {
51  double const& e1 = v[0];
52  double const& e2 = v[1];
53  double const& e3 = v[2];
54 
55  vnl_cross_product_matrix & E = *this;
56 
57  E(0,0) = 0; E(0,1) = -e3; E(0,2) = e2;
58  E(1,0) = e3; E(1,1) = 0; E(1,2) = -e1;
59  E(2,0) = -e2; E(2,1) = e1; E(2,2) = 0;
60 
61  return *this;
62  }
63 };
64 
65 #endif // vnl_cross_product_matrix_h_
vnl_cross_product_matrix(vnl_vector_fixed< double, 3 > const &v)
vnl_cross_product_matrix & operator=(const vnl_cross_product_matrix &that)
vnl_cross_product_matrix(vnl_vector< double > const &v)
Fixed size, stack-stored, space-efficient matrix.
Definition: vnl_fwd.h:23
#define v
Definition: vnl_vector.h:42
vnl_matrix_fixed & operator=(const vnl_matrix_fixed &rhs)=default
Copy another vnl_matrix_fixed<T,m,n> into this.
vnl_cross_product_matrix(const double *v)
Calculates the 3x3 skew symmetric cross product matrix from a vector.
3x3 matrix of double
Fixed length stack-stored, space-efficient vector.
Definition: vnl_fwd.h:22
~vnl_cross_product_matrix()=default
Fixed length stack-stored vector.
vnl_cross_product_matrix & set(const double *v)
Construct a vnl_cross_product_matrix from a C-array of 3 doubles.