- 1、本文档共3页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
代码如下:
Dim n As Long Dim x() As Double Dim y() As Double Dim px As Double Dim py As Double
Private Sub Command1_Click() Command3.Enabled = False Call dzdbxn(n, x(), y(), px, py)
End Sub
Public Function dzdbxn(n As Long, ptx() As Double, pty() As Double, px As Double, py As Double) As Boolean Dim j As Long Dim d1 As Double Dim d2 As Double Dim d3 As Double
dzdbxn = False
For i = 0 To n - 1
j = i + 1: If i = n - 1 Then j = 0
d1 = Abs(ptx(i) * pty(j) + ptx(j) * py + px * pty(i) - ptx(i) * py - ptx(j) * pty(i) - px * pty(j))
Command2 Command3
Command1
Command4
Picture1
Label6
d2 = Pold(ptx(i), pty(i), ptx(j), pty(j))
d3 = Abs(d2 - Pold(ptx(i), pty(i), px, py) - Pold(ptx(j), pty(j), px, py)) d1 = d1 / d2
Picture1.Print i= + Str(i) + j= + Str(j) + d1= + Str(d1) + d3= + Str(d3)
If d1 0.0001 And d3 0.0001 Then dzdbxn = True: Exit Function Next i
If dzdbxn = False Then Dim dx As Double Dim xmax As Double Dim dy As Double Dim ymin As Double
For i = 0 To n - 1
dx = Abs(ptx(i) - px): dy = Abs(pty(i) - py) If i = 0 Then
xmax = dx: ymin = dy Else
If dx xmax Then xmax = dx If dy ymin Then ymin = dy End If Next i
Dim sum As Long
sum = 0: xmax = 2# * xmax For i = 0 To n - 1
j = i + 1: If i = n - 1 Then j = 0
d1 = ymin * (ptx(j) - ptx(i)) - xmax * (pty(j) - pty(i)) d2 = xmax * (pty(i) - py) - ymin * (ptx(i) - px)
d3 = (ptx(j) - ptx(i)) * (pty(i) - py) - (pty(j) - pty(i)) * (ptx(i) - px) If (d2 * (d1 - d2)) = 0# And d3 * d1 = 0# Then sum = sum + 1 Next i
Picture1.Print sum= + Str(sum) + px= + Str(px) + py= + Str(py) If sum 0 And sum 2 * Int(sum / 2) Then dzdbxn = True
Label6.Caption = 点在多边形内
Else
文档评论(0)