/usr/include/ossim/base/ossimMatrix4x4.h is in libossim-dev 2.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | //*******************************************************************
//
// License: See top level LICENSE.txt file.
//
// Author: Garrett Potts (gpotts@imagelinks.com)
//
// Description:
//
//*******************************************************************
// $Id: ossimMatrix4x4.h 19824 2011-07-15 16:01:34Z dburken $
#ifndef ossimMatrix4x4_HEADER
#define ossimMatrix4x4_HEADER
#include <iostream>
#include <ossim/matrix/newmat.h>
#include <ossim/matrix/newmatio.h>
#include <ossim/base/ossimColumnVector4d.h>
#include <ossim/base/ossimColumnVector3d.h>
#include <ossim/base/ossimQuaternion.h>
class OSSIM_DLL ossimMatrix4x4
{
public:
friend std::ostream& operator<<(std::ostream& out,
const ossimMatrix4x4& data)
{
return out << data.getData();
}
ossimMatrix4x4();
ossimMatrix4x4(const NEWMAT::Matrix& m);
ossimMatrix4x4(double v00, double v01, double v02, double v03,
double v10, double v11, double v12, double v13,
double v20, double v21, double v22, double v23,
double v30, double v31, double v32, double v33);
inline explicit ossimMatrix4x4(const ossim::Quaternion& quat){ makeRotate(quat);}
ossimMatrix4x4(const ossimMatrix4x4& rhs)
:theData(4,4)
{
theData[0][0] = rhs.theData[0][0];
theData[0][1] = rhs.theData[0][1];
theData[0][2] = rhs.theData[0][2];
theData[0][3] = rhs.theData[0][3];
theData[1][0] = rhs.theData[1][0];
theData[1][1] = rhs.theData[1][1];
theData[1][2] = rhs.theData[1][2];
theData[1][3] = rhs.theData[1][3];
theData[2][0] = rhs.theData[2][0];
theData[2][1] = rhs.theData[2][1];
theData[2][2] = rhs.theData[2][2];
theData[2][3] = rhs.theData[2][3];
theData[3][0] = rhs.theData[3][0];
theData[3][1] = rhs.theData[3][1];
theData[3][2] = rhs.theData[3][2];
theData[3][3] = rhs.theData[3][3];
}
void makeRotate( const ossim::Quaternion& quat);
void setRotate( const ossim::Quaternion& quat);
ossim::Quaternion getRotate()const;
void getRotate(ossim::Quaternion& quat)const;
ossimMatrix4x4 operator+ (const ossimMatrix4x4& rhs)const
{
return ossimMatrix4x4(theData[0][0] + rhs.theData[0][0], theData[0][1] + rhs.theData[0][1], theData[0][2] + rhs.theData[0][2], theData[0][3] + rhs.theData[0][3],
theData[1][0] + rhs.theData[1][0], theData[1][1] + rhs.theData[1][1], theData[1][2] + rhs.theData[1][2], theData[1][3] + rhs.theData[1][3],
theData[2][0] + rhs.theData[2][0], theData[2][1] + rhs.theData[2][1], theData[2][2] + rhs.theData[2][2], theData[2][3] + rhs.theData[2][3],
theData[3][0] + rhs.theData[3][0], theData[3][1] + rhs.theData[3][1], theData[3][2] + rhs.theData[3][2], theData[3][3] + rhs.theData[3][3]);
}
ossimMatrix4x4 operator- (const ossimMatrix4x4& rhs)const
{
return ossimMatrix4x4(theData[0][0] - rhs.theData[0][0], theData[0][1] - rhs.theData[0][1], theData[0][2] - rhs.theData[0][2], theData[0][3] - rhs.theData[0][3],
theData[1][0] - rhs.theData[1][0], theData[1][1] - rhs.theData[1][1], theData[1][2] - rhs.theData[1][2], theData[1][3] - rhs.theData[1][3],
theData[2][0] - rhs.theData[2][0], theData[2][1] - rhs.theData[2][1], theData[2][2] - rhs.theData[2][2], theData[2][3] - rhs.theData[2][3],
theData[3][0] - rhs.theData[3][0], theData[3][1] - rhs.theData[3][1], theData[3][2] - rhs.theData[3][2], theData[3][3] - rhs.theData[3][3]);
}
friend ossimColumnVector4d operator * (const ossimMatrix4x4& lhs, const ossimColumnVector4d& rhs)
{
return ossimColumnVector4d( (lhs.theData[0][0]*rhs[0] + lhs.theData[0][1]*rhs[1] + lhs.theData[0][2]*rhs[2] + lhs.theData[0][3]*rhs[3]),
(lhs.theData[1][0]*rhs[0] + lhs.theData[1][1]*rhs[1] + lhs.theData[1][2]*rhs[2] + lhs.theData[1][3]*rhs[3]),
(lhs.theData[2][0]*rhs[0] + lhs.theData[2][1]*rhs[1] + lhs.theData[2][2]*rhs[2] + lhs.theData[2][3]*rhs[3]),
(lhs.theData[3][0]*rhs[0] + lhs.theData[3][1]*rhs[1] + lhs.theData[3][2]*rhs[2] + lhs.theData[3][3]*rhs[3]));
}
friend ossimColumnVector3d operator * (const ossimMatrix4x4& lhs, const ossimColumnVector3d& rhs)
{
// assume the 4 coordinate (homogeneous coord) of the 3d vector is 1
return ossimColumnVector3d( (lhs.theData[0][0]*rhs[0] + lhs.theData[0][1]*rhs[1] + lhs.theData[0][2]*rhs[2] + lhs.theData[0][3]),
(lhs.theData[1][0]*rhs[0] + lhs.theData[1][1]*rhs[1] + lhs.theData[1][2]*rhs[2] + lhs.theData[1][3]),
(lhs.theData[2][0]*rhs[0] + lhs.theData[2][1]*rhs[1] + lhs.theData[2][2]*rhs[2] + lhs.theData[2][3]));
}
ossimColumnVector4d rotateOnly(const ossimColumnVector4d& rhs)const
{
// multiply only by the 3x3 submatrix.
return ossimColumnVector4d( (theData[0][0]*rhs[0] + theData[0][1]*rhs[1] + theData[0][2]*rhs[2]),
(theData[1][0]*rhs[0] + theData[1][1]*rhs[1] + theData[1][2]*rhs[2]),
(theData[2][0]*rhs[0] + theData[2][1]*rhs[1] + theData[2][2]*rhs[2]));
}
ossimColumnVector3d rotateOnly(const ossimColumnVector3d& rhs)const
{
// assume the 4 coordinate (homogeneous coord) of the 3d vector is 1
return ossimColumnVector3d( (theData[0][0]*rhs[0] + theData[0][1]*rhs[1] + theData[0][2]*rhs[2]),
(theData[1][0]*rhs[0] + theData[1][1]*rhs[1] + theData[1][2]*rhs[2]),
(theData[2][0]*rhs[0] + theData[2][1]*rhs[1] + theData[2][2]*rhs[2]));
}
ossimMatrix4x4 operator*(double scalar)const
{
return ossimMatrix4x4(theData[0][0]*scalar, theData[0][1]*scalar, theData[0][2]*scalar, theData[0][3]*scalar,
theData[1][0]*scalar, theData[1][1]*scalar, theData[1][2]*scalar, theData[1][3]*scalar,
theData[2][0]*scalar, theData[2][1]*scalar, theData[2][2]*scalar, theData[2][3]*scalar,
theData[0][0]*scalar, theData[0][1]*scalar, theData[0][2]*scalar, theData[0][3]*scalar);
}
ossimMatrix4x4 operator*(const ossimMatrix4x4& rhs)const
{
ossimMatrix4x4 m;
// element 0,0 is first row time first column
m.theData[0][0] = (theData[0][0]*rhs.theData[0][0] +
theData[0][1]*rhs.theData[1][0] +
theData[0][2]*rhs.theData[2][0] +
theData[0][3]*rhs.theData[3][0]);
// element 0, 1 is first row second column
m.theData[0][1] = (theData[0][0]*rhs.theData[0][1] +
theData[0][1]*rhs.theData[1][1] +
theData[0][2]*rhs.theData[2][1] +
theData[0][3]*rhs.theData[3][1]);
// element 0, 2 is first row third column
m.theData[0][2] = (theData[0][0]*rhs.theData[0][2] +
theData[0][1]*rhs.theData[1][2] +
theData[0][2]*rhs.theData[2][2] +
theData[0][3]*rhs.theData[3][2]);
// element 0, 3 is first row fourth column
m.theData[0][3] = (theData[0][0]*rhs.theData[0][3] +
theData[0][1]*rhs.theData[1][3] +
theData[0][2]*rhs.theData[2][3] +
theData[0][3]*rhs.theData[3][3]);
// element 1, 0 is second row first column
m.theData[1][0] = (theData[1][0]*rhs.theData[0][0] +
theData[1][1]*rhs.theData[1][0] +
theData[1][2]*rhs.theData[2][0] +
theData[1][3]*rhs.theData[3][0]);
// element 1, 1 is second row second column
m.theData[1][1] = (theData[1][0]*rhs.theData[0][1] +
theData[1][1]*rhs.theData[1][1] +
theData[1][2]*rhs.theData[2][1] +
theData[1][3]*rhs.theData[3][1]);
// element 1, 2 is second row third column
m.theData[1][2] = (theData[1][0]*rhs.theData[0][2] +
theData[1][1]*rhs.theData[1][2] +
theData[1][2]*rhs.theData[2][2] +
theData[1][3]*rhs.theData[3][2]);
// element 1, 3 is second row fourth column
m.theData[1][3] = (theData[1][0]*rhs.theData[0][3] +
theData[1][1]*rhs.theData[1][3] +
theData[1][2]*rhs.theData[2][3] +
theData[1][3]*rhs.theData[3][3]);
// element 2, 0 is third row first column
m.theData[2][0] = (theData[2][0]*rhs.theData[0][0] +
theData[2][1]*rhs.theData[1][0] +
theData[2][2]*rhs.theData[2][0] +
theData[2][3]*rhs.theData[3][0]);
// element 2, 1 is third row second column
m.theData[2][1] = (theData[2][0]*rhs.theData[0][1] +
theData[2][1]*rhs.theData[1][1] +
theData[2][2]*rhs.theData[2][1] +
theData[2][3]*rhs.theData[3][1]);
// element 2, 2 is third row third column
m.theData[2][2] = (theData[2][0]*rhs.theData[0][2] +
theData[2][1]*rhs.theData[1][2] +
theData[2][2]*rhs.theData[2][2] +
theData[2][3]*rhs.theData[3][2]);
// element 2, 3 is third row fourth column
m.theData[2][3] = (theData[2][0]*rhs.theData[0][3] +
theData[2][1]*rhs.theData[1][3] +
theData[2][2]*rhs.theData[2][3] +
theData[2][3]*rhs.theData[3][3]);
// element 3, 0 is fourth row first column
m.theData[3][0] = (theData[3][0]*rhs.theData[0][0] +
theData[3][1]*rhs.theData[1][0] +
theData[3][2]*rhs.theData[2][0] +
theData[3][3]*rhs.theData[3][0]);
// element 3, 1 is fourth row second column
m.theData[3][1] = (theData[3][0]*rhs.theData[0][1] +
theData[3][1]*rhs.theData[1][1] +
theData[3][2]*rhs.theData[2][1] +
theData[3][3]*rhs.theData[3][1]);
// element 3, 2 is fourth row third column
m.theData[3][2] = (theData[3][0]*rhs.theData[0][2] +
theData[3][1]*rhs.theData[1][2] +
theData[3][2]*rhs.theData[2][2] +
theData[3][3]*rhs.theData[3][2]);
// element 3, 3 is fourth row fourth column
m.theData[3][3] = (theData[3][0]*rhs.theData[0][3] +
theData[3][1]*rhs.theData[1][3] +
theData[3][2]*rhs.theData[2][3] +
theData[3][3]*rhs.theData[3][3]);
return m;
}
/*!
* uses the matrix package to compute the inverse
*/
ossimMatrix4x4& i()
{
theData = theData.i();
return *this;
}
/*!
* Uses the matrix package to compute the transpose.
*/
ossimMatrix4x4& t()
{
theData = theData.t();
return *this;
}
/*!
* uses the matrix package to compute the determinant
*/
double getDeterminant()const
{
return theData.Determinant();
}
/*!
* Uses the matrix package to compute the eigenvalues for this
* matrix
*/
ossimColumnVector3d getEigenValues()const;
bool isEqualTo(const ossimMatrix4x4& rhs,
ossimCompareType compareType=OSSIM_COMPARE_FULL)const;
void setZero();
void setIdentity();
static NEWMAT::Matrix createIdentity();
static NEWMAT::Matrix createRotateOnly(const ossimMatrix4x4& aMatrix);
static NEWMAT::Matrix createZero();
static NEWMAT::Matrix createTranslationMatrix(double x,
double y,
double z);
static NEWMAT::Matrix createRotationMatrix(double angleX,
double angleY,
double angleZ,
ossimCoordSysOrientMode orientationMode=OSSIM_RIGHT_HANDED);
static NEWMAT::Matrix createRotationXMatrix(double angle,
ossimCoordSysOrientMode orientationMode=OSSIM_RIGHT_HANDED);
static NEWMAT::Matrix createRotationYMatrix(double angle,
ossimCoordSysOrientMode orientationMode=OSSIM_RIGHT_HANDED);
static NEWMAT::Matrix createRotationZMatrix(double angle,
ossimCoordSysOrientMode orientationMode=OSSIM_RIGHT_HANDED);
static NEWMAT::Matrix createScaleMatrix(double X, double Y, double Z);
const NEWMAT::Matrix& getData()const{return theData;}
NEWMAT::Matrix& getData(){return theData;}
private:
NEWMAT::Matrix theData;
}; // class OSSIM_DLL ossimMatrix4x4
inline bool ossimMatrix4x4::isEqualTo(const ossimMatrix4x4& rhs,
ossimCompareType /* compareType */)const
{
return (ossim::almostEqual(theData[0][0], rhs.theData[0][0])&&
ossim::almostEqual(theData[0][1], rhs.theData[0][1])&&
ossim::almostEqual(theData[0][2], rhs.theData[0][2])&&
ossim::almostEqual(theData[0][3], rhs.theData[0][3])&&
ossim::almostEqual(theData[1][0], rhs.theData[1][0])&&
ossim::almostEqual(theData[1][1], rhs.theData[1][1])&&
ossim::almostEqual(theData[1][2], rhs.theData[1][2])&&
ossim::almostEqual(theData[1][3], rhs.theData[1][3])&&
ossim::almostEqual(theData[2][0], rhs.theData[2][0])&&
ossim::almostEqual(theData[2][1], rhs.theData[2][1])&&
ossim::almostEqual(theData[2][2], rhs.theData[2][2])&&
ossim::almostEqual(theData[2][3], rhs.theData[2][3])&&
ossim::almostEqual(theData[3][0], rhs.theData[3][0])&&
ossim::almostEqual(theData[3][1], rhs.theData[3][1])&&
ossim::almostEqual(theData[3][2], rhs.theData[3][2])&&
ossim::almostEqual(theData[3][3], rhs.theData[3][3]));
}
#endif /* #ifndef ossimMatrix4x4_HEADER */
|