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

3 次查看(过去 30 天)
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 个评论
John D'Errico
John D'Errico 2017-7-12
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.

请先登录,再进行评论。

回答(1 个)

KSSV
KSSV 2017-7-13
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 个评论
SAMUEL AYINDE
SAMUEL AYINDE 2017-7-13
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Smoothing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by