Alexandre Villares Posted November 27, 2002 Share Posted November 27, 2002 I guess you must calculate the intersection point and move the closer point of each line to it. Quote Link to comment
Guest Posted November 27, 2002 Share Posted November 27, 2002 I'm using VS 8.5 and I need to be able to join lines. Does anyone know how to do this. Apparently you can't call DoMenuTextbyName('Join',0); which is unfotunate. Any ideas? Quote Link to comment
Alexandre Villares Posted November 28, 2002 Share Posted November 28, 2002 A bit crude, it lacks a failure (parallel) flag, but it works ok. Provide two line handles and it'll give back a 'vector', it's components are the point's coordinates. Now on VW10 we have the POINT structure, but then, we have LineLineIntersect... {-----------------------------------------------------} Function IntersectP (hd1,hd2:HANDLE): VECTOR; {-----------------------------------------------------} var p1_1,p1_2,p2_1,p2_2:VECTOR; {quatro pontos} a1,a2, b1,b2:REAL; {A ? a inclina??o , B o ponto no eixo Y} L1,L2, P :VECTOR; V1,V2:BOOLEAN; Begin GetSegPt1(hd1, p1_1.X, p1_1.Y); GetSegPt2(hd1, p1_2.X, p1_2.Y); GetSegPt1(hd2, p2_1.X, p2_1.Y); GetSegPt2(hd2, p2_2.X, p2_2.Y); L1.x:= p1_2.x - p1_1.x; L1.y:= p1_2.y - p1_1.y; IF L1.x<>0 THEN BEGIN V1:=FALSE; a1:=L1.y/L1.x; b1:= p1_1.y- a1*p1_1.x; END ELSE BEGIN V1:=TRUE; b1:=p1_1.x; END; L2.x:= p2_2.x - p2_1.x; L2.y:= p2_2.y - p2_1.y; IF L2.x<>0 THEN BEGIN V2:=FALSE; a2:=L2.y/L2.x; b2:= p2_1.y- a2*p2_1.x; END ELSE BEGIN V2:=TRUE; b2:=p2_1.x; END; IF V1 then begin P.X := b1; P.Y := (a2 * b1) + b2; end else IF V2 then begin P.X := b2; P.Y := (a1 * b2) + b1; end else begin P.X := (b2 - b1) / (a1 - a2); P.Y := (a1 * P.X) + b1; end; IntersectP.X := P.X; IntersectP.Y := P.Y; {-----------------------------------------------------} End; {IntersectP} {-----------------------------------------------------} [ 11-28-2002, 06:28 AM: Message edited by: Alexandre B A Villares ] Quote Link to comment
Guest Posted December 2, 2002 Share Posted December 2, 2002 Thanks a lot. this was a huge help!!! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.