LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/basegfx/vector - b2dvector.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 19 26 73.1 %
Date: 2012-08-25 Functions: 7 9 77.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           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                 :            : #ifndef _BGFX_VECTOR_B2DVECTOR_HXX
      30                 :            : #define _BGFX_VECTOR_B2DVECTOR_HXX
      31                 :            : 
      32                 :            : #include <basegfx/tuple/b2dtuple.hxx>
      33                 :            : #include <basegfx/vector/b2ivector.hxx>
      34                 :            : #include <basegfx/vector/b2enums.hxx>
      35                 :            : #include <basegfx/basegfxdllapi.h>
      36                 :            : 
      37                 :            : namespace basegfx
      38                 :            : {
      39                 :            :     // predeclaration
      40                 :            :     class B2DHomMatrix;
      41                 :            : 
      42                 :            :     /** Base Point class with two double values
      43                 :            : 
      44                 :            :         This class derives all operators and common handling for
      45                 :            :         a 2D data class from B2DTuple. All necessary extensions
      46                 :            :         which are special for 2D Vectors are added here.
      47                 :            : 
      48                 :            :         @see B2DTuple
      49                 :            :     */
      50                 :     126303 :     class BASEGFX_DLLPUBLIC B2DVector : public ::basegfx::B2DTuple
      51                 :            :     {
      52                 :            :     public:
      53                 :            :         /** Create a 2D Vector
      54                 :            : 
      55                 :            :             The vector is initialized to (0.0, 0.0)
      56                 :            :         */
      57                 :     349047 :         B2DVector()
      58                 :     349047 :         :   B2DTuple()
      59                 :     349047 :         {}
      60                 :            : 
      61                 :            :         /** Create a 2D Vector
      62                 :            : 
      63                 :            :             @param fX
      64                 :            :             This parameter is used to initialize the X-coordinate
      65                 :            :             of the 2D Vector.
      66                 :            : 
      67                 :            :             @param fY
      68                 :            :             This parameter is used to initialize the Y-coordinate
      69                 :            :             of the 2D Vector.
      70                 :            :         */
      71                 :     702993 :         B2DVector(double fX, double fY)
      72                 :     702993 :         :   B2DTuple(fX, fY)
      73                 :     702993 :         {}
      74                 :            : 
      75                 :            :         /** Create a copy of a 2D Vector
      76                 :            : 
      77                 :            :             @param rVec
      78                 :            :             The 2D Vector which will be copied.
      79                 :            :         */
      80                 :     284659 :         B2DVector(const B2DVector& rVec)
      81                 :     284659 :         :   B2DTuple(rVec)
      82                 :     284659 :         {}
      83                 :            : 
      84                 :            :         /** Create a copy of a 2D Vector
      85                 :            : 
      86                 :            :             @param rVec
      87                 :            :             The 2D Vector which will be copied.
      88                 :            :         */
      89                 :          0 :         explicit B2DVector(const ::basegfx::B2IVector& rVec)
      90                 :          0 :         :   B2DTuple(rVec)
      91                 :          0 :         {}
      92                 :            : 
      93                 :            :         /** constructor with tuple to allow copy-constructing
      94                 :            :             from B2DTuple-based classes
      95                 :            :         */
      96                 :     214732 :         B2DVector(const ::basegfx::B2DTuple& rTuple)
      97                 :     214732 :         :   B2DTuple(rTuple)
      98                 :     214732 :         {}
      99                 :            : 
     100                 :    1985478 :         ~B2DVector()
     101                 :    1985478 :         {}
     102                 :            : 
     103                 :            :         /** *=operator to allow usage from B2DVector, too
     104                 :            :         */
     105                 :          0 :         B2DVector& operator*=( const B2DVector& rPnt )
     106                 :            :         {
     107                 :          0 :             mfX *= rPnt.mfX;
     108                 :          0 :             mfY *= rPnt.mfY;
     109                 :          0 :             return *this;
     110                 :            :         }
     111                 :            : 
     112                 :            :         /** *=operator to allow usage from B2DVector, too
     113                 :            :         */
     114                 :      35903 :         B2DVector& operator*=(double t)
     115                 :            :         {
     116                 :      35903 :             mfX *= t;
     117                 :      35903 :             mfY *= t;
     118                 :      35903 :             return *this;
     119                 :            :         }
     120                 :            : 
     121                 :            :         /** assignment operator to allow assigning the results
     122                 :            :             of B2DTuple calculations
     123                 :            :         */
     124                 :            :         B2DVector& operator=( const ::basegfx::B2DTuple& rVec );
     125                 :            : 
     126                 :            :         /** Calculate the length of this 2D Vector
     127                 :            : 
     128                 :            :             @return The Length of the 2D Vector
     129                 :            :         */
     130                 :            :         double getLength() const;
     131                 :            : 
     132                 :            :         /** Set the length of this 2D Vector
     133                 :            : 
     134                 :            :             @param fLen
     135                 :            :             The to be achieved length of the 2D Vector
     136                 :            :         */
     137                 :            :         B2DVector& setLength(double fLen);
     138                 :            : 
     139                 :            :         /** Normalize this 2D Vector
     140                 :            : 
     141                 :            :             The length of the 2D Vector is set to 1.0
     142                 :            :         */
     143                 :            :         B2DVector& normalize();
     144                 :            : 
     145                 :            :         /** Calculate the Scalar with another 2D Vector
     146                 :            : 
     147                 :            :             @param rVec
     148                 :            :             The second 2D Vector
     149                 :            : 
     150                 :            :             @return
     151                 :            :             The Scalar value of the two involved 2D Vectors
     152                 :            :         */
     153                 :            :         double scalar( const B2DVector& rVec ) const;
     154                 :            : 
     155                 :            :         /** Calculate the length of the cross product with another 2D Vector
     156                 :            : 
     157                 :            :             In 2D, returning an actual vector does not make much
     158                 :            :             sense here. The magnitude, although, can be readily
     159                 :            :             used for tasks such as angle calculations, since for
     160                 :            :             the returned value, the following equation holds:
     161                 :            :             retVal = getLength(this)*getLength(rVec)*sin(theta),
     162                 :            :             with theta being the angle between the two vectors.
     163                 :            : 
     164                 :            :             @param rVec
     165                 :            :             The second 2D Vector
     166                 :            : 
     167                 :            :             @return
     168                 :            :             The length of the cross product of the two involved 2D Vectors
     169                 :            :         */
     170                 :            :         double cross( const B2DVector& rVec ) const;
     171                 :            : 
     172                 :            :         /** Calculate the Angle with another 2D Vector
     173                 :            : 
     174                 :            :             @param rVec
     175                 :            :             The second 2D Vector
     176                 :            : 
     177                 :            :             @return
     178                 :            :             The Angle value of the two involved 2D Vectors in -pi/2 < return < pi/2
     179                 :            :         */
     180                 :            :         double angle( const B2DVector& rVec ) const;
     181                 :            : 
     182                 :            :         /** Transform vector by given transformation matrix.
     183                 :            : 
     184                 :            :             Since this is a vector, translational components of the
     185                 :            :             matrix are disregarded.
     186                 :            :         */
     187                 :            :         B2DVector& operator*=( const B2DHomMatrix& rMat );
     188                 :            : 
     189                 :            :         static const B2DVector& getEmptyVector();
     190                 :            :     };
     191                 :            : 
     192                 :            :     // external operators
     193                 :            :     //////////////////////////////////////////////////////////////////////////
     194                 :            : 
     195                 :            :     /** Calculate the orientation to another 2D Vector
     196                 :            : 
     197                 :            :         @param rVecA
     198                 :            :         The first 2D Vector
     199                 :            : 
     200                 :            :         @param rVecB
     201                 :            :         The second 2D Vector
     202                 :            : 
     203                 :            :         @return
     204                 :            :         The mathematical Orientation of the two involved 2D Vectors
     205                 :            :     */
     206                 :            :     BASEGFX_DLLPUBLIC B2VectorOrientation getOrientation( const B2DVector& rVecA, const B2DVector& rVecB );
     207                 :            : 
     208                 :            :     /** Calculate a perpendicular 2D Vector to the given one
     209                 :            : 
     210                 :            :         @param rVec
     211                 :            :         The source 2D Vector
     212                 :            : 
     213                 :            :         @attention This only works if the given 2D Vector is normalized.
     214                 :            : 
     215                 :            :         @return
     216                 :            :         A 2D Vector perpendicular to the one given in parameter rVec
     217                 :            :     */
     218                 :            :     BASEGFX_DLLPUBLIC B2DVector getPerpendicular( const B2DVector& rNormalizedVec );
     219                 :            : 
     220                 :            :     /** Calculate a perpendicular 2D Vector to the given one,
     221                 :            :         normalize the given one as preparation
     222                 :            : 
     223                 :            :         @param rVec
     224                 :            :         The source 2D Vector
     225                 :            : 
     226                 :            :         @return
     227                 :            :         A normalized 2D Vector perpendicular to the one given in parameter rVec
     228                 :            :     */
     229                 :            :     BASEGFX_DLLPUBLIC B2DVector getNormalizedPerpendicular( const B2DVector& rVec );
     230                 :            : 
     231                 :            :     /** Test two vectors which need not to be normalized for parallelism
     232                 :            : 
     233                 :            :         @param rVecA
     234                 :            :         The first 2D Vector
     235                 :            : 
     236                 :            :         @param rVecB
     237                 :            :         The second 2D Vector
     238                 :            : 
     239                 :            :         @return
     240                 :            :         bool if the two values are parallel. Also true if
     241                 :            :         one of the vectors is empty.
     242                 :            :     */
     243                 :            :     BASEGFX_DLLPUBLIC bool areParallel( const B2DVector& rVecA, const B2DVector& rVecB );
     244                 :            : 
     245                 :            :     /** Transform vector by given transformation matrix.
     246                 :            : 
     247                 :            :         Since this is a vector, translational components of the
     248                 :            :         matrix are disregarded.
     249                 :            :     */
     250                 :            :     BASEGFX_DLLPUBLIC B2DVector operator*( const B2DHomMatrix& rMat, const B2DVector& rVec );
     251                 :            : 
     252                 :            :     /** Test continuity between given vectors.
     253                 :            : 
     254                 :            :         The two given vectors are assumed to describe control points on a
     255                 :            :         common point. Calculate if there is a continuity between them.
     256                 :            :     */
     257                 :            :     BASEGFX_DLLPUBLIC B2VectorContinuity getContinuity( const B2DVector& rBackVector, const B2DVector& rForwardVector );
     258                 :            : 
     259                 :            : } // end of namespace basegfx
     260                 :            : 
     261                 :            : #endif /* _BGFX_VECTOR_B2DVECTOR_HXX */
     262                 :            : 
     263                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10