LCOV - code coverage report
Current view: top level - basegfx/source/vector - b3dvector.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 27 33 81.8 %
Date: 2015-06-13 12:38:46 Functions: 4 5 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <basegfx/vector/b3dvector.hxx>
      21             : #include <basegfx/matrix/b3dhommatrix.hxx>
      22             : 
      23             : namespace basegfx
      24             : {
      25      475500 :     B3DVector& B3DVector::normalize()
      26             :     {
      27      475500 :         double fLen(scalar(*this));
      28             : 
      29      475500 :         if(!::basegfx::fTools::equalZero(fLen))
      30             :         {
      31      458501 :             const double fOne(1.0);
      32             : 
      33      458501 :             if(!::basegfx::fTools::equal(fOne, fLen))
      34             :             {
      35      354415 :                 fLen = sqrt(fLen);
      36             : 
      37      354415 :                 if(!::basegfx::fTools::equalZero(fLen))
      38             :                 {
      39      354415 :                     mfX /= fLen;
      40      354415 :                     mfY /= fLen;
      41      354415 :                     mfZ /= fLen;
      42             :                 }
      43             :             }
      44             :         }
      45             : 
      46      475500 :         return *this;
      47             :     }
      48             : 
      49      122701 :     B3DVector B3DVector::getPerpendicular(const B3DVector& rNormalizedVec) const
      50             :     {
      51      122701 :         B3DVector aNew(*this);
      52      122701 :         aNew = cross(aNew, rNormalizedVec);
      53      122701 :         aNew.normalize();
      54      122701 :         return aNew;
      55             :     }
      56             : 
      57       27522 :     B3DVector& B3DVector::operator*=( const ::basegfx::B3DHomMatrix& rMat )
      58             :     {
      59       27522 :         const double fTempX( rMat.get(0,0)*mfX + rMat.get(0,1)*mfY + rMat.get(0,2)*mfZ );
      60       27522 :         const double fTempY( rMat.get(1,0)*mfX + rMat.get(1,1)*mfY + rMat.get(1,2)*mfZ );
      61       27522 :         const double fTempZ( rMat.get(2,0)*mfX + rMat.get(2,1)*mfY + rMat.get(2,2)*mfZ );
      62       27522 :         mfX = fTempX;
      63       27522 :         mfY = fTempY;
      64       27522 :         mfZ = fTempZ;
      65             : 
      66       27522 :         return *this;
      67             :     }
      68             : 
      69       26866 :     B3DVector operator*( const ::basegfx::B3DHomMatrix& rMat, const B3DVector& rVec )
      70             :     {
      71       26866 :         B3DVector aRes( rVec );
      72       26866 :         return aRes*=rMat;
      73             :     }
      74             : 
      75           0 :     bool areParallel( const B3DVector& rVecA, const B3DVector& rVecB )
      76             :     {
      77             :         // i think fastest is to compare relations, need no square or division
      78           0 :         if(!fTools::equal(rVecA.getX() * rVecB.getY(), rVecA.getY() * rVecB.getX()))
      79           0 :             return false;
      80             : 
      81           0 :         if(!fTools::equal(rVecA.getX() * rVecB.getZ(), rVecA.getZ() * rVecB.getX()))
      82           0 :             return false;
      83             : 
      84           0 :         return (fTools::equal(rVecA.getY() * rVecB.getZ(), rVecA.getZ() * rVecB.getY()));
      85             :     }
      86             : 
      87             : } // end of namespace basegfx
      88             : 
      89             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11