blob: 9f782b18a9f08558ec876090e30f1ae8b7fb36d6 [file] [log] [blame]
caryclark@google.com27accef2012-01-25 18:57:23 +00001#include "LineUtilities.h"
2
3bool implicitLine(const _Line& line, double& slope, double& axisIntercept) {
4 double lineDx = line[1].x - line[0].x;
5 double lineDy = line[1].y - line[0].y;
6 bool moreHorizontal = fabs(lineDx) > fabs(lineDy);
7 if (moreHorizontal) {
8 slope = lineDy / lineDx;
9 axisIntercept = line[0].y - slope * line[0].x;
10 } else {
11 slope = lineDx / lineDy;
12 axisIntercept = line[0].x - slope * line[0].y;
13 }
14 return moreHorizontal;
15}
16
17int reduceOrder(const _Line& line, _Line& reduced) {
18 reduced[0] = line[0];
19 int different = line[0] != line[1];
20 reduced[1] = line[different];
21 return 1 + different;
22}