/usr/include/ossim/base/ossimColumnVector3d.h is in libossim-dev 1.8.16-4ubuntu1.
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 | //*******************************************************************
//
// License: See top level LICENSE.txt file.
//
// Author: Garrett Potts
//
// Description: This is a 3-D vector without the homogeneous
// coordinate.
//
//*******************************************************************
// $Id: ossimColumnVector3d.h 20074 2011-09-08 16:16:27Z gpotts $
#ifndef ossimColumnVector3d_HEADER
#define ossimColumnVector3d_HEADER
#include <ossim/base/ossimConstants.h>
#include <ossim/base/ossimNotifyContext.h>
#include <float.h> // for FLT_EPSILON
#include <iomanip>
#include <iostream>
#include <cmath>
using namespace std;
#include <ossim/matrix/newmat.h>
#include <ossim/base/ossimString.h>
class OSSIMDLLEXPORT ossimColumnVector3d
{
public:
ossimColumnVector3d()
{
data[0]=0;
data[1]=0;
data[2]=0;
}
ossimColumnVector3d(double x, double y, double z=0)
{
data[0]=x;
data[1]=y;
data[2]=z;
}
ossimColumnVector3d(const ossimColumnVector3d &rhs)
{
data[0] = rhs.data[0];
data[1] = rhs.data[1];
data[2] = rhs.data[2];
}
explicit ossimColumnVector3d(const NEWMAT::ColumnVector& rhs)
{
if ( (rhs.Ncols() == 1) && (rhs.Nrows() > 2) )
{
data[0] = rhs[0];
data[1] = rhs[1];
data[2] = rhs[2];
}
else
{
data[0]=0;
data[1]=0;
data[2]=0;
}
}
const ossimColumnVector3d& operator=(const NEWMAT::ColumnVector& rhs)
{
if ( (rhs.Ncols() == 1) && (rhs.Nrows() == 3) )
{
data[0] = rhs[0];
data[1] = rhs[1];
data[2] = rhs[2];
}
return *this;
}
friend ostream& operator <<(ostream& out, const ossimColumnVector3d& v)
{
return out << setiosflags(ios::fixed) << setprecision(15)
<< v[0] << " " << v[1] <<" "
<< v[2];
}
friend ossimColumnVector3d operator*(double scalar,
const ossimColumnVector3d &v)
{
return ossimColumnVector3d(v.data[0]*scalar,
v.data[1]*scalar,
v.data[2]*scalar);
}
/*!
* Multiplies column vector times matrix.
* Note:
* If "lhs" is not a 3x3 that's an error and a blank column vector
* is returned.
*/
friend ossimColumnVector3d operator*(const NEWMAT::Matrix& lhs,
const ossimColumnVector3d& rhs)
{
if ((lhs.Ncols() == 3) && (lhs.Nrows() == 3))
{
return ossimColumnVector3d( (lhs[0][0]*rhs[0] + lhs[0][1]*rhs[1] + lhs[0][2]*rhs[2]),
(lhs[1][0]*rhs[0] + lhs[1][1]*rhs[1] + lhs[1][2]*rhs[2]),
(lhs[2][0]*rhs[0] + lhs[2][1]*rhs[1] + lhs[2][2]*rhs[2]));
}
else if((lhs.Ncols() == 4) && (lhs.Nrows() == 4))
{
return ossimColumnVector3d( (lhs[0][0]*rhs[0] + lhs[0][1]*rhs[1] + lhs[0][2]*rhs[2] + lhs[0][3]) ,
(lhs[1][0]*rhs[0] + lhs[1][1]*rhs[1] + lhs[1][2]*rhs[2] + lhs[1][3]) ,
(lhs[2][0]*rhs[0] + lhs[2][1]*rhs[1] + lhs[2][2]*rhs[2] + lhs[2][3]));
}
ossimNotify(ossimNotifyLevel_WARN) << "Multiplying a 3 row column vector by an invalid matrix" << std::endl;
return rhs;
}
double& operator [](int index)
{
return data[index];
}
const double& operator [](int index)const
{
return data[index];
}
ossimColumnVector3d operator*(double scalar)const
{
return ossimColumnVector3d(data[0]*scalar,
data[1]*scalar,
data[2]*scalar);
}
ossimColumnVector3d operator +(const ossimColumnVector3d &rhs)const
{
return ossimColumnVector3d( data[0]+rhs[0],
data[1]+rhs[1],
data[2]+rhs[2]);
}
const ossimColumnVector3d& operator +=(const ossimColumnVector3d &rhs)
{
data[0] += rhs[0];
data[1] += rhs[1];
data[2] += rhs[2];
return *this;
}
ossimColumnVector3d operator - ()const
{
return ossimColumnVector3d(-data[0],
-data[1],
-data[2]);
}
ossimColumnVector3d operator /(double scalar)const
{
return ossimColumnVector3d( data[0]/scalar,
data[1]/scalar,
data[2]/scalar);
}
const ossimColumnVector3d& operator /=(double scalar)
{
data[0]/=scalar;
data[1]/=scalar;
data[2]/=scalar;
return *this;
}
ossimColumnVector3d operator -(const ossimColumnVector3d &rhs)const
{
return ossimColumnVector3d( data[0]-rhs[0],
data[1]-rhs[1],
data[2]-rhs[2]);
}
const ossimColumnVector3d& operator -=(const ossimColumnVector3d &rhs)
{
data[0] -= rhs[0];
data[1] -= rhs[1];
data[2] -= rhs[2];
return *this;
}
bool operator ==(const ossimColumnVector3d &rhs) const
{ return ((fabs(data[0] - rhs[0]) <= FLT_EPSILON) &&
(fabs(data[1] - rhs[1]) <= FLT_EPSILON) &&
(fabs(data[2] - rhs[2]) <= FLT_EPSILON));
}
bool operator !=(const ossimColumnVector3d &rhs) const
{ return !(*this == rhs); }
double magnitude()const
{
return sqrt(data[0]*data[0] +
data[1]*data[1] +
data[2]*data[2]);
}
inline double norm2()const //!speedup
{
return data[0]*data[0] +
data[1]*data[1] +
data[2]*data[2];
}
double dot(const ossimColumnVector3d &rhs) const
{
return (data[0]*rhs[0]+
data[1]*rhs[1]+
data[2]*rhs[2]);
}
ossimColumnVector3d unit() const
{
double mag = magnitude();
if(fabs(mag) > FLT_EPSILON)
{
mag = 1.0/mag;
return (*this *mag);
}
return *this;
}
ossimColumnVector3d cross(const ossimColumnVector3d &rhs) const
{
return ossimColumnVector3d( data[1]*rhs[2] - data[2]*rhs[1],
data[2]*rhs[0] - data[0]*rhs[2],
data[0]*rhs[1] - data[1]*rhs[0]);
}
const ossimColumnVector3d& xAligned()
{
data[0] = 1;
data[1] = 0;
data[2] = 0;
return *this;
}
const ossimColumnVector3d& yAligned()//
{
data[0] = 0;
data[1] = 1;
data[2] = 0;
return *this;
}
const ossimColumnVector3d& zAligned() //
{
data[0] = 0;
data[1] = 0;
data[2] = 1;
return *this;
}
/**
* @brief To string method.
*
* @param precision Output floating point precision.
*
* @return ossimString representing point.
*
* Output format:
* ( 0.0000000, 0.0000000, 0.00000000 )
* -----x---- -----y---- ------z----
*/
ossimString toString(ossim_uint32 precision=15) const;
/**
* @brief Initializes this point from string.
*
* Expected format:
*
* ( 0.0000000, 0.0000000, 0.00000000 )
* -----x---- -----y---- ------z----
*
* @param s String to initialize from.
*/
void toPoint(const std::string& s);
private:
double data[3];
};
#endif
|