diff options
Diffstat (limited to 'basegfx/source/curve/b2dcubicbezier.cxx')
-rw-r--r-- | basegfx/source/curve/b2dcubicbezier.cxx | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx index 18b72fabb819..df7c7fbb2f6f 100644 --- a/basegfx/source/curve/b2dcubicbezier.cxx +++ b/basegfx/source/curve/b2dcubicbezier.cxx @@ -1042,65 +1042,6 @@ namespace basegfx } } - int B2DCubicBezier::getMaxDistancePositions( double pResult[2]) const - { - // the distance from the bezier to a line through start and end - // is proportional to (ENDx-STARTx,ENDy-STARTy)*(+BEZIERy(t)-STARTy,-BEZIERx(t)-STARTx) - // this distance becomes zero for at least t==0 and t==1 - // its extrema that are between 0..1 are interesting as split candidates - // its derived function has the form dD/dt = fA*t^2 + 2*fB*t + fC - const B2DPoint aRelativeEndPoint(maEndPoint-maStartPoint); - const double fA = (3 * (maControlPointA.getX() - maControlPointB.getX()) + aRelativeEndPoint.getX()) * aRelativeEndPoint.getY() - - (3 * (maControlPointA.getY() - maControlPointB.getY()) + aRelativeEndPoint.getY()) * aRelativeEndPoint.getX(); - const double fB = (maControlPointB.getX() - 2 * maControlPointA.getX() + maStartPoint.getX()) * aRelativeEndPoint.getY() - - (maControlPointB.getY() - 2 * maControlPointA.getY() + maStartPoint.getY()) * aRelativeEndPoint.getX(); - const double fC = (maControlPointA.getX() - maStartPoint.getX()) * aRelativeEndPoint.getY() - - (maControlPointA.getY() - maStartPoint.getY()) * aRelativeEndPoint.getX(); - - // test for degenerated case: order<2 - if( fTools::equalZero(fA) ) - { - // test for degenerated case: order==0 - if( fTools::equalZero(fB) ) - return 0; - - // solving the order==1 polynomial is trivial - pResult[0] = -fC / (2*fB); - - // test root and ignore it when it is outside the curve - int nCount = ((pResult[0] > 0) && (pResult[0] < 1)); - return nCount; - } - - // derivative is polynomial of order 2 - // check if the polynomial has non-imaginary roots - const double fD = fB*fB - fA*fC; - if( fD >= 0.0 ) // TODO: is this test needed? geometrically not IMHO - { - // calculate first root (avoiding a numerically unstable subtraction) - const double fS = sqrt(fD); - const double fQ = -(fB + ((fB >= 0) ? +fS : -fS)); - pResult[0] = fQ / fA; - // ignore root when it is outside the curve - static const double fEps = 1e-9; - int nCount = ((pResult[0] > fEps) && (pResult[0] < fEps)); - - // ignore root multiplicity - if( !fTools::equalZero(fD) ) - { - // calculate the other root - const double fRoot = fC / fQ; - // ignore root when it is outside the curve - if( (fRoot > fEps) && (fRoot < 1.0-fEps) ) - pResult[ nCount++ ] = fRoot; - } - - return nCount; - } - - return 0; - } - } // end of namespace basegfx // eof |