LCOV - code coverage report
Current view: top level - basegfx/source/vector - b3dvector.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 33 81.8 %
Date: 2012-08-25 Functions: 4 5 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 16 43.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <basegfx/vector/b3dvector.hxx>
      30                 :            : #include <basegfx/matrix/b3dhommatrix.hxx>
      31                 :            : 
      32                 :            : //////////////////////////////////////////////////////////////////////////////
      33                 :            : 
      34                 :            : namespace basegfx
      35                 :            : {
      36                 :      51490 :     B3DVector& B3DVector::normalize()
      37                 :            :     {
      38                 :      51490 :         double fLen(scalar(*this));
      39                 :            : 
      40         [ +  - ]:      51490 :         if(!::basegfx::fTools::equalZero(fLen))
      41                 :            :         {
      42                 :      51490 :             const double fOne(1.0);
      43                 :            : 
      44         [ +  + ]:      51490 :             if(!::basegfx::fTools::equal(fOne, fLen))
      45                 :            :             {
      46                 :      14850 :                 fLen = sqrt(fLen);
      47                 :            : 
      48         [ +  - ]:      14850 :                 if(!::basegfx::fTools::equalZero(fLen))
      49                 :            :                 {
      50                 :      14850 :                     mfX /= fLen;
      51                 :      14850 :                     mfY /= fLen;
      52                 :      51490 :                     mfZ /= fLen;
      53                 :            :                 }
      54                 :            :             }
      55                 :            :         }
      56                 :            : 
      57                 :      51490 :         return *this;
      58                 :            :     }
      59                 :            : 
      60                 :      17377 :     B3DVector B3DVector::getPerpendicular(const B3DVector& rNormalizedVec) const
      61                 :            :     {
      62                 :      17377 :         B3DVector aNew(*this);
      63         [ +  - ]:      17377 :         aNew = cross(aNew, rNormalizedVec);
      64         [ +  - ]:      17377 :         aNew.normalize();
      65                 :      17377 :         return aNew;
      66                 :            :     }
      67                 :            : 
      68                 :       2971 :     B3DVector& B3DVector::operator*=( const ::basegfx::B3DHomMatrix& rMat )
      69                 :            :     {
      70                 :       2971 :         const double fTempX( rMat.get(0,0)*mfX + rMat.get(0,1)*mfY + rMat.get(0,2)*mfZ );
      71                 :       2971 :         const double fTempY( rMat.get(1,0)*mfX + rMat.get(1,1)*mfY + rMat.get(1,2)*mfZ );
      72                 :       2971 :         const double fTempZ( rMat.get(2,0)*mfX + rMat.get(2,1)*mfY + rMat.get(2,2)*mfZ );
      73                 :       2971 :         mfX = fTempX;
      74                 :       2971 :         mfY = fTempY;
      75                 :       2971 :         mfZ = fTempZ;
      76                 :            : 
      77                 :       2971 :         return *this;
      78                 :            :     }
      79                 :            : 
      80                 :       2707 :     B3DVector operator*( const ::basegfx::B3DHomMatrix& rMat, const B3DVector& rVec )
      81                 :            :     {
      82                 :       2707 :         B3DVector aRes( rVec );
      83         [ +  - ]:       2707 :         return aRes*=rMat;
      84                 :            :     }
      85                 :            : 
      86                 :          0 :     bool areParallel( const B3DVector& rVecA, const B3DVector& rVecB )
      87                 :            :     {
      88                 :            :         // i think fastest is to compare relations, need no square or division
      89         [ #  # ]:          0 :         if(!fTools::equal(rVecA.getX() * rVecB.getY(), rVecA.getY() * rVecB.getX()))
      90                 :          0 :             return false;
      91                 :            : 
      92         [ #  # ]:          0 :         if(!fTools::equal(rVecA.getX() * rVecB.getZ(), rVecA.getZ() * rVecB.getX()))
      93                 :          0 :             return false;
      94                 :            : 
      95                 :          0 :         return (fTools::equal(rVecA.getY() * rVecB.getZ(), rVecA.getZ() * rVecB.getY()));
      96                 :            :     }
      97                 :            : 
      98                 :            : } // end of namespace basegfx
      99                 :            : 
     100                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10