Clear Filters
Clear Filters

Joining lines together smoothly with a smooth curve, given the radius and center of the curve and starting and ending coordinates of each curve

10 views (last 30 days)
I have lines . I want to join them together with smooth curves in order to have a two dimensional geometry. (Check the attached picture). For each curve, I have the coordinates of the starting point, end points and the Center (C). I also have the radius of the curve (r). For example, for the curve to join line 1 and line 2, I have (x1, y1), (x2,y2), (Cx12, Cy12) and r12 ). Please, can someone help me with a Matlab code to implement this? Thank you.
  2 Comments
John D'Errico
John D'Errico on 12 Jul 2017
In general, this is completely impossible to solve.
A circle in a plane is parameterized by THREE numbers: the radius (which you are providing) and the center, thus Cx and Cy.
Therefore, you are asking to find the circle which passes through two points in the plane, as well as creating a smooth intersection at those locations. That means the resulting curve must at least be differentiable. So you have at least FOUR constraints on this circular arc. But I just got done telling you there are only TWO parameters that you can vary. So this is simply NOT possible to do.

Sign in to comment.

Answers (1)

KSSV
KSSV on 13 Jul 2017
Let P1,P2 be your two points and P0 be center. Arc can be drawn using:
P1 = rand(2,1) ;
P2 = rand(2,1) ;
P0 = rand(2,1) ;
n = 1000 ; % The number of points in the arc
v1 = P1-P0;
v2 = P2-P0;
c = det([v1,v2]); % "cross product" of v1 and v2
a = linspace(0,atan2(abs(c),dot(v1,v2)),n); % Angle range
v3 = [0,-c;c,0]*v1; % v3 lies in plane of v1 and v2 and is orthog. to v1
v = v1*cos(a)+((norm(v1)/norm(v3))*v3)*sin(a); % Arc, center at (0,0)
plot(v(1,:)+P0(1),v(2,:)+P0(2),'y.') % Plot arc, centered at P0
axis equal
  1 Comment
SAMUEL AYINDE
SAMUEL AYINDE on 13 Jul 2017
Hi KSSV, The code did not do the job. Please, find my attached M-files of the centers, radii and the line_x and line_y. You will load M-files on your Matlab workspace and run plotthelines.m to generate the lines. Help me adapt your code such that it will join the lines together with smooth curves. Thank you so much.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!