JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGColumnVector3 Class Reference

This class implements a 3 element column vector. More...

#include <FGColumnVector3.h>

Public Member Functions

 FGColumnVector3 (void)
 Default initializer. More...
 
 FGColumnVector3 (const double X, const double Y, const double Z)
 Initialization by given values. More...
 
 FGColumnVector3 (const FGColumnVector3 &v)
 Copy constructor. More...
 
 ~FGColumnVector3 (void)
 Destructor.
 
std::string Dump (const std::string &delimeter) const
 Prints the contents of the vector. More...
 
double Entry (const unsigned int idx) const
 Read access the entries of the vector. More...
 
double & Entry (const unsigned int idx)
 Write access the entries of the vector. More...
 
void InitMatrix (void)
 
void InitMatrix (const double a)
 
void InitMatrix (const double a, const double b, const double c)
 
double Magnitude (void) const
 Length of the vector. More...
 
double Magnitude (const int idx1, const int idx2) const
 Length of the vector in a coordinate axis plane. More...
 
FGColumnVector3Normalize (void)
 Normalize. More...
 
bool operator!= (const FGColumnVector3 &b) const
 Comparison operator. More...
 
double operator() (const unsigned int idx) const
 Read access the entries of the vector. More...
 
double & operator() (const unsigned int idx)
 Write access the entries of the vector. More...
 
FGColumnVector3 operator* (const double scalar) const
 Multiplication by a scalar. More...
 
FGColumnVector3 operator* (const FGColumnVector3 &V) const
 Cross product multiplication. More...
 
FGColumnVector3operator*= (const double scalar)
 Scale by a scalar.
 
FGColumnVector3 operator+ (const FGColumnVector3 &B) const
 Addition operator.
 
FGColumnVector3operator+= (const FGColumnVector3 &B)
 Add an other vector.
 
FGColumnVector3 operator- (const FGColumnVector3 &B) const
 Subtraction operator.
 
FGColumnVector3operator-= (const FGColumnVector3 &B)
 Subtract an other vector.
 
FGColumnVector3 operator/ (const double scalar) const
 Multiply by 1/scalar. More...
 
FGColumnVector3operator/= (const double scalar)
 Scale by a 1/scalar.
 
FGColumnVector3operator= (const FGColumnVector3 &b)
 Assignment operator. More...
 
bool operator== (const FGColumnVector3 &b) const
 Comparison operator. More...
 

Detailed Description

This class implements a 3 element column vector.

Author
Jon S. Berndt, Tony Peden, et. al.
Version
Id
FGColumnVector3.h,v 1.18 2013/11/30 10:25:33 bcoconni Exp

Definition at line 70 of file FGColumnVector3.h.

Constructor & Destructor Documentation

◆ FGColumnVector3() [1/3]

FGColumnVector3 ( void  )

Default initializer.

Create a zero vector.

Definition at line 58 of file FGColumnVector3.cpp.

59 {
60  data[0] = data[1] = data[2] = 0.0;
61  // Debug(0);
62 }
+ Here is the caller graph for this function:

◆ FGColumnVector3() [2/3]

FGColumnVector3 ( const double  X,
const double  Y,
const double  Z 
)
inline

Initialization by given values.

Parameters
Xvalue of the x-conponent.
Yvalue of the y-conponent.
Zvalue of the z-conponent. Create a vector from the doubles given in the arguments.

Definition at line 82 of file FGColumnVector3.h.

82  {
83  data[0] = X;
84  data[1] = Y;
85  data[2] = Z;
86  }

◆ FGColumnVector3() [3/3]

FGColumnVector3 ( const FGColumnVector3 v)
inline

Copy constructor.

Parameters
vVector which is used for initialization. Create copy of the vector given in the argument.

Definition at line 91 of file FGColumnVector3.h.

91  {
92  data[0] = v.data[0];
93  data[1] = v.data[1];
94  data[2] = v.data[2];
95  }

Member Function Documentation

◆ Dump()

string Dump ( const std::string &  delimeter) const

Prints the contents of the vector.

Parameters
delimeterthe item separator (tab or comma)
Returns
a string with the delimeter-separated contents of the vector

Definition at line 66 of file FGColumnVector3.cpp.

67 {
68  ostringstream buffer;
69  buffer << std::setprecision(16) << data[0] << delimiter;
70  buffer << std::setprecision(16) << data[1] << delimiter;
71  buffer << std::setprecision(16) << data[2];
72  return buffer.str();
73 }
+ Here is the caller graph for this function:

◆ Entry() [1/2]

double Entry ( const unsigned int  idx) const
inline

Read access the entries of the vector.

Parameters
idxthe component index. Return the value of the matrix entry at the given index. Indices are counted starting with 1. This function is just a shortcut for the double operator()(unsigned int idx) const function. It is used internally to access the elements in a more convenient way. Note that the index given in the argument is unchecked.

Definition at line 122 of file FGColumnVector3.h.

122 { return data[idx-1]; }
+ Here is the caller graph for this function:

◆ Entry() [2/2]

double& Entry ( const unsigned int  idx)
inline

Write access the entries of the vector.

Parameters
idxthe component index. Return a reference to the vector entry at the given index. Indices are counted starting with 1. This function is just a shortcut for the double& operator()(unsigned int idx) function. It is used internally to access the elements in a more convenient way. Note that the index given in the argument is unchecked.

Definition at line 132 of file FGColumnVector3.h.

132 { return data[idx-1]; }
+ Here is the call graph for this function:

◆ Magnitude() [1/2]

double Magnitude ( void  ) const

Length of the vector.

Compute and return the euclidean norm of this vector.

Definition at line 112 of file FGColumnVector3.cpp.

113 {
114  return sqrt( data[0]*data[0] + data[1]*data[1] + data[2]*data[2] );
115 }
+ Here is the caller graph for this function:

◆ Magnitude() [2/2]

double Magnitude ( const int  idx1,
const int  idx2 
) const

Length of the vector in a coordinate axis plane.

Compute and return the euclidean norm of this vector projected into the coordinate axis plane idx1-idx2.

Definition at line 131 of file FGColumnVector3.cpp.

131  {
132  return sqrt( data[idx1-1]*data[idx1-1] + data[idx2-1]*data[idx2-1] );
133 }

◆ Normalize()

FGColumnVector3 & Normalize ( void  )

Normalize.

Normalize the vector to have the Magnitude() == 1.0. If the vector is equal to zero it is left untouched.

Definition at line 119 of file FGColumnVector3.cpp.

120 {
121  double Mag = Magnitude();
122 
123  if (Mag != 0.0)
124  operator*=( 1.0/Mag );
125 
126  return *this;
127 }
FGColumnVector3 & operator*=(const double scalar)
Scale by a scalar.
double Magnitude(void) const
Length of the vector.
+ Here is the caller graph for this function:

◆ operator!=()

bool operator!= ( const FGColumnVector3 b) const
inline

Comparison operator.

Parameters
bother vector. Returns false if both vectors are exactly the same.

Definition at line 159 of file FGColumnVector3.h.

159 { return ! operator==(b); }
bool operator==(const FGColumnVector3 &b) const
Comparison operator.
+ Here is the call graph for this function:

◆ operator()() [1/2]

double operator() ( const unsigned int  idx) const
inline

Read access the entries of the vector.

Parameters
idxthe component index. Return the value of the matrix entry at the given index. Indices are counted starting with 1. Note that the index given in the argument is unchecked.

Definition at line 105 of file FGColumnVector3.h.

105 { return data[idx-1]; }

◆ operator()() [2/2]

double& operator() ( const unsigned int  idx)
inline

Write access the entries of the vector.

Parameters
idxthe component index. Return a reference to the vector entry at the given index. Indices are counted starting with 1. Note that the index given in the argument is unchecked.

Definition at line 112 of file FGColumnVector3.h.

112 { return data[idx-1]; }

◆ operator*() [1/2]

FGColumnVector3 operator* ( const double  scalar) const
inline

Multiplication by a scalar.

Parameters
scalarscalar value to multiply the vector with.
Returns
The resulting vector from the multiplication with that scalar. Multiply the vector with the scalar given in the argument.

Definition at line 165 of file FGColumnVector3.h.

165  {
166  return FGColumnVector3(scalar*data[0], scalar*data[1], scalar*data[2]);
167  }
FGColumnVector3(void)
Default initializer.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator*() [2/2]

FGColumnVector3 operator* ( const FGColumnVector3 V) const
inline

Cross product multiplication.

Parameters
Vvector to multiply with.
Returns
The resulting vector from the cross product multiplication. Compute and return the cross product of the current vector with the given argument.

Definition at line 180 of file FGColumnVector3.h.

180  {
181  return FGColumnVector3( data[1] * V.data[2] - data[2] * V.data[1],
182  data[2] * V.data[0] - data[0] * V.data[2],
183  data[0] * V.data[1] - data[1] * V.data[0] );
184  }
FGColumnVector3(void)
Default initializer.
+ Here is the call graph for this function:

◆ operator/()

FGColumnVector3 operator/ ( const double  scalar) const

Multiply by 1/scalar.

Parameters
scalarscalar value to devide the vector through.
Returns
The resulting vector from the division through that scalar. Multiply the vector with the 1/scalar given in the argument.

Definition at line 85 of file FGColumnVector3.cpp.

86 {
87  if (scalar != 0.0)
88  return operator*( 1.0/scalar );
89 
90  cerr << "Attempt to divide by zero in method \
91  FGColumnVector3::operator/(const double scalar), \
92  object " << data[0] << " , " << data[1] << " , " << data[2] << endl;
93  return FGColumnVector3();
94 }
FGColumnVector3 operator*(const double scalar) const
Multiplication by a scalar.
FGColumnVector3(void)
Default initializer.
+ Here is the caller graph for this function:

◆ operator=()

FGColumnVector3& operator= ( const FGColumnVector3 b)
inline

Assignment operator.

Parameters
bsource vector. Copy the content of the vector given in the argument into *this.

Definition at line 142 of file FGColumnVector3.h.

142  {
143  data[0] = b.data[0];
144  data[1] = b.data[1];
145  data[2] = b.data[2];
146  return *this;
147  }

◆ operator==()

bool operator== ( const FGColumnVector3 b) const
inline

Comparison operator.

Parameters
bother vector. Returns true if both vectors are exactly the same.

Definition at line 152 of file FGColumnVector3.h.

152  {
153  return data[0] == b.data[0] && data[1] == b.data[1] && data[2] == b.data[2];
154  }
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: