Draw a perfect circle from user's touch

后端 未结 7 1789
天命终不由人
天命终不由人 2021-01-29 17:28

I have this practice project that allows the user to draw on the screen as they touch with their fingers. Very simple App I did as exercise way back. My little cousin took the l

7条回答
  •  南笙
    南笙 (楼主)
    2021-01-29 17:38

    Once you determine the user finished drawing their shape where they started, you can take a sample of the coordinates that they drew through and try fitting them to a circle.

    There is a MATLAB solution to this problem here: http://www.mathworks.com.au/matlabcentral/fileexchange/15060-fitcircle-m

    Which is based on the paper Least-Squares Fitting of Circles and Ellipses by Walter Gander, Gene H. Golub and Rolf Strebel: http://www.emis.de/journals/BBMS/Bulletin/sup962/gander.pdf

    Dr Ian Coope from the University of Canterbury, NZ published a paper with the abstract:

    The problem of determining the circle of best fit to a set of points in the plane (or the obvious generalization to n-dimensions) is easily formulated as a nonlinear total least-squares problem which may be solved using a Gauss-Newton minimization algorithm. This straight-forward approach is shown to be inefficient and extremely sensitive to the presence of outliers. An alternative formulation allows the problem to be reduced to a linear least squares problem which is trivially solved. The recommended approach is shown to have the added advantage of being much less sensitive to outliers than the nonlinear least squares approach.

    http://link.springer.com/article/10.1007%2FBF00939613

    The MATLAB file can compute both the nonlinear TLS and linear LLS problem.

提交回复
热议问题