skia2/experimental/Intersection/LineUtilities.cpp
caryclark@google.com c682590538 save work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@3141 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-02-03 22:07:47 +00:00

24 lines
673 B
C++

#include "CurveIntersection.h"
#include "LineUtilities.h"
bool implicitLine(const _Line& line, double& slope, double& axisIntercept) {
_Point delta;
tangent(line, delta);
bool moreHorizontal = fabs(delta.x) > fabs(delta.y);
if (moreHorizontal) {
slope = delta.y / delta.x;
axisIntercept = line[0].y - slope * line[0].x;
} else {
slope = delta.x / delta.y;
axisIntercept = line[0].x - slope * line[0].y;
}
return moreHorizontal;
}
int reduceOrder(const _Line& line, _Line& reduced) {
reduced[0] = line[0];
int different = line[0] != line[1];
reduced[1] = line[different];
return 1 + different;
}