40 #include "FGJSBBase.h" 41 #include "FGColumnVector3.h" 51 IDENT(IdSrc,
"$Id: FGColumnVector3.cpp,v 1.17 2014/01/13 10:46:03 ehofman Exp $");
52 IDENT(IdHdr,ID_COLUMNVECTOR3);
58 FGColumnVector3::FGColumnVector3(
void)
60 data[0] = data[1] = data[2] = 0.0;
66 string FGColumnVector3::Dump(
const string& delimiter)
const 69 buffer << std::setprecision(16) << data[0] << delimiter;
70 buffer << std::setprecision(16) << data[1] << delimiter;
71 buffer << std::setprecision(16) << data[2];
79 os << col(1) <<
" , " << col(2) <<
" , " << col(3);
88 return operator*( 1.0/scalar );
90 cerr <<
"Attempt to divide by zero in method \ 91 FGColumnVector3::operator/(const double scalar), \ 92 object " << data[0] <<
" , " << data[1] <<
" , " << data[2] << endl;
101 operator*=( 1.0/scalar );
103 cerr <<
"Attempt to divide by zero in method \ 104 FGColumnVector3::operator/=(const double scalar), \ 105 object " << data[0] <<
" , " << data[1] <<
" , " << data[2] << endl;
112 double FGColumnVector3::Magnitude(
void)
const 114 return sqrt( data[0]*data[0] + data[1]*data[1] + data[2]*data[2] );
121 double Mag = Magnitude();
124 operator*=( 1.0/Mag );
131 double FGColumnVector3::Magnitude(
const int idx1,
const int idx2)
const {
132 return sqrt( data[idx1-1]*data[idx1-1] + data[idx2-1]*data[idx2-1] );
This class implements a 3 element column vector.