Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Matrix4x4.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 #include "Matrix4x4.hh"
27 
28 using namespace BIAS;
29 using namespace std;
30 
31 
32 namespace BIAS {
33 
34 template <class T>
36  // destroy the new allocated members of this class if they exist
37 }
38 
39 template <class T>
40 Matrix4x4<T>::Matrix4x4(const std::string & s)
41 : Matrix<T>(4, 4, s)
42 {}
43 
44 
45 /** Set the matrix values JW */
46 template <class T>
47 Matrix4x4<T>::Matrix4x4(const T a0, const T a1, const T a2, const T a3,
48  const T a4, const T a5, const T a6, const T a7,
49  const T a8, const T a9, const T a10, const T a11,
50  const T a12, const T a13, const T a14, const T a15 )
51  : Matrix<T>(4, 4)
52 {
53  this->GetData()[ 0]= a0; this->GetData()[ 1]= a1; this->GetData()[ 2]= a2; this->GetData()[ 3]= a3;
54  this->GetData()[ 4]= a4; this->GetData()[ 5]= a5; this->GetData()[ 6]= a6; this->GetData()[ 7]= a7;
55  this->GetData()[ 8]= a8; this->GetData()[ 9]= a9; this->GetData()[10]=a10; this->GetData()[11]=a11;
56  this->GetData()[12]=a12; this->GetData()[13]=a13; this->GetData()[14]=a14; this->GetData()[15]=a15;
57 }
58 
59 
60 template <class T>
62  if ((mat.num_rows() == 4) && (mat.num_cols() == 4)) {
63  Matrix<T>::operator= (mat); // call the operator of the base class
64  return *this;
65  } else {
66  BIASERR("cannot assign with operator= , num_rows=" << mat.
67  num_rows() << " num_cols= " << mat.
68  num_cols() << " are'nt appropriate for a 4x4 Matrix4x4<T>. ");
69  BIASABORT;
70  };
71  return *this;
72 }
73 
74 template<class T>
76 {
77  if ((mat.num_rows() != 4) || (mat.num_cols() != 4)) {
78  BIASERR("wrong matrix size "<<mat.num_rows()<<"x"
79  << mat.num_cols());
80  }
81 }
82 
83 template<class T>
85 {
86  if ((mat.num_rows() != 4) || (mat.num_cols() != 4)) {
87  BIASERR("wrong matrix size "<<mat.num_rows()<<"x"
88  << mat.num_cols());
89  }
90 }
91 
92 template <class T>
93 Matrix4x4<T> & Matrix4x4<T>::newsize(int rows, int cols) {
94  if ((rows != 4) || (cols != 4)) {
95  // do nothing
96  // print error message if the new size should not be a 4x4 matrix
97  BIASERR("The size of a Matrix4x4<T> has to be 4 rows, 4 cols. newsize can't create a " <<
98  rows << " x " << cols << " Matrix4x4 !");
99 #if DEBUG
100  BIASABORT;
101 #endif
102  return *this;
103 
104  } else {
105  BIASASSERT( rows==4 ); // 4x4 matrix
106  BIASASSERT( cols==4 );
107  // call base class function (usually unnecessary except for first construction)
108  Matrix<T>::newsize(4, 4);
109  return *this;
110  };
111 }
112 
113 template <class T>
115  const Vector3<T> &trans) : Matrix<T>(4, 4)
116 {
117  (*this)[0][0]=R[0][0]; (*this)[0][1]=R[0][1]; (*this)[0][2]=R[0][2];
118  (*this)[0][3]=trans[0];
119  (*this)[1][0]=R[1][0]; (*this)[1][1]=R[1][1]; (*this)[1][2]=R[1][2];
120  (*this)[1][3]=trans[1];
121  (*this)[2][0]=R[2][0]; (*this)[2][1]=R[2][1]; (*this)[2][2]=R[2][2];
122  (*this)[2][3]=trans[2];
123  (*this)[3][0]=0;(*this)[3][1]=0; (*this)[3][2]=0;
124  (*this)[3][3]=T(1);
125 
126 }
127 
128 } // end namespace BIAS
129 
130 #define INST(type) \
131 template class BIASMathBase_EXPORT BIAS::Matrix4x4<type>;\
132 
133 INST(unsigned char)
134 INST(char)
135 INST(float)
136 INST(short)
137 INST(unsigned short)
138 INST(long int)
139 INST(int)
140 INST(unsigned int)
141 INST(double)
Matrix4x4 & newsize(int rows, int cols)
just neccessary to avoid resizing of this &#39;fixed size&#39; matrix because it is derived from the resizabl...
Definition: Matrix4x4.cpp:93
Subscript num_cols() const
Definition: cmat.h:320
Matrix< T > & newsize(Subscript M, Subscript N)
Definition: cmat.h:269
Matrix< T > & operator=(const TNT::Matrix< T > &mat)
assignment operators calling corresponding operator from base class if appropriate ...
Definition: Matrix.hh:1101
T * GetData()
get the pointer to the data array of the matrix (for faster direct memeory access) ...
Definition: Matrix.hh:185
virtual ~Matrix4x4()
destructor untested (04/17/2002)
Definition: Matrix4x4.cpp:35
is a &#39;fixed size&#39; quadratic matrix of dim.
Definition: Matrix.hh:54
Matrix4x4()
constructors call the corresponding constructors of the base class if appropriate ...
Definition: Matrix4x4.hh:64
class Vector3 contains a Vector of fixed dim.
Definition: Matrix.hh:53
matrix class with arbitrary size, indexing is row major.
Subscript num_rows() const
Definition: cmat.h:319
is a &#39;fixed size&#39; quadratic matrix of dim.
Definition: Matrix4x4.hh:54
Matrix4x4 & operator=(const Matrix< T > &mat)
assignment operators calling corresponding operator from base class &quot;TNT::Matrix&quot; if appropriate ...
Definition: Matrix4x4.cpp:61