caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame^] | 1 | #include "CurveIntersection.h" |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 2 | #include "LineUtilities.h" |
| 3 | |
| 4 | bool implicitLine(const _Line& line, double& slope, double& axisIntercept) { |
caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame^] | 5 | _Point delta; |
| 6 | tangent(line, delta); |
| 7 | bool moreHorizontal = fabs(delta.x) > fabs(delta.y); |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 8 | if (moreHorizontal) { |
caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame^] | 9 | slope = delta.y / delta.x; |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 10 | axisIntercept = line[0].y - slope * line[0].x; |
| 11 | } else { |
caryclark@google.com | c682590 | 2012-02-03 22:07:47 +0000 | [diff] [blame^] | 12 | slope = delta.x / delta.y; |
caryclark@google.com | 27accef | 2012-01-25 18:57:23 +0000 | [diff] [blame] | 13 | axisIntercept = line[0].x - slope * line[0].y; |
| 14 | } |
| 15 | return moreHorizontal; |
| 16 | } |
| 17 | |
| 18 | int reduceOrder(const _Line& line, _Line& reduced) { |
| 19 | reduced[0] = line[0]; |
| 20 | int different = line[0] != line[1]; |
| 21 | reduced[1] = line[different]; |
| 22 | return 1 + different; |
| 23 | } |