How to get the majority of points which makes a circle

Hello friends,

I’m trying to get the majority of points which could make up a circle like this:

Where the green points are the majority of points which makes the correct circle and the red points are either outside or inside the circle.

Using the fit circle through point command on all the points from the beginning will obviously result in the circle taking the red points into consideration and offsetting the circle either inside or outside from where it needs to be.

So I’m trying to get only the green points (in Grasshopper) so I could fit a circle through them.

Many Thanks for your help in advance :slight_smile:

Roy.

take centroid of all the points, calculate distance of each point to centroid, pick soem values to use as R of circle, use R to filter distance, use those points to fit your circle

circle from commonest radius.gh (20.8 KB)

Thank you so much for your valuable help Ethan , I’m sorry I didn’t add the example,
I wasn’t thinking anyone would use it like this… :pray:

For anyone’s convenience here is my example and your solution (which I’ve edited):
circle from commonest radius Example.3dm (202.8 KB)
circle from commonest radius.gh (17.1 KB)

and Thank you too @markz, your solution is the same and what I was looking for.

1 Like

It’s more interesting when the center point is unknown…

circle_fit_majority_center_unknown.gh (33.5 KB)

2 Likes

It’s interesting because your looking at the most common radius gives you a value of 101.75 but using @markz 's suggestion of determining the centroid gives an average distance of 109.75.

Just to be sure I started with a point set where I knew the exact origin. My solution creates 3 point arcs and extracts the number of times a radius occurs.

I assume by “take centroid of all the points” Mark means average… This is not precise.

Your points already separated by layer.
In case they are in the same layer and in different location:

circle from commonest radius__.gh (35.7 KB)

Thank you @anon39580149, The separation of layers was just for the sake of demonstration in different colors.

What I really have to start with is a deformed circle curve that I need to make as perfect as it could be, so I was thinking to get the curve’s points and create a new circle out of the majority of the points which are on the same “virtual circle”…

Here is a real scenario:

Create Circle from curve points.gh (8.9 KB)
Create Circle from curve points.3dm (52.2 KB)

Speaking about accuracy @akilli I don’t think the center of the existing curve (or its points) is the center of the most accurate circle that could fit there.

which makes @martinsiegrist solution maybe more relevant but it got me this cool thing:

but I can’t tell you I figured the solution out yet :slight_smile:

I was thinking of a method to someway evaluate if any point is on an arc together with its next and last points and somehow create a list of points which are the most common on arcs which shares the same radius… and then it could really get the “common points”… Does it make any sense?

If the points are not derived from actual circles and do not have a clear center point, some sort of rounding is required. I wouldn’t create circles from three consecutive points shuffle the list and create lists with three points each.

Here’s a file with three different ways to compare the results.

circle_from_curve_points.gh (38.0 KB)

Try this, i forgot about it and it is very useful

Thank you @anon39580149 I’ve tried it on my curve and the result wasn’t so accurate.

Looking For the Common Radius or angle between points.gh (24.4 KB)
Thank for your help! it’s almost perfect… I’ve also rebuilt the curve to Degree 3 to smooth it out and it worked even better and got an more accurate result.

You are right, one approach is rounding the circle but as your solution is great, it still takes all points into consideration. I was wondering if I could get it to be even more accurate by ignoring the points which are not the common points of the circle that could virtually fit through most points.

So I was also trying two other things, assuming the points are derived from a curve which is almost a real circle, I even had it rebuilt with Degree 3 to smooth it out and was trying to compare consecutive arcs (more like all arcs from any 3 points) which didn’t produce a common radius as you can see.
I’ve also tried to make the arcs larger, spanning 5 points for example but still didn’t get a common value.

and also tried to rebuild the curve to Degree 3 to smooth it out a bit and rebuilt again to Degree 1 to convert it to straight lines and then tried to compare the angle between any two consecutive lines.
Still no common value appeared… but a wide range.

I was thinking this direction should make sense but I guess I’m still missing something.


Looking For the Common Radius or angle between points.gh (24.4 KB)