vb6 图像框中判断 矩形Shape控件与直线是否有交点,怎么计算
答案:1 悬赏:80 手机版
解决时间 2021-11-18 09:01
- 提问者网友:辞取
- 2021-11-18 03:32
vb6 图像框中判断 矩形Shape控件与直线是否有交点,怎么计算
最佳答案
- 五星知识达人网友:孤独入客枕
- 2021-11-18 04:32
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
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
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯