LCOV - code coverage report
Current view: top level - basegfx/source/vector - b3dvector.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 27 33 81.8 %
Date: 2014-11-03 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      869489 :     B3DVector& B3DVector::normalize()
      26             :     {
      27      869489 :         double fLen(scalar(*this));
      28             : 
      29      869489 :         if(!::basegfx::fTools::equalZero(fLen))
      30             :         {
      31      835459 :             const double fOne(1.0);
      32             : 
      33      835459 :             if(!::basegfx::fTools::equal(fOne, fLen))
      34             :             {
      35      689672 :                 fLen = sqrt(fLen);
      36             : 
      37      689672 :                 if(!::basegfx::fTools::equalZero(fLen))
      38             :                 {
      39      689672 :                     mfX /= fLen;
      40      689672 :                     mfY /= fLen;
      41      689672 :                     mfZ /= fLen;
      42             :                 }
      43             :             }
      44             :         }
      45             : 
      46      869489 :         return *this;
      47             :     }
      48             : 
      49      217131 :     B3DVector B3DVector::getPerpendicular(const B3DVector& rNormalizedVec) const
      50             :     {
      51      217131 :         B3DVector aNew(*this);
      52      217131 :         aNew = cross(aNew, rNormalizedVec);
      53      217131 :         aNew.normalize();
      54      217131 :         return aNew;
      55             :     }
      56             : 
      57       51309 :     B3DVector& B3DVector::operator*=( const ::basegfx::B3DHomMatrix& rMat )
      58             :     {
      59       51309 :         const double fTempX( rMat.get(0,0)*mfX + rMat.get(0,1)*mfY + rMat.get(0,2)*mfZ );
      60       51309 :         const double fTempY( rMat.get(1,0)*mfX + rMat.get(1,1)*mfY + rMat.get(1,2)*mfZ );
      61       51309 :         const double fTempZ( rMat.get(2,0)*mfX + rMat.get(2,1)*mfY + rMat.get(2,2)*mfZ );
      62       51309 :         mfX = fTempX;
      63       51309 :         mfY = fTempY;
      64       51309 :         mfZ = fTempZ;
      65             : 
      66       51309 :         return *this;
      67             :     }
      68             : 
      69       51177 :     B3DVector operator*( const ::basegfx::B3DHomMatrix& rMat, const B3DVector& rVec )
      70             :     {
      71       51177 :         B3DVector aRes( rVec );
      72       51177 :         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.10