Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
If the program is presented with X and Y coordinates, how do I get the program to connect those dots to form a shape similar to a circle? This means that the program is trying to create a shape by connecting those dots. What I want to know: How do I determine which dots to connect to form the circle(or the shape closest to a circle).
I'm not looking for any specific code, just the algorithm. Thanks:)

Example:

This is the visual representation of the input(the coordinates)

The program will use these coordinates to create a shape by connecting them. The output should show which dots where connected to form that shape. This shape should go through all the dots and still be the closest possible shape(through the dots) to a circle/have the largest possible surface area.
visual representation of the output
The output of this example should be AB,BC,CX,XY,YZ,ZA

What I have tried:

I've tried comparing the distances between the dots to see what the shortest path through all the dots are that end at the starting point and that seems give a good result. I am sure however that there is a more effective algorithm.
Posted
Updated 29-May-18 23:13pm
v4
Comments
Richard MacCutchan 29-May-18 11:03am    
It depends how many co-oordinates are given and in what order.

Your question is unclear.
The question is so vague that I see 2 completely different things that fit the provlem:
- You have a set of points and you want to draw the smallest circle that surround those points.
Smallest-circle problem - Wikipedia[^]
- You have a set of points and you want to draw a convex hull.
Convex hull - Wikipedia[^]

For better answers: clarify your question, give example of input and result you looking for.
[Update]
Quote:
The output of this example should be AB,BC,CX,XY,YZ,ZA

A direct link to AC and removing B would be closer to a circle. Is it what you want ?
 
Share this answer
 
v3
If the dots are all points on a single exact circle, then the path connecting them that is nearest to a circle is the shortest path.
Suppose, as a conjecture, that the path most resembling a circle is in general the shortest path. Then your problem is the traveling salesmen problem, the most famous in computer science. Find the order to visit the points which gives the shortest distance traveled. There is no efficient, exact solution known, but plenty of heuristics will serve the purpose. Simulated annealing will work, see Numerical Recipes. For an slow, exact solution, see http://calgo.acm.org/750.gz
 
Share this answer
 
Do you mean splines[^]?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900