summaryrefslogtreecommitdiff
path: root/basegfx/source/vector/b2dvector.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx/source/vector/b2dvector.cxx')
-rw-r--r--basegfx/source/vector/b2dvector.cxx233
1 files changed, 115 insertions, 118 deletions
diff --git a/basegfx/source/vector/b2dvector.cxx b/basegfx/source/vector/b2dvector.cxx
index ed0325b446a5..d9c46044211c 100644
--- a/basegfx/source/vector/b2dvector.cxx
+++ b/basegfx/source/vector/b2dvector.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dvector.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: thb $ $Date: 2003-11-12 12:11:24 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:18:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -73,163 +73,160 @@
namespace basegfx
{
- namespace vector
+ B2DVector& B2DVector::normalize()
{
- B2DVector& B2DVector::normalize()
+ double fLen(scalar(*this));
+
+ if(!::basegfx::fTools::equalZero(fLen))
{
- double fLen(scalar(*this));
+ const double fOne(1.0);
- if(!::basegfx::numeric::fTools::equalZero(fLen))
+ if(!::basegfx::fTools::equal(fOne, fLen))
{
- const double fOne(1.0);
+ fLen = sqrt(fLen);
- if(!::basegfx::numeric::fTools::equal(fOne, fLen))
+ if(!::basegfx::fTools::equalZero(fLen))
{
- fLen = sqrt(fLen);
-
- if(!::basegfx::numeric::fTools::equalZero(fLen))
- {
- mfX /= fLen;
- mfY /= fLen;
- }
+ mfX /= fLen;
+ mfY /= fLen;
}
}
-
- return *this;
- }
-
- B2DVector& B2DVector::operator=( const ::basegfx::tuple::B2DTuple& rVec )
- {
- mfX = rVec.getX();
- mfY = rVec.getY();
- return *this;
}
+ return *this;
+ }
- double B2DVector::getLength() const
- {
- return hypot( mfX, mfY );
- }
-
- double B2DVector::scalar( const B2DVector& rVec ) const
- {
- return((mfX * rVec.mfX) + (mfY * rVec.mfY));
- }
+ B2DVector& B2DVector::operator=( const ::basegfx::B2DTuple& rVec )
+ {
+ mfX = rVec.getX();
+ mfY = rVec.getY();
+ return *this;
+ }
- double B2DVector::cross( const B2DVector& rVec ) const
- {
- return(mfX * rVec.getY() - mfY * rVec.getX());
- }
- double B2DVector::angle( const B2DVector& rVec ) const
- {
- return atan2(mfX * rVec.getY() - mfY * rVec.getX(),
- mfX * rVec.getX() + mfY * rVec.getY());
- }
+ double B2DVector::getLength() const
+ {
+ return hypot( mfX, mfY );
+ }
- const B2DVector& B2DVector::getEmptyVector()
- {
- return (const B2DVector&) ::basegfx::tuple::B2DTuple::getEmptyTuple();
- }
+ double B2DVector::scalar( const B2DVector& rVec ) const
+ {
+ return((mfX * rVec.mfX) + (mfY * rVec.mfY));
+ }
- B2DVector& B2DVector::operator*=( const matrix::B2DHomMatrix& rMat )
- {
- const double fTempX( rMat.get(0,0)*mfX +
- rMat.get(0,1)*mfY );
- const double fTempY( rMat.get(1,0)*mfX +
- rMat.get(1,1)*mfY );
- mfX = fTempX;
- mfY = fTempY;
-
- return *this;
- }
+ double B2DVector::cross( const B2DVector& rVec ) const
+ {
+ return(mfX * rVec.getY() - mfY * rVec.getX());
+ }
- B2DVector& B2DVector::setLength(double fLen)
- {
- double fLenNow(scalar(*this));
+ double B2DVector::angle( const B2DVector& rVec ) const
+ {
+ return atan2(mfX * rVec.getY() - mfY * rVec.getX(),
+ mfX * rVec.getX() + mfY * rVec.getY());
+ }
- if(!::basegfx::numeric::fTools::equalZero(fLenNow))
- {
- const double fOne(10.0);
+ const B2DVector& B2DVector::getEmptyVector()
+ {
+ return (const B2DVector&) ::basegfx::B2DTuple::getEmptyTuple();
+ }
- if(!::basegfx::numeric::fTools::equal(fOne, fLenNow))
- {
- fLen /= sqrt(fLenNow);
- }
+ B2DVector& B2DVector::operator*=( const B2DHomMatrix& rMat )
+ {
+ const double fTempX( rMat.get(0,0)*mfX +
+ rMat.get(0,1)*mfY );
+ const double fTempY( rMat.get(1,0)*mfX +
+ rMat.get(1,1)*mfY );
+ mfX = fTempX;
+ mfY = fTempY;
- mfX *= fLen;
- mfY *= fLen;
- }
+ return *this;
+ }
- return *this;
- }
+ B2DVector& B2DVector::setLength(double fLen)
+ {
+ double fLenNow(scalar(*this));
- sal_Bool B2DVector::isNormalized() const
+ if(!::basegfx::fTools::equalZero(fLenNow))
{
- const double fOne(1.0);
- const double fScalar(scalar(*this));
+ const double fOne(10.0);
- return (::basegfx::numeric::fTools::equal(fOne, fScalar));
- }
+ if(!::basegfx::fTools::equal(fOne, fLenNow))
+ {
+ fLen /= sqrt(fLenNow);
+ }
- sal_Bool areParallel( const B2DVector& rVecA, const B2DVector& rVecB )
- {
- double fVal(rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX());
- return ::basegfx::numeric::fTools::equalZero(fVal);
+ mfX *= fLen;
+ mfY *= fLen;
}
- B2DVectorOrientation getOrientation( const B2DVector& rVecA, const B2DVector& rVecB )
- {
- double fVal(rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX());
+ return *this;
+ }
- if(fVal > 0.0)
- {
- return ORIENTATION_POSITIVE;
- }
+ sal_Bool B2DVector::isNormalized() const
+ {
+ const double fOne(1.0);
+ const double fScalar(scalar(*this));
- if(fVal < 0.0)
- {
- return ORIENTATION_NEGATIVE;
- }
+ return (::basegfx::fTools::equal(fOne, fScalar));
+ }
- return ORIENTATION_NEUTRAL;
- }
+ sal_Bool areParallel( const B2DVector& rVecA, const B2DVector& rVecB )
+ {
+ double fVal(rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX());
+ return ::basegfx::fTools::equalZero(fVal);
+ }
+
+ B2DVectorOrientation getOrientation( const B2DVector& rVecA, const B2DVector& rVecB )
+ {
+ double fVal(rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX());
- B2DVector getPerpendicular( const B2DVector& rNormalizedVec )
+ if(fVal > 0.0)
{
- B2DVector aPerpendicular(-rNormalizedVec.getY(), rNormalizedVec.getX());
- return aPerpendicular;
+ return ORIENTATION_POSITIVE;
}
- B2DVector operator*( const matrix::B2DHomMatrix& rMat, const B2DVector& rVec )
+ if(fVal < 0.0)
{
- B2DVector aRes( rVec );
- return aRes*=rMat;
+ return ORIENTATION_NEGATIVE;
}
- ::basegfx::vector::B2DVectorContinuity getContinuity(const B2DVector& rBackVector, const B2DVector& rForwardVector )
+ return ORIENTATION_NEUTRAL;
+ }
+
+ B2DVector getPerpendicular( const B2DVector& rNormalizedVec )
+ {
+ B2DVector aPerpendicular(-rNormalizedVec.getY(), rNormalizedVec.getX());
+ return aPerpendicular;
+ }
+
+ B2DVector operator*( const B2DHomMatrix& rMat, const B2DVector& rVec )
+ {
+ B2DVector aRes( rVec );
+ return aRes*=rMat;
+ }
+
+ ::basegfx::B2DVectorContinuity getContinuity(const B2DVector& rBackVector, const B2DVector& rForwardVector )
+ {
+ ::basegfx::B2DVectorContinuity eRetval(::basegfx::CONTINUITY_NONE);
+
+ if(!rBackVector.equalZero() && !rForwardVector.equalZero())
{
- ::basegfx::vector::B2DVectorContinuity eRetval(::basegfx::vector::CONTINUITY_NONE);
+ const B2DVector aInverseForwardVector(-rForwardVector.getX(), -rForwardVector.getY());
- if(!rBackVector.equalZero() && !rForwardVector.equalZero())
+ if(rBackVector.equal(aInverseForwardVector))
{
- const B2DVector aInverseForwardVector(-rForwardVector.getX(), -rForwardVector.getY());
-
- if(rBackVector.equal(aInverseForwardVector))
- {
- // same direction and same length -> C2
- eRetval = ::basegfx::vector::CONTINUITY_C2;
- }
- else if(areParallel(rBackVector, aInverseForwardVector))
- {
- // same direction -> C1
- eRetval = ::basegfx::vector::CONTINUITY_C1;
- }
+ // same direction and same length -> C2
+ eRetval = ::basegfx::CONTINUITY_C2;
+ }
+ else if(areParallel(rBackVector, aInverseForwardVector))
+ {
+ // same direction -> C1
+ eRetval = ::basegfx::CONTINUITY_C1;
}
-
- return eRetval;
}
- } // end of namespace vector
+
+ return eRetval;
+ }
} // end of namespace basegfx
// eof