Jump to content
Developer Wiki and Function Reference Links ×

Joining Lines


Guest

Recommended Posts

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 ]

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...