vb6 图像框中判断 矩形Shape控件与直线是否有交点,怎么计算
展开全部
Function Intersect(a As Shape, i As Line) As Boolean
Dim L, R, T, B
L = a.Left
R = L + a.Width
T = a.Top
B = T + a.Height
With i
If (.X1 < L And .X2 < L) Or (.X1 > R And .X2 > R) Or _
(.Y1 < T And .Y2 < T) Or (.Y1 > B And .Y2 > B) Then
Intersect = False
ElseIf .X1 = .X2 Or .Y1 = .Y2 Then
Intersect = True
Else
Intersect = (- _
((L - .X1) / (.X2 - .X1) > (T - .Y1) / (.Y2 - .Y1)) - _
((L - .X1) / (.X2 - .X1) > (B - .Y1) / (.Y2 - .Y1)) - _
((R - .X1) / (.X2 - .X1) > (T - .Y1) / (.Y2 - .Y1)) - _
((R - .X1) / (.X2 - .X1) > (B - .Y1) / (.Y2 - .Y1)) _
) Mod 4
End If
End With
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询