璁$畻浜ょ偣浠ュ強鏄惁鍦ㄧ洿绾垮唴
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了璁$畻浜ょ偣浠ュ強鏄惁鍦ㄧ洿绾垮唴相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/ssl' title='ssl'>ssl tor The cross var line reg pointf ros
function IsCrossLine(Line1,Line2:TGPLineF):Boolean;
var
SP, EP, SP1, EP1: TGPPointF;
denominator, ua, ub: Single;
t: Single;
CrossP:TGPPointF;
IsCross:Boolean;
MinValue,MaxValue:single;
begin
Result:= False;
SP:= Line1.SP;
EP:= Line1.EP;
SP1:= Line2.SP;
EP1:= Line2.EP;
IsCross:=False;
if Abs(Abs(Line1.Angle)-Abs(Line2.Angle))<0.01 then
Exit;
// 姘村钩鎴栧瀭鐩存柟鍚?br /> if Abs(SP.X-EP.X)<0.01 and Abs(SP1.Y-EP1.Y)<0.01 then
begin
Result := True;
end
else if Abs(SP.Y - EP.Y)<0.01 and Abs(SP1.X - EP1.X)<0.01 then
begin
Result := True;
end
else
begin
denominator := (EP1.Y - SP1.Y) * (EP.X - SP.X) - (EP1.X - SP1.X) * (EP.Y - SP.Y);
if denominator < 0.001 then
Result := False;
ua := ((EP1.X - SP1.X) * (SP.Y - SP1.Y) - (EP1.Y - SP1.Y) * (SP.X - SP1.X)) / denominator;
ub := ((EP.X - SP.X) * (SP.Y - SP1.Y) - (EP.Y - SP.Y) * (SP.X - SP1.X)) / denominator;
if (ua >= 0.00) and (ua <= 1.00) and (ub >= 0.00) and (ub <= 1.00) then
begin
IsCross := True;
end;
end;
if IsCross then
begin
if Abs(SP.X-EP.X)<0.01 and Abs(SP1.Y-EP1.Y)<0.01 then
begin
CrossP.X := SP.X;
CrossP.Y := SP1.Y;
Result:=True;
end
else if Abs(SP.Y, EP.Y)<0.01 and Abs(SP1.X, EP1.X)<0.01 then
begin
CrossP.X := SP1.X;
CrossP.Y := SP.Y;
Result:=True;
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));
CrossP.X := ReGP.X + (EP.X - SP.X) * t;
CrossP.Y := ReGP.Y + (EP.Y - SP.Y) * t;
if Abs(Line2.Angle)>0.01 then
begin
MinValue:= Min(Line2.SP.Y,Line2.SP.Y)+0.01;
MaxValue:= Min(Line2.SP.Y,Line2.SP.Y)+0.01;
if (CrossP.Y<=MaxValue) and (CrossP.Y>=MaxValue) then
Result:= True;
end else
begin
MinValue:= Min(Line2.SP.X,Line2.SP.X)+0.01;
MaxValue:= Min(Line2.SP.X,Line2.SP.X)+0.01;
if (CrossP.X<=MaxValue) and (CrossP.X>=MaxValue) then
Result:= True;
end;
end;
end;
end;
以上是关于璁$畻浜ょ偣浠ュ強鏄惁鍦ㄧ洿绾垮唴的主要内容,如果未能解决你的问题,请参考以下文章