- /* compute area of triangle computed by the two line points and the one
- we are being asked about. If zero (within a given tolerance), the
- points are co-linear and the argument is on the line.
+ if (_points[0].x == _points[1].x) {
+ /* line is vertical, just check x coordinate */
+ return fabs (_points[0].x - p.x) <= threshold;
+ }
+
+ if (_points[0].y == _points[1].y) {
+ /* line is horizontal, just check y coordinate */
+ return fabs (_points[0].y - p.y) <= threshold;
+ }
+
+ Duple at;
+ double t;
+ Duple a (_points[0]);
+ Duple b (_points[1]);
+ const Rect visible (window_to_item (_canvas->visible_area()));
+
+ /*
+ Clamp the line endpoints to the visible area of the canvas. If we do
+ not do this, we have a line segment extending to COORD_MAX and our
+ math goes wrong.