Lines Matching full:line
14 From http://en.wikipedia.org/wiki/Line-line_intersection
38 Determine the intersection point of two line segments
128 int horizontalIntersect(const _Line& line, double y, double tRange[2]) {
129 double min = line[0].y;
130 double max = line[1].y;
142 tRange[0] = (y - line[0].y) / (line[1].y - line[0].y);
146 // OPTIMIZATION Given: dy = line[1].y - line[0].y
147 // and: xIntercept / (y - line[0].y) == (line[1].x - line[0].x) / dy
148 // then: xIntercept * dy == (line[1].x - line[0].x) * (y - line[0].y)
149 // Assuming that dy is always > 0, the line segment intercepts if:
151 // thus: left * dy <= (line[1].x - line[0].x) * (y - line[0].y) <= right * dy
154 int horizontalLineIntersect(const _Line& line, double left, double right,
156 int result = horizontalIntersect(line, y, tRange);
161 double xIntercept = line[0].x + tRange[0] * (line[1].x - line[0].x);
168 int horizontalIntersect(const _Line& line, double left, double right,
170 int result = horizontalIntersect(line, y, intersections.fT[0]);
175 double xIntercept = line[0].x + intersections.fT[0][0]
176 * (line[1].x - line[0].x);
185 double lineL = line[0].x;
186 double lineR = line[1].x;
198 intersections.fT[0][0] = (overlapL - line[0].x) / (line[1].x - line[0].x);
201 intersections.fT[0][1] = (overlapR - line[0].x) / (line[1].x - line[0].x);
205 double a0 = line[0].x;
206 double a1 = line[1].x;
226 return computePoints(line, 1 + second, intersections);
231 // OPTIMIZATION: instead of swapping, pass original line, use [1].x - [0].x
236 return computePoints(line, result, intersections);
239 static int verticalIntersect(const _Line& line, double x, double tRange[2]) {
240 double min = line[0].x;
241 double max = line[1].x;
253 tRange[0] = (x - line[0].x) / (line[1].x - line[0].x);
257 int verticalIntersect(const _Line& line, double top, double bottom,
259 int result = verticalIntersect(line, x, intersections.fT[0]);
264 double yIntercept = line[0].y + intersections.fT[0][0]
265 * (line[1].y - line[0].y);
274 double lineT = line[0].y;
275 double lineB = line[1].y;
287 intersections.fT[0][0] = (overlapT - line[0].y) / (line[1].y - line[0].y);
290 intersections.fT[0][1] = (overlapB - line[0].y) / (line[1].y - line[0].y);
294 double a0 = line[0].y;
295 double a1 = line[1].y;
315 return computePoints(line, 1 + second, intersections);
320 // OPTIMIZATION: instead of swapping, pass original line, use [1].y - [0].y
325 return computePoints(line, result, intersections);