Hi guys,
I have 3 lines , labelled accordingly as '1' , '2' and '3'.
Basically I want to have the relevant endpoints of lines '2' and '3' meet at the relevant endpoints of line '1'.
Below is my code. I have 2 blocks of the same code, with one showing what I currently have and what I'd like to achieve in my Line drawing.
Basically, for the portion of code with What I'd like to Achieve , I manually modified the 'Lines' matrix accordingly to suit.
I'd like to ask for you guys' help on automatically determining where to ensure lines 2 and 3 meet at the relevant endpoints of line 1(whose coordinates are always fixed).
I'd like to prevent stuff happening where for example Line's 2 endpoint ends up at the end point where ideally Line 3 is supposed to connect to that specific endpoint of Line 1.
I know I'm asking a bit. But help if you can.
Cheers
audley
% Currently what I have 
clc;
clear all;
close all;
Lines = [ 8.199 9.128 24.2 191.48
11 9.2977 66 12.625
10 191.22 106 193.03 ]
X1 = Lines(:,1)
Y1 = Lines(:,2)
X2=Lines(:,3)
Y2= Lines(:,4)
K=[ X1 Y1 X2 Y2] ;
K_pts = reshape(K.',2,[]).';
midpt =[ (X1+X2)/2 (Y1+Y2)/2 ] ;
midx = midpt(:,1);
midy = midpt(:,2);
for i = 1:length(X1)
draw_lines(i)=line([ X1(i) X2(i)], [Y1(i) Y2(i)] ,'Color', 'r','LineStyle','','Linewidth' ,1.5 );
text(midx(i),midy(i),num2str(i),'FontSize',11,'Color','b');
end
%
% What I'd like to get 
clc;
clear all;
% close all;
Lines = [ 8.199 9.128 24.2 191.48
8.199 9.128 66 12.625
24.2 191.48 106 193.03 ]
X1 = Lines(:,1)
Y1 = Lines(:,2)
X2=Lines(:,3)
Y2= Lines(:,4)
K=[ X1 Y1 X2 Y2] ;
K_pts = reshape(K.',2,[]).';
midpt =[ (X1+X2)/2 (Y1+Y2)/2 ] ;
midx = midpt(:,1);
midy = midpt(:,2);
figure,
for i = 1:length(X1)
draw_lines(i)=line([ X1(i) X2(i)], [Y1(i) Y2(i)] ,'Color', 'r','LineStyle','','Linewidth' ,1.5 );
text(midx(i),midy(i),num2str(i),'FontSize',11,'Color','b');
end
%
