diff options
author | Noel Grandin <noel@peralex.com> | 2016-01-15 12:00:55 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-01-15 12:39:46 +0000 |
commit | e15a997b153551a4c0e91964b5cff1b6269a9790 (patch) | |
tree | 93208827148e6df46ff6d24048ba92745124050d /tools/source/generic | |
parent | 9f62954369a5d77f976f616623495ad27be6b099 (diff) |
loplugin:unusedmethods unused return value in include/tools
Change-Id: I77a6a46ca20cb41ed73050185fb2064a1bbf2009
Reviewed-on: https://gerrit.libreoffice.org/21485
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'tools/source/generic')
-rw-r--r-- | tools/source/generic/poly.cxx | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 8dc2e21e9947..9b2961e3d501 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -28,7 +28,6 @@ #include <tools/gen.hxx> #include <poly.h> #include <tools/line.hxx> -#include <tools/vector2d.hxx> #include <tools/poly.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/point/b2dpoint.hxx> @@ -1122,6 +1121,30 @@ void Polygon::AdaptiveSubdivide( Polygon& rResult, const double d ) const } } +class Vector2D +{ +private: + double mfX; + double mfY; +public: + Vector2D( const Pair& rPair ) : mfX( rPair.A() ), mfY( rPair.B() ) {}; + double GetLength() const { return hypot( mfX, mfY ); } + Vector2D& operator-=( const Vector2D& rVec ) { mfX -= rVec.mfX, mfY -= rVec.mfY; return *this; } + double Scalar( const Vector2D& rVec ) const { return mfX * rVec.mfX + mfY * rVec.mfY ; } + Vector2D& Normalize(); + bool IsPositive( Vector2D& rVec ) const { return ( mfX * rVec.mfY - mfY * rVec.mfX ) >= 0.0; } + bool IsNegative( Vector2D& rVec ) const { return !IsPositive( rVec ); } +}; +Vector2D& Vector2D::Normalize() +{ + double fLen = Scalar( *this ); + + if( ( fLen != 0.0 ) && ( fLen != 1.0 ) && ( ( fLen = sqrt( fLen ) ) != 0.0 ) ) + mfX /= fLen, mfY /= fLen; + + return *this; +} + void Polygon::ImplReduceEdges( tools::Polygon& rPoly, const double& rArea, sal_uInt16 nPercent ) { const double fBound = 2000.0 * ( 100 - nPercent ) * 0.01; |