/usr/include/ossim/base/ossimLsrVector.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 | //*******************************************************************
//
// License: See top level LICENSE.txt file.
//
// DESCRIPTION:
// Class for representing vectors in some local space rectangular (LSR)
// coordinate system. This coordinate system is related to the ECEF system
// by the ossimLsrSpace member object. This class simplifies coordinate
// conversions between LSR and ECEF, and other LSR vectors.
//
// SOFTWARE HISTORY:
//>
// 08Aug2001 Oscar Kramer
// Initial coding.
//<
//*****************************************************************************
// $Id: ossimLsrVector.h 12790 2008-05-05 13:41:33Z dburken $
#ifndef ossimLsrVector_HEADER
#define ossimLsrVector_HEADER
#include <iosfwd>
#include <ossim/base/ossimCommon.h>
#include <ossim/base/ossimLsrPoint.h>
#include <ossim/base/ossimLsrSpace.h>
#include <ossim/base/ossimEcefVector.h>
#include <ossim/base/ossimColumnVector3d.h>
class ossimGpt;
//*****************************************************************************
// CLASS: ossimLsrVector
//
//*****************************************************************************
class OSSIMDLLEXPORT ossimLsrVector
{
public:
/*!
* CONSTRUCTORS:
*/
ossimLsrVector()
: theData (0,0,0) {}
ossimLsrVector(const ossimLsrVector& copy_this)
: theData(copy_this.theData), theLsrSpace(copy_this.theLsrSpace) {}
ossimLsrVector(const ossimColumnVector3d& assign_this,
const ossimLsrSpace& space)
: theData(assign_this), theLsrSpace(space) {}
ossimLsrVector(const double& x,
const double& y,
const double& z,
const ossimLsrSpace& space)
: theData(x,y,z), theLsrSpace(space) {}
ossimLsrVector(const ossimEcefVector& convert_this,
const ossimLsrSpace&);
ossimLsrVector(const ossimLsrVector& convert_this,
const ossimLsrSpace&);
/*!
* OPERATORS: (all methods inlined below)
*/
const ossimLsrVector& operator= (const ossimLsrVector&);
ossimLsrVector operator- () const;
ossimLsrVector operator+ (const ossimLsrVector&) const;
ossimLsrVector operator- (const ossimLsrVector&) const;
ossimLsrPoint operator+ (const ossimLsrPoint&) const;
ossimLsrVector operator* (const double& scalar) const;
ossimLsrVector operator/ (const double& scalar) const;
bool operator==(const ossimLsrVector&) const;
bool operator!=(const ossimLsrVector&) const;
/*!
* CASTING OPERATOR:
* Used as: myEcefVector = ossimEcefVector(this) -- looks like a constructor
* but is an operation on this object. ECEF knows nothing about LSR, so
* cannot provide an ossimEcefVector(ossimLsrVector) constructor.
*/
operator ossimEcefVector() const; // inline below
/*!
* Vector-related functions:
*/
double dot(const ossimLsrVector&) const;
double angleTo(const ossimLsrVector&) const;
ossimLsrVector cross(const ossimLsrVector&) const;
ossimLsrVector unitVector() const;//inline below
double magnitude() const;//inline below
void normalize(); // inline below
/*!
* DATA ACCESS METHODS:
*/
double x() const { return theData[0]; }
double& x() { return theData[0]; }
double y() const { return theData[1]; }
double& y() { return theData[1]; }
double z() const { return theData[2]; }
double& z() { return theData[2]; }
bool hasNans()const
{
return (ossim::isnan(theData[0])||
ossim::isnan(theData[1])||
ossim::isnan(theData[2]));
}
void makeNan()
{
theData[0] = ossim::nan();
theData[1] = ossim::nan();
theData[2] = ossim::nan();
}
ossimColumnVector3d& data() { return theData; }
const ossimColumnVector3d& data() const { return theData; }
ossimLsrSpace& lsrSpace() { return theLsrSpace; }
const ossimLsrSpace& lsrSpace() const { return theLsrSpace; }
/*!
* Debug Dump:
*/
std::ostream& print(ostream& stream) const;
friend std::ostream& operator<< (std::ostream& os ,
const ossimLsrVector& instance);
protected:
/*!
* METHOD: initialize(ossimEcefVector)
* Convenience method used by several constructors for initializing theData
* given an ECEF vector. Assumes theLsrSpace has been previously initialized
*/
void initialize(const ossimEcefVector& ecef_point);
ossimColumnVector3d theData;
ossimLsrSpace theLsrSpace;
};
//================== BEGIN DEFINITIONS FOR INLINE METHODS =====================
//*****************************************************************************
// INLINE OPERATOR: ossimLsrVector::operator=(ossimLsrVector)
//*****************************************************************************
inline const ossimLsrVector& ossimLsrVector::operator=(const ossimLsrVector& v)
{
theData = v.theData;
theLsrSpace = v.theLsrSpace;
return *this;
}
//*****************************************************************************
// INLINE OPERATOR: ossimLsrVector::operator-() (negate)
//*****************************************************************************
inline ossimLsrVector ossimLsrVector::operator-() const
{
return ossimLsrVector(-theData, theLsrSpace);
}
//*****************************************************************************
// INLINE OPERATOR: ossimLsrVector::operator+(ossimLsrVector)
//*****************************************************************************
inline ossimLsrVector ossimLsrVector::operator+(const ossimLsrVector& v) const
{
if ((theLsrSpace != v.theLsrSpace)||hasNans()||v.hasNans())
{
theLsrSpace.lsrSpaceErrorMessage();
return ossimLsrVector(ossim::nan(), ossim::nan(), ossim::nan(), theLsrSpace);
}
return ossimLsrVector(theData + v.theData, theLsrSpace);
}
//*****************************************************************************
// INLINE OPERATOR: ossimLsrVector::operator-(ossimLsrVector)
//*****************************************************************************
inline ossimLsrVector ossimLsrVector::operator-(const ossimLsrVector& v) const
{
if ((theLsrSpace != v.theLsrSpace)||hasNans()||v.hasNans())
{
theLsrSpace.lsrSpaceErrorMessage();
return ossimLsrVector(ossim::nan(), ossim::nan(), ossim::nan(), theLsrSpace);
}
return ossimLsrVector(theData - v.data(), theLsrSpace);
}
//*****************************************************************************
// INLINE OPERATOR: ossimLsrVector::operator+(ossimLsrPoint)
//*****************************************************************************
inline ossimLsrPoint ossimLsrVector::operator+(const ossimLsrPoint& p) const
{
if ((theLsrSpace != p.lsrSpace())||hasNans()||p.hasNans())
{
theLsrSpace.lsrSpaceErrorMessage();
return ossimLsrPoint(ossim::nan(), ossim::nan(), ossim::nan(), theLsrSpace);
}
return ossimLsrPoint(theData + p.data(), theLsrSpace);
}
//*****************************************************************************
// INLINE OPERATOR: ossimLsrVector::operator*(double scalar)
//*****************************************************************************
inline ossimLsrVector ossimLsrVector::operator*(const double& scalar) const
{
return ossimLsrVector(theData*scalar, theLsrSpace);
}
//*****************************************************************************
// INLINE OPERATOR: ossimLsrVector::operator/(double scalar)
//*****************************************************************************
inline ossimLsrVector ossimLsrVector::operator/(const double& scalar) const
{
return ossimLsrVector(theData/scalar, theLsrSpace);
}
//*****************************************************************************
// INLINE OPERATOR: ossimLsrVector::operator==(ossimLsrVector)
//*****************************************************************************
inline bool ossimLsrVector::operator==(const ossimLsrVector& v) const
{
return ((theData == v.theData) && (theLsrSpace == v.theLsrSpace));
}
//*****************************************************************************
// INLINE OPERATOR: ossimLsrVector::operator!=(ossimLsrVector)
//*****************************************************************************
inline bool ossimLsrVector::operator!=(const ossimLsrVector& v) const
{
return (!(*this == v));
}
//*****************************************************************************
// INLINE OPERATOR: ossimEcefVector()
//
// Looks like a constructor for an ossimEcefVector but is an operation on this
// object. Returns the ossimEcefVector equivalent.
//
//*****************************************************************************
inline ossimLsrVector::operator ossimEcefVector() const
{
return ossimEcefVector(theLsrSpace.lsrToEcefRotMatrix()*theData);
}
//*****************************************************************************
// INLINE METHOD: ossimLsrVector::unitVector()
// Returns a unit vector parallel to this.
//*****************************************************************************
inline ossimLsrVector ossimLsrVector::unitVector() const
{
if(hasNans()) return ossimLsrVector(ossim::nan(), ossim::nan(), ossim::nan(), theLsrSpace);
return ossimLsrVector(theData/theData.magnitude(), theLsrSpace);
}
//*****************************************************************************
// INLINE METHOD: ossimLsrVector::magnitude()
//*****************************************************************************
inline double ossimLsrVector::magnitude() const
{
if(hasNans()) return ossim::nan();
return theData.magnitude();
}
//*****************************************************************************
// INLINE METHOD: ossimLsrVector::normalize()
// Normalizes this vector.
//*****************************************************************************
inline void ossimLsrVector::normalize()
{
theData /= theData.magnitude();
}
//*****************************************************************************
// PROTECTED INLINE METHOD: ossimLsrPoint::initialize(ossimEcefPoint)
//
// Convenience method used by several constructors for initializing theData
// given an ECEF point. Assumes theLsrSpace has been previously initialized.
//
//*****************************************************************************
inline void ossimLsrVector::initialize(const ossimEcefVector& ecef_vector)
{
theData = theLsrSpace.ecefToLsrRotMatrix() * ecef_vector.data();
}
#endif
|