1

I have done a lot of research on the topic, but I don't seem to have the right questions to ask. I don't know what to call the problem I'm trying to solve. Thank you in advance for any help.

The problem

Suppose I have a user-drawn circle like this:

Open circle

The circle isn't quite closed, because of user error (it will be drawn with a finger). I want to close the circle, like this:

Closed circle

I only want to do this if the ends of the user-drawn path are close enough together, like so:

Distance to endpoints

This example is exaggerated. I would want them to be closer together than that.

Potential Problems

  • The circle (or ellipse) can be at any orientation.
  • There is no way to force the user to draw a circle, so the user can draw anything, as long as it takes a single stroke.

Thus, I only wish to take the last few points into account and sort of linearly-interpolate between the endpoints.

Conclusion

If you could direct me to a solution/implementation I would be very grateful. Also, if you could tell me what this problem is actually called, or the terminology involved, I could search online for more help. Thanks again!

retrovius
  • 782
  • 1
  • 10
  • 25
  • Not sure on the terminology, but a way that might work is by using a list and the distance functions. If these points can be stored in a list as the user moves their finger, then you can check if the first point in the array and last point are within X distance. From there, you can start shifting the end points in the array appropriately or add additional points to bridge the gap. – Tim Hunter May 22 '19 at 23:35
  • As for how to shift the end points if that's the route you want to go, I recommend using your current points to find a mid-point in the middle of the circle. From there you can adjust the distance of the points from the mid-point to closer form a circle. – Tim Hunter May 22 '19 at 23:38
  • I'd start with the keywords, "circle best fit" – Immersive May 23 '19 at 06:16
  • Would it be possible to check the vector of each end if the line was continued (not in a circular path, but in a straight line)? You might be able to check for connections that way and infer a circle if the vector connects to a point and make the closest circle possible using that line – Eliasar May 23 '19 at 14:24
  • 1
    You can also fit a spline (or other kind of curve) to the points at the two ends and resample in this area. – Nico Schertler May 24 '19 at 20:48
  • @NicoSchertler that is what I was thinking, but I have no idea how to start. Would you be able to direct me to a resource? – retrovius May 26 '19 at 14:21

0 Answers0