function LineToLineCP(VertLine, WallLine: TGPLineF): TGPPointF;
var
SP, EP, SP1, EP1: TGPPointF;
t: Single;
ReGP: TGPPointF;
begin
SP.X := VertLine.SP.X;
SP.Y := VertLine.SP.Y;
EP.X := VertLine.EP.X;
EP.Y := VertLine.EP.Y;
SP1.X := WallLine.SP.X;
SP1.Y := WallLine.SP.Y;
EP1.X := WallLine.EP.X;
EP1.Y := WallLine.EP.Y;
ReGP.X := SP.X;
ReGP.Y := SP.Y;
// 需判断
if IsEqualValue(SP.X, EP.X) and IsEqualValue(SP1.Y, EP1.Y) then
begin
ReGP.X := SP.X;
ReGP.Y := SP1.Y;
end
else if IsEqualValue(SP.Y, EP.Y) and IsEqualValue(SP1.X, EP1.X) then
begin
ReGP.X := SP1.X;
ReGP.Y := SP.Y;
end
else
begin
t := ((SP.X - SP1.X) * (SP1.Y - EP1.Y) - (SP.Y - SP1.Y) * (SP1.X - EP1.X)) / ((SP.X - EP.X) * (SP1.Y - EP1.Y) - (SP.Y - EP.Y) * (SP1.X - EP1.X));
ReGP.X := ReGP.X + (EP.X - SP.X) * t;
ReGP.Y := ReGP.Y + (EP.Y - SP.Y) * t;
end;
Result := ReGP;
end;
来源:https://www.cnblogs.com/jeenmablog/p/12020596.html