/usr/include/ossim/base/ossimColumnVector4d.h is in libossim-dev 1.7.21-3ubuntu2.
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 | //*******************************************************************
//
// License: See top level LICENSE.txt file.
//
// Author: Garrett Potts
//
// Description: This is your 3-D vector where the 4-th dimension is
// for the homogenious coordinate.
//
//*******************************************************************
// $Id: ossimColumnVector4d.h 11346 2007-07-23 12:59:48Z gpotts $
#ifndef ossimColumnVector4d_HEADER
#define ossimColumnVector4d_HEADER
#include <ossim/base/ossimConstants.h>
#include <ossim/base/ossimCommon.h>
#include <float.h> // for FLT_EPSILON
#include <iomanip>
#include <iostream>
#include <cmath>
using namespace std;
class OSSIMDLLEXPORT ossimColumnVector4d
{
public:
ossimColumnVector4d()
{
data[0]=0;
data[1]=0;
data[2]=0;
data[3]=1;
}
ossimColumnVector4d(double x, double y, double z, double w=1.0)
{
data[0]=x;
data[1]=y;
data[2]=z;
data[3]=w;
}
ossimColumnVector4d(const ossimColumnVector4d &rhs)
{
data[0] = rhs.data[0];
data[1] = rhs.data[1];
data[2] = rhs.data[2];
data[3] = rhs.data[3];
}
friend ostream& operator <<(ostream& out, const ossimColumnVector4d& v)
{
return out << setiosflags(ios::fixed) << setprecision(15)
<< v[0] << " " << v[1] <<" "
<< v[2] << " " << v[3];
}
friend ossimColumnVector4d operator*(double scalar, const ossimColumnVector4d &v)
{
return ossimColumnVector4d(v.data[0]*scalar,
v.data[1]*scalar,
v.data[2]*scalar);
}
double& operator [](int index)
{
return data[index];
}
const double& operator [](int index)const
{
return data[index];
}
ossimColumnVector4d operator*(double scalar)const
{
return ossimColumnVector4d(data[0]*scalar,
data[1]*scalar,
data[2]*scalar);
}
ossimColumnVector4d operator +(const ossimColumnVector4d &rhs)const
{
return ossimColumnVector4d( data[0]+rhs[0],
data[1]+rhs[1],
data[2]+rhs[2]);
}
ossimColumnVector4d operator +=(const ossimColumnVector4d &rhs)
{
data[0] += rhs[0];
data[1] += rhs[1];
data[2] += rhs[2];
return *this;
}
ossimColumnVector4d operator - ()const
{
return ossimColumnVector4d(-data[0],
-data[1],
-data[2]);
}
ossimColumnVector4d operator /(double scalar)const
{
return ossimColumnVector4d( data[0]/scalar,
data[1]/scalar,
data[2]/scalar);
}
ossimColumnVector4d& operator /=(double scalar)
{
data[0]/=scalar;
data[1]/=scalar;
data[2]/=scalar;
return *this;
}
ossimColumnVector4d operator -(const ossimColumnVector4d &rhs)const
{
return ossimColumnVector4d( data[0]-rhs[0],
data[1]-rhs[1],
data[2]-rhs[2]);
}
ossimColumnVector4d operator -=(const ossimColumnVector4d &rhs)
{
data[0] -= rhs[0];
data[1] -= rhs[1];
data[2] -= rhs[2];
return *this;
}
double magnitude()const
{
return std::sqrt(data[0]*data[0] +
data[1]*data[1] +
data[2]*data[2]);
}
double dot(const ossimColumnVector4d &rhs)const
{
return (data[0]*rhs[0]+
data[1]*rhs[1]+
data[2]*rhs[2]);
}
ossimColumnVector4d unit()const
{
double mag = magnitude();
if(std::abs(mag) > DBL_EPSILON)
{
mag = 1.0/mag;
return (*this *mag);
}
return *this;
}
ossimColumnVector4d cross(const ossimColumnVector4d &rhs)
{
return ossimColumnVector4d( data[1]*rhs[2] - data[2]*rhs[1],
data[2]*rhs[0] - data[0]*rhs[2],
data[0]*rhs[1] - data[1]*rhs[0]);
}
ossimColumnVector4d& xAligned()// creates 4-D homogeneous vectors
{
data[0] = 1;
data[1] = 0;
data[2] = 0;
data[3] = 1;
return *this;
}
ossimColumnVector4d& yAligned()//
{
data[0] = 0;
data[1] = 1;
data[2] = 0;
data[3] = 1;
return *this;
}
ossimColumnVector4d& zAligned() //
{
data[0] = 0;
data[1] = 0;
data[2] = 1;
data[3] = 1;
return *this;
}
private:
double data[4];
};
#endif
|