-1

Example circleI have to draw best-fit circle using multiple points (in AutoCAD). The software only allows for three, but no more, points to be selected.

Circle_2 is there a code I can write and embed it into CAD?

Thank you :)

  • Such question doesn't have an answer. In geometrical meaning what is the solution? Let's imagine situation where You have 4 points which are not rectangular corners. or 15 random points. What is criteria of best-fit? Each point inside circle? Minimal distance to each point? – CAD Developer Jun 24 '22 at 06:17
  • Apologies for the structure of my question. Maybe if I attach an image that should help - I'm not really sure how should I ask. Imagine there are 4, or more, points that resemble a circle and I want to pick most of them (if not all). I obviously will not choose points in the middle - Basically, I want to pick points that, to my judgement, are around the pseudo-circumference. – user3047214 Jun 24 '22 at 08:08
  • As the answear to Your question : "is there a code I can write and embed it into CAD?" Yes, there is a code You can write and embed it into CAD. You may write such code in few languages: .Net, C++, LISP But we can not help You in writing the code as long as we don't know the rules of Your judgement. Like in bake a cake: As programmers we may follow the rules. but can not write the program You want as long as we don't know the rules. The same as baker can't bake what You want as long as he don't know if You would like: bread, pie, muffin – CAD Developer Jun 25 '22 at 19:09
  • I have attached an image showing, in part, what I intent to do. In my definition, it would be a circumference that takes into account all the selected points (see picture - points within blue area), and draws a circumference that sit near or at those points - almost like a linear regression, using least squares of all the selected points, for example. – user3047214 Jun 27 '22 at 13:16
  • identify the circle that fits the provided points in the plane most effectively from the least-squares perspective. Picture attached (Circle_2) – user3047214 Jun 27 '22 at 13:21
  • In a situation in which you have the data points x, y that are distributed in a ring-shape on an x-y plane, the least-squares regression can be used to determine the equation of a circle that will best fit with the available data points; i.e., the following regression will help you to calculate the k, m, and r values of the curve: (x − k)2 + (y − m)2 = r2 When you use the least-squares, you determine the "best fit" by minimizing the equation as follows: F(k, m, r) = ∑[(xi − k)2 + (yi − m)2 − r2]2 – user3047214 Jun 27 '22 at 13:23
  • The equation of the circle is linearized by the model ∂F/∂k = 0, ∂F/∂m = 0, and ∂F/∂r = 0. As such, we have the following: (x − k)2 + (y − m)2 = r2 x2 − 2kx + k2 + y2 − 2my + m2 = r2 x2 + y2 = 2kx + 2my + r2 − k2 − m2 x2 + y2 = Ax + By + C This results in a linear equation with the coefficients A, B, and C undetermined. As such, you can use the matrices to solve the least-squares problem. Once you have determined A, B, and C, it is possible to work backward to compute k, m, and r. – user3047214 Jun 27 '22 at 13:23
  • Finding A, B, and C with Matrices The circle regression model is supported by the following matrix equation: where n is the number of data points (xi, yi). In a situation in which the 3-by-3 matrix outlined on the left is invertible, the A, B, and C values are unique, and this determines the best fit circle. You can use the A, B, and C values to subsequently determine k, m, and r: k = A/2 m = B/2 r = (√4C + A² + B²)/2 https://goodcalculators.com/best-fit-circle-least-squares-calculator/ © 2015-2022 goodcalculators.com – user3047214 Jun 27 '22 at 13:24

1 Answers1

0

Like circle_2 I feel like a best fit circle to 4 points or more by minimal distance would be a great function to have.

Deviation of these selected points from the circumference of it would also be quite useful.

4b0
  • 21,981
  • 30
  • 95
  • 142
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 29 '22 at 23:19