LCOV - code coverage report
Current view: top level - math - FGColumnVector3.cpp (source / functions) Hit Total Coverage
Test: JSBSim-Coverage-Statistics Lines: 27 43 62.8 %
Date: 2010-08-24 Functions: 10 12 83.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 22 27.3 %

           Branch data     Line data    Source code
       1                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       2                 :            : 
       3                 :            : Module: FGColumnVector3.cpp
       4                 :            : Author: Originally by Tony Peden [formatted here by JSB]
       5                 :            : Date started: 1998
       6                 :            : Purpose: FGColumnVector3 class
       7                 :            : Called by: Various
       8                 :            : 
       9                 :            :  ------------- Copyright (C) 1998 Tony Peden and Jon S. Berndt (jon@jsbsim.org) -
      10                 :            : 
      11                 :            :  This program is free software; you can redistribute it and/or modify it under
      12                 :            :  the terms of the GNU Lesser General Public License as published by the Free Software
      13                 :            :  Foundation; either version 2 of the License, or (at your option) any later
      14                 :            :  version.
      15                 :            : 
      16                 :            :  This program is distributed in the hope that it will be useful, but WITHOUT
      17                 :            :  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      18                 :            :  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      19                 :            :  details.
      20                 :            : 
      21                 :            :  You should have received a copy of the GNU Lesser General Public License along with
      22                 :            :  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
      23                 :            :  Place - Suite 330, Boston, MA  02111-1307, USA.
      24                 :            : 
      25                 :            :  Further information about the GNU Lesser General Public License can also be found on
      26                 :            :  the world wide web at http://www.gnu.org.
      27                 :            : 
      28                 :            : FUNCTIONAL DESCRIPTION
      29                 :            : --------------------------------------------------------------------------------
      30                 :            : 
      31                 :            : HISTORY
      32                 :            : --------------------------------------------------------------------------------
      33                 :            : ??/??/??   TP   Created
      34                 :            : 03/16/2000 JSB  Added exception throwing
      35                 :            : 
      36                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      37                 :            : INCLUDES
      38                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      39                 :            : 
      40                 :            : #include "FGColumnVector3.h"
      41                 :            : #include <iostream>
      42                 :            : #include <sstream>
      43                 :            : #include <iomanip>
      44                 :            : #include <cmath>
      45                 :            : 
      46                 :            : using namespace std;
      47                 :            : 
      48                 :            : namespace JSBSim {
      49                 :            : 
      50                 :            : static const char *IdSrc = "$Id: FGColumnVector3.cpp,v 1.13 2010/08/08 00:19:21 jberndt Exp $";
      51                 :            : static const char *IdHdr = ID_COLUMNVECTOR3;
      52                 :            : 
      53                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      54                 :            : CLASS IMPLEMENTATION
      55                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      56                 :            : 
      57                 :    1404531 : FGColumnVector3::FGColumnVector3(void)
      58                 :            : {
      59                 :     270027 :   data[0] = data[1] = data[2] = 0.0;
      60                 :            :   // Debug(0);
      61                 :    1404531 : }
      62                 :            : 
      63                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      64                 :            : 
      65                 :     127634 : string FGColumnVector3::Dump(const string& delimiter) const
      66                 :            : {
      67                 :     127634 :   ostringstream buffer;
      68                 :     127634 :   buffer << std::setw(18) << std::setprecision(16) << data[0] << delimiter;
      69                 :     127634 :   buffer << std::setw(18) << std::setprecision(16) << data[1] << delimiter;
      70                 :     510536 :   buffer << std::setw(18) << std::setprecision(16) << data[2];
      71                 :     127634 :   return buffer.str();
      72                 :            : }
      73                 :            : 
      74                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      75                 :            : 
      76                 :          4 : ostream& operator<<(ostream& os, const FGColumnVector3& col)
      77                 :            : {
      78                 :          8 :   os << col(1) << " , " << col(2) << " , " << col(3);
      79                 :          4 :   return os;
      80                 :            : }
      81                 :            : 
      82                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      83                 :            : 
      84                 :     270027 : FGColumnVector3 FGColumnVector3::operator/(const double scalar) const
      85                 :            : {
      86         [ +  - ]:     270027 :   if (scalar != 0.0)
      87                 :     270027 :     return operator*( 1.0/scalar );
      88                 :            : 
      89                 :            :   cerr << "Attempt to divide by zero in method \
      90                 :            :     FGColumnVector3::operator/(const double scalar), \
      91                 :          0 :     object " << data[0] << " , " << data[1] << " , " << data[2] << endl;
      92                 :          0 :   return FGColumnVector3();
      93                 :            : }
      94                 :            : 
      95                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      96                 :            : 
      97                 :      53103 : FGColumnVector3& FGColumnVector3::operator/=(const double scalar)
      98                 :            : {
      99         [ +  - ]:      53103 :   if (scalar != 0.0)
     100                 :      53103 :     operator*=( 1.0/scalar );
     101                 :            :   else
     102                 :            :     cerr << "Attempt to divide by zero in method \
     103                 :            :       FGColumnVector3::operator/=(const double scalar), \
     104                 :          0 :       object " << data[0] << " , " << data[1] << " , " << data[2] << endl;
     105                 :            : 
     106                 :      53103 :   return *this;
     107                 :            : }
     108                 :            : 
     109                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     110                 :            : 
     111                 :     598979 : double FGColumnVector3::Magnitude(void) const
     112                 :            : {
     113                 :     598979 :   return sqrt( data[0]*data[0] +  data[1]*data[1] +  data[2]*data[2] );
     114                 :            : }
     115                 :            : 
     116                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     117                 :            : 
     118                 :      54006 : FGColumnVector3& FGColumnVector3::Normalize(void)
     119                 :            : {
     120                 :      54006 :   double Mag = Magnitude();
     121                 :            : 
     122         [ +  - ]:      54006 :   if (Mag != 0.0)
     123                 :      54006 :     operator*=( 1.0/Mag );
     124                 :            : 
     125                 :      54006 :   return *this;
     126                 :            : }
     127                 :            : 
     128                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
     129                 :            : //    The bitmasked value choices are as follows:
     130                 :            : //    unset: In this case (the default) JSBSim would only print
     131                 :            : //       out the normally expected messages, essentially echoing
     132                 :            : //       the config files as they are read. If the environment
     133                 :            : //       variable is not set, debug_lvl is set to 1 internally
     134                 :            : //    0: This requests JSBSim not to output any messages
     135                 :            : //       whatsoever.
     136                 :            : //    1: This value explicity requests the normal JSBSim
     137                 :            : //       startup messages
     138                 :            : //    2: This value asks for a message to be printed out when
     139                 :            : //       a class is instantiated
     140                 :            : //    4: When this value is set, a message is displayed when a
     141                 :            : //       FGModel object executes its Run() method
     142                 :            : //    8: When this value is set, various runtime state variables
     143                 :            : //       are printed out periodically
     144                 :            : //    16: When set various parameters are sanity checked and
     145                 :            : //       a message is printed out when they go out of bounds
     146                 :            : 
     147                 :          0 : void FGColumnVector3::Debug(int from)
     148                 :            : {
     149         [ #  # ]:          0 :   if (debug_lvl <= 0) return;
     150                 :            : 
     151                 :          0 :   if (debug_lvl & 1) { // Standard console startup message output
     152                 :            :   }
     153         [ #  # ]:          0 :   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
     154         [ #  # ]:          0 :     if (from == 0) cout << "Instantiated: FGColumnVector3" << endl;
     155         [ #  # ]:          0 :     if (from == 1) cout << "Destroyed:    FGColumnVector3" << endl;
     156                 :            :   }
     157                 :          0 :   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
     158                 :            :   }
     159                 :          0 :   if (debug_lvl & 8 ) { // Runtime state variables
     160                 :            :   }
     161                 :          0 :   if (debug_lvl & 16) { // Sanity checking
     162                 :            :   }
     163         [ #  # ]:          0 :   if (debug_lvl & 64) {
     164         [ #  # ]:          0 :     if (from == 0) { // Constructor
     165                 :          0 :       cout << IdSrc << endl;
     166                 :          0 :       cout << IdHdr << endl;
     167                 :            :     }
     168                 :            :   }
     169                 :            : }
     170                 :            : 
     171 [ +  + ][ +  - ]:         12 : } // namespace JSBSim

Generated by: LCOV version 1.9