Joining lines together smoothly with a smooth curve, given the radius and center of the curve and starting and ending coordinates of each curve
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
John D'Errico
el 12 de Jul. de 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.
Respuestas (1)
KSSV
el 13 de Jul. de 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
Ver también
Categorías
Más información sobre Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!