8dcf114db9
M Intersection/DataTypes.cpp M Intersection/QuadraticIntersection_Test.cpp M Intersection/EdgeWalker.cpp M Intersection/LineQuadraticIntersection_Test.cpp M Intersection/LineIntersection_Test.cpp M Intersection/LineIntersection.cpp D Intersection/edge.xcodeproj M Intersection/SimplifyFindTop_Test.cpp M Intersection/DataTypes.h A Intersection/SimplifyRect4x4_Test.cpp M Intersection/CubicIntersection_Test.cpp M Intersection/QuadraticUtilities.h M Intersection/LineCubicIntersection_Test.cpp A Intersection/CurveUtilities.h M Intersection/QuadraticBezierClip.cpp M Intersection/QuadraticBounds.cpp M Intersection/LineUtilities.h M Intersection/Intersection_Tests.cpp M Intersection/Simplify.cpp M Intersection/EdgeWalker_TestUtility.cpp M Intersection/QuadraticUtilities.cpp M Intersection/thingsToDo.txt M Intersection/LineUtilities.cpp M Intersection/CubicUtilities.h M Intersection/SimplifyFindNext_Test.cpp M Intersection/Intersection_Tests.h M Intersection/CubicBezierClip.cpp M Intersection/ActiveEdge_Test.cpp M Intersection/CubicBounds.cpp M Intersection/Simplify.h M Intersection/SimplifyNew_Test.cpp M Intersection/EdgeWalker_Test.h M Intersection/CubicUtilities.cpp M Intersection/op.htm M Intersection/ConvexHull.cpp D Intersection/RectUtilities.cpp M Intersection/SimplifyAddIntersectingTs_Test.cpp git-svn-id: http://skia.googlecode.com/svn/trunk@4429 2bbb7eff-a529-9590-31e7-b0007b416f81
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
#include "CurveIntersection.h"
|
|
#include "CurveUtilities.h"
|
|
#include "Extrema.h"
|
|
|
|
static int isBoundedByEndPoints(double a, double b, double c)
|
|
{
|
|
return (a <= b && b <= c) || (a >= b && b >= c);
|
|
}
|
|
|
|
double leftMostT(const Quadratic& quad, double startT, double endT) {
|
|
double leftT;
|
|
if (findExtrema(quad[0].x, quad[1].x, quad[2].x, &leftT)
|
|
&& startT <= leftT && leftT <= endT) {
|
|
return leftT;
|
|
}
|
|
_Point startPt;
|
|
xy_at_t(quad, startT, startPt.x, startPt.y);
|
|
_Point endPt;
|
|
xy_at_t(quad, endT, endPt.x, endPt.y);
|
|
return startPt.x <= endPt.x ? startT : endT;
|
|
}
|
|
|
|
void _Rect::setBounds(const Quadratic& quad) {
|
|
set(quad[0]);
|
|
add(quad[2]);
|
|
double tValues[2];
|
|
int roots = 0;
|
|
if (!isBoundedByEndPoints(quad[0].x, quad[1].x, quad[2].x)) {
|
|
roots = findExtrema(quad[0].x, quad[1].x, quad[2].x, tValues);
|
|
}
|
|
if (!isBoundedByEndPoints(quad[0].y, quad[1].y, quad[2].y)) {
|
|
roots += findExtrema(quad[0].y, quad[1].y, quad[2].y,
|
|
&tValues[roots]);
|
|
}
|
|
for (int x = 0; x < roots; ++x) {
|
|
_Point result;
|
|
xy_at_t(quad, tValues[x], result.x, result.y);
|
|
add(result);
|
|
}
|
|
}
|
|
|
|
void _Rect::setRawBounds(const Quadratic& quad) {
|
|
set(quad[0]);
|
|
for (int x = 1; x < 3; ++x) {
|
|
add(quad[x]);
|
|
}
|
|
}
|