Clear Filters
Clear Filters

Can someone propose some code that will "connect the dots" using circular arcs?

5 views (last 30 days)
Can someone propose some alternate or additional code (to the code proposed in my last posting here) that will automatically connect the dots (dots = center points of each triplet), as shown below, to generate the correct polygons from the given points in the attached file (fpep.mat)?
Note 1: The edges of each polygon must be circular arcs (we cannot use splines for this one) that connect all the center points.
Note 2: Each "triplet" will produce precesely 3 circular arcs (except for those along the outer borders).
Note 3: Each arc's initial and final slopes are given by the angle between the centerpoint and the corresponding endpoint for that arc (remember that the inital and final slopes of each arc must be equal-and-opposite; so, the "starting" and "landing" angles must be averaged).
The coords of each endpoint are contained in the first 6 columns of the attached file (fpep.mat) and the coords of the center points are contained in the last two columns.
Once again, I'm excited to see what you can come up with. Thanks in advance for your help!
Image Analyst
Image Analyst on 17 Nov 2019
You did not answer the question. Let me try again.
  1. If one arcs up, however shallowly, and one arcs down, which equation/arc do you pick?
  2. And, why would you even pick either of them? Why not just say the connecting edge is a straight line?
  3. Why do you think you NEED an arc rather than a straight line?
Steve on 17 Nov 2019
Edited: Steve on 17 Nov 2019
I actually answered both your questions; however, it's obvious that I failed to make my points clear enough for every possible member of the audience. Below I have addressed your three (technically four) new questions. This time I have included pictures for clarity:
1. If one arcs up, however shallowly, and one arcs down, which equation/arc do you pick?
I'm not sure what you mean by "which equation/arc do you pick?", because there is only one way that the arc can go--unless you do not care how shallow the arc is; in that case the other arc choice will be very bulbous (see last picture below). The path of the correct arc is determined by the starting and ending slopes (see first picture below).
2. And, why would you even pick either of them? Why not just say the connecting edge is a straight line?
You don't have to "pick" anything. The starting (and ending) slopes of the only possible arc (within a given "shallowness") for a particular endpoint are already given by the angle made by the endpoint and its corresponding center point.
We can not "just say" that the connecting edge is a straight line, because it is not a straight line. All the edges must be circular arcs.
3. Why do you think you NEED an arc rather than a straight line?
I don't just think we need circular arcs, I know we need circular arcs. We need arcs because the original, physical, edges were actually circular arcs--not straight lines. All of our research is based on this fact.
I'm pretty tight with the physics here. What I really need is some help with the MATLAB to produce the arcs and to store all their attributes (i.e., arc lengths, index/node numbers) in a variable.
Thanks again.

Sign in to comment.

Accepted Answer

Matt J
Matt J on 18 Nov 2019
Edited: Matt J on 18 Nov 2019
The spline plotting that we came up with in our previous conversation looked like this
for i=1:N
C1=AP(:,1,i); C2=AP(:,4,i); %Center points
V1=AP(:,2,i); V2=AP(:,3,i); %Triplet end points
s=[0, dot(V1-C1,U)/L , dot(V2-C1,U)/L , 1];
X(:,i)=APi(:,1); %x coordinates on connecting curve
Y(:,i)=APi(:,2); %y coordinates on connecting curve
It is this section of code (and nothing else) that you need to modify to connect C1 and C2 (the center points of the i-th arc) with a different curve of your choosing.You simply must fill X(:,i) and Y(:,i) with the x and y coordinates of the points that form the desired connecting curve (based on C1,V1,V2, and C2).
Steve on 18 Nov 2019
Thanks again for your input Matt. Below is a screenshot of the plot for the latest snippet of code you proposed:
Any idea of what may be going wrong?
Matt J
Matt J on 18 Nov 2019
No idea, but the updated version of TripletGraph that I attached shouldn't have that problem.

Sign in to comment.

More Answers (2)

Steven Lord
Steven Lord on 14 Nov 2019
Are you trying to do something like path planning for an autonomous vehicle, passing through waypoints along the way? If so consider the functions for that purpose in Automated Driving Toolbox.
Steve on 14 Nov 2019
Thanks for your response. We are actually just looking to connect the dots with circular arcs and to store the data of all the connections (i.e., length of circular arcs) for analysis--just some fundamental research we are doing. Do you have an idea on how we could do this?
Thanks again,

Sign in to comment.

Matt J
Matt J on 18 Nov 2019
Edited: Matt J on 18 Nov 2019
I have attached a version of TripletGraph.m which implements methods of joining the points with ideal circular arcs, as well as with the spline and quadratic approximations discussed previously. The code below plots your data with circular and quadratic arcs super-imposed. To my eye, there is no visible difference, so it seems like it should be sufficient to use the quadratic approximation, which as I have said is numerically a lot safer.
load fpep
obj.plotcirc; %join with ideal circular arc formula
hold on;
obj.plotquad; %join with quadratic approximation
hold off
Steve on 20 Nov 2019
If anyone could propose some code mods that will let me extract and store the information listed above (as described in my new post here), it would be greatly appreciated.
Steve on 21 Nov 2019
I have attached a screenshot of an Excel file that I created, which contains the data I manually extracted from running the aforementioned code. We would really like to have Matlab generate it automatically. If anyone can help with this, we would realy appreciate it. Thanks in advance for any help you could offer.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!