I would like C# code for determining the centre and radius of the circle that best fits the points in an array using the least squares method or equivalent.
Having searched on web I’ve found none.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can either use a general minimization algorithm such as Levenberg-Marquardt or turn it into a linear problem and just solve for the parameters of the circle (x,y, radius). See this link for more information.
I’m not aware of any multivaraible Levenberg-Marquardt for .NET so the second solution is probably easier to go for. Note that you will need to solve a matrix equation of the form Ax=b to find your circle parameters. The Math.NET library seems able to do this.