+/*virtual*/ bool Arc::HitTest(Point point)
+{
+ hitCenter = hitArc = hitRotate = hitSpan = false;
+
+/*
+What we have:
+the center of the arc
+the starting angle
+the span of the arc
+The point on a unit circle given an angle a is x = cos(a), y = sin(a)
+This vector is already unitized, so all we need to do to get our point is to
+multiply it by radius (to get the length correct) and add it to the center
+point (to get the correct position).
+*/
+// Vector v1(point, position); // Head minus tail (vector points at "point")
+ Vector v1(position, point); // Head minus tail (vector points at "point")
+ Point p1(cos(startAngle), sin(startAngle));
+ Point p2(cos(startAngle + angleSpan), sin(startAngle + angleSpan));
+ Vector handle2 = (p1 * radius) + position;
+ Vector handle3 = (p2 * radius) + position;
+ double pointerAngle = v1.Angle();
+ double length = v1.Magnitude();
+
+#if 0
+ if (v1.Magnitude() < 10.0)
+ hitCenter = true;
+ else if (Vector(handle3 - point).Magnitude() < 10.0)
+ hitSpan = true;
+ else if (Vector(handle2 - point).Magnitude() < 10.0)
+ hitRotate = true;
+ else if ((v1.Magnitude() < radius + 3.0) && (v1.Magnitude() > radius - 3.0)
+ && AngleInArcSpan(pointerAngle))
+ hitArc = true;
+#else
+ if ((length * Painter::zoom) < 8.0)
+ {
+ hitCenter = true;
+ snapPoint = position;
+ snapPointIsValid = true;
+ }
+ else if (((fabs(length - radius) * Painter::zoom) < 2.0)
+ && AngleInArcSpan(pointerAngle))
+ hitArc = true;
+ else if ((Vector::Magnitude(handle2, point) * Painter::zoom) < 8.0)
+ {
+ hitRotate = true;
+ snapPoint = handle2;
+ snapPointIsValid = true;
+ }
+ else if ((Vector::Magnitude(handle3, point) * Painter::zoom) < 8.0)
+ {
+ hitSpan = true;
+ snapPoint = handle3;
+ snapPointIsValid = true;
+ }
+#endif
+
+ return (hitCenter || hitArc || hitRotate || hitSpan ? true : false);
+}
+
+