blob: 9f782b18a9f08558ec876090e30f1ae8b7fb36d6 [file] [log] [blame]
#include "LineUtilities.h"
bool implicitLine(const _Line& line, double& slope, double& axisIntercept) {
double lineDx = line[1].x - line[0].x;
double lineDy = line[1].y - line[0].y;
bool moreHorizontal = fabs(lineDx) > fabs(lineDy);
if (moreHorizontal) {
slope = lineDy / lineDx;
axisIntercept = line[0].y - slope * line[0].x;
} else {
slope = lineDx / lineDy;
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;
}