JSBSim Flight Dynamics Model  1.2.0 (05 Nov 2023)
An Open Source Flight Dynamics and Control Software Library in C++
FGColumnVector3 Class Reference

Detailed Description

This class implements a 3 element column vector.

Author
Jon S. Berndt, Tony Peden, et. al.

Definition at line 65 of file FGColumnVector3.h.

#include <FGColumnVector3.h>

Public Member Functions

 FGColumnVector3 (const double X, const double Y, const double Z)
 Initialization by given values. More...
 
 FGColumnVector3 (const FGColumnVector3 &v)
 Copy constructor. More...
 
 FGColumnVector3 (void)
 Default initializer. 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)
 Write access the entries of the vector. More...
 
double Entry (const unsigned int idx) const
 Read access the entries of the vector. More...
 
void InitMatrix (const double a)
 
void InitMatrix (const double a, const double b, const double c)
 
void InitMatrix (void)
 
double Magnitude (const int idx1, const int idx2) const
 Length of the vector in a coordinate axis plane. More...
 
double Magnitude (void) const
 Length of the vector. More...
 
FGColumnVector3Normalize (void)
 Normalize. More...
 
bool operator!= (const FGColumnVector3 &b) const
 Comparison operator. More...
 
double & operator() (const unsigned int idx)
 Write access the entries of the vector. More...
 
double operator() (const unsigned int idx) const
 Read 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...
 
FGColumnVector3operator= (std::initializer_list< double > lv)
 Assignment operator. More...
 
bool operator== (const FGColumnVector3 &b) const
 Comparison operator. More...
 

Constructor & Destructor Documentation

◆ FGColumnVector3() [1/3]

FGColumnVector3 ( void  )

Default initializer.

Create a zero vector.

Definition at line 55 of file FGColumnVector3.cpp.

56 {
57  data[0] = data[1] = data[2] = 0.0;
58  // Debug(0);
59 }

◆ 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 77 of file FGColumnVector3.h.

77  {
78  data[0] = X;
79  data[1] = Y;
80  data[2] = Z;
81  }

◆ 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 86 of file FGColumnVector3.h.

86  {
87  data[0] = v.data[0];
88  data[1] = v.data[1];
89  data[2] = v.data[2];
90  }

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 63 of file FGColumnVector3.cpp.

64 {
65  ostringstream buffer;
66  buffer << std::setprecision(16) << data[0] << delimiter;
67  buffer << std::setprecision(16) << data[1] << delimiter;
68  buffer << std::setprecision(16) << data[2];
69  return buffer.str();
70 }

◆ Entry() [1/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 127 of file FGColumnVector3.h.

127 { return data[idx-1]; }

◆ Entry() [2/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 117 of file FGColumnVector3.h.

117 { return data[idx-1]; }

◆ Magnitude() [1/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 128 of file FGColumnVector3.cpp.

128  {
129  return sqrt( data[idx1-1]*data[idx1-1] + data[idx2-1]*data[idx2-1] );
130 }

◆ Magnitude() [2/2]

double Magnitude ( void  ) const

Length of the vector.

Compute and return the euclidean norm of this vector.

Definition at line 109 of file FGColumnVector3.cpp.

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

◆ 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 116 of file FGColumnVector3.cpp.

117 {
118  double Mag = Magnitude();
119 
120  if (Mag != 0.0)
121  operator*=( 1.0/Mag );
122 
123  return *this;
124 }
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 165 of file FGColumnVector3.h.

165 { return ! operator==(b); }
bool operator==(const FGColumnVector3 &b) const
Comparison operator.

◆ operator()() [1/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 107 of file FGColumnVector3.h.

107 { return data[idx-1]; }

◆ operator()() [2/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 100 of file FGColumnVector3.h.

100 { 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 171 of file FGColumnVector3.h.

171  {
172  return FGColumnVector3(scalar*data[0], scalar*data[1], scalar*data[2]);
173  }
FGColumnVector3(void)
Default initializer.

◆ 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 186 of file FGColumnVector3.h.

186  {
187  return FGColumnVector3( data[1] * V.data[2] - data[2] * V.data[1],
188  data[2] * V.data[0] - data[0] * V.data[2],
189  data[0] * V.data[1] - data[1] * V.data[0] );
190  }

◆ 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 82 of file FGColumnVector3.cpp.

83 {
84  if (scalar != 0.0)
85  return operator*( 1.0/scalar );
86 
87  cerr << "Attempt to divide by zero in method \
88  FGColumnVector3::operator/(const double scalar), \
89  object " << data[0] << " , " << data[1] << " , " << data[2] << endl;
90  return FGColumnVector3();
91 }
FGColumnVector3 operator*(const double scalar) const
Multiplication by a scalar.

◆ operator=() [1/2]

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 137 of file FGColumnVector3.h.

137  {
138  data[0] = b.data[0];
139  data[1] = b.data[1];
140  data[2] = b.data[2];
141  return *this;
142  }

◆ operator=() [2/2]

FGColumnVector3& operator= ( std::initializer_list< double >  lv)
inline

Assignment operator.

Parameters
lvinitializer list of at most 3 values (i.e. {x, y, Z}) Copy the content of the list into *this.

Definition at line 147 of file FGColumnVector3.h.

147  {
148  double *v = data;
149  for(auto &x : lv)
150  *(v++) = x;
151 
152  return *this;
153  }

◆ 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 158 of file FGColumnVector3.h.

158  {
159  return data[0] == b.data[0] && data[1] == b.data[1] && data[2] == b.data[2];
160  }

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