+// Vector orthogonal = Vector::Normal(position, endpoint);
+ Vector orthogonal = Vector::Normal(linePt1, linePt2);
+ // Get our line parallel to our points
+#if 0
+ Point p1 = position + (orthogonal * 10.0 * size);
+ Point p2 = endpoint + (orthogonal * 10.0 * size);
+#else
+ Point p1 = linePt1 + (orthogonal * 10.0 * size);
+ Point p2 = linePt2 + (orthogonal * 10.0 * size);
+#endif
+ Point p3(p1, point);
+
+ hitPoint1 = hitPoint2 = hitLine = hitFlipSwitch = hitChangeSwitch1
+ = hitChangeSwitch2 = false;
+ Vector v1(position, point);
+ Vector v2(endpoint, point);
+// Vector lineSegment(position, endpoint);
+ Vector lineSegment(p1, p2);
+// double t = Geometry::ParameterOfLineAndPoint(position, endpoint, point);
+ double t = Geometry::ParameterOfLineAndPoint(p1, p2, point);
+ double distance;
+ Point midpoint = (p1 + p2) / 2.0;
+ Point hFSPoint = Point(midpoint, point);
+ Point hCS1Point = Point((p1 + midpoint) / 2.0, point);
+ Point hCS2Point = Point((midpoint + p2) / 2.0, point);
+
+ if (t < 0.0)
+ distance = v1.Magnitude();
+ else if (t > 1.0)
+ distance = v2.Magnitude();
+ else
+ // distance = ?Det?(ls, v1) / |ls|
+// distance = fabs((lineSegment.x * v1.y - v1.x * lineSegment.y)
+ distance = fabs((lineSegment.x * p3.y - p3.x * lineSegment.y)
+ / lineSegment.Magnitude());
+
+ if ((v1.Magnitude() * Painter::zoom) < 8.0)
+ hitPoint1 = true;
+ else if ((v2.Magnitude() * Painter::zoom) < 8.0)
+ hitPoint2 = true;
+ else if ((distance * Painter::zoom) < 5.0)
+ hitLine = true;
+
+ if ((hFSPoint.Magnitude() * Painter::zoom) < 8.0)
+ hitFlipSwitch = true;
+ else if ((hCS1Point.Magnitude() * Painter::zoom) < 8.0)
+ hitChangeSwitch1 = true;
+ else if ((hCS2Point.Magnitude() * Painter::zoom) < 8.0)
+ hitChangeSwitch2 = true;
+
+ return (hitPoint1 || hitPoint2 || hitLine || hitFlipSwitch || hitChangeSwitch1 || hitChangeSwitch2 ? true : false);