charlesli8
发表于 2015-2-1 23:02:48
'//极角比较, 返回-1: p0p1 在 p0p2 的右侧,返回 0:p0,p1,p2 共线
Public Function Cmp_PolarAngel(P1 As point, P2 As point, pb As point) As Long
Dim delta As Double
delta = (P1.x - pb.x) * (P2.y - pb.y) - (P2.x - pb.x) * (P1.y - pb.y)
If delta < 0# Then
Cmp_PolarAngel = 1
ElseIf delta = 0# Then
Cmp_PolarAngel = 0
Else
Cmp_PolarAngel = -1
End If
End Function
charlesli8
发表于 2015-2-1 23:05:08
charlesli8 发表于 2015-2-1 21:12 static/image/common/back.gif
你说的是主代码吧?
'//极角比较, 返回-1: p0p1 在 p0p2 的右侧,返回 0:p0,p1,p2 共线
Public Function Cmp_PolarAngel(P1 As point, P2 As point, pb As point) As Long
Dim delta As Double
delta = (P1.x - pb.x) * (P2.y - pb.y) - (P2.x - pb.x) * (P1.y - pb.y)
If delta < 0# Then
Cmp_PolarAngel = 1
ElseIf delta = 0# Then
Cmp_PolarAngel = 0
Else
Cmp_PolarAngel = -1
End If
End Function
这个函数中的x.y是从哪里来的? delta = (P1.x - pb.x) * (P2.y - pb.y) - (P2.x - pb.x) * (P1.y - pb.y)这一句可否解释下多谢
zzyong00
发表于 2015-2-1 23:54:04
point是自定义类型,包括x,y
delta = (P1.x - pb.x) * (P2.y - pb.y) - (P2.x - pb.x) * (P1.y - pb.y)这一句就是向量叉积!
charlesli8
发表于 2015-2-2 19:15:31
charlesli8 发表于 2015-2-1 21:12 static/image/common/back.gif
你说的是主代码吧?
'//极角比较, 返回-1: p0p1 在 p0p2 的右侧,返回 0:p0,p1,p2 共线
Public Function Cmp_PolarAngel(P1 As point, P2 As point, pb As point) As Long
Dim delta As Double
delta = (P1.x - pb.x) * (P2.y - pb.y) - (P2.x - pb.x) * (P1.y - pb.y)
If delta < 0# Then
Cmp_PolarAngel = 1
ElseIf delta = 0# Then
Cmp_PolarAngel = 0
Else
Cmp_PolarAngel = -1
End If
End Function
这是个传递函数,请问x,y是从哪里来的,还有delta = (P1.x - pb.x) * (P2.y - pb.y) - (P2.x - pb.x) * (P1.y - pb.y) 是怎么计算的?
charlesli8
发表于 2015-2-2 19:17:47
'//极角比较, 返回-1: p0p1 在 p0p2 的右侧,返回 0:p0,p1,p2 共线
Public Function Cmp_PolarAngel(P1 As point, P2 As point, pb As point) As Long
Dim delta As Double
delta = (P1.x - pb.x) * (P2.y - pb.y) - (P2.x - pb.x) * (P1.y - pb.y)
If delta < 0# Then
Cmp_PolarAngel = 1
ElseIf delta = 0# Then
Cmp_PolarAngel = 0
Else
Cmp_PolarAngel = -1
End If
End Function
这是个传递函数,请问x, y是从哪里来的?delta = (P1.x - pb.x) * (P2.y - pb.y) - (P2.x - pb.x) * (P1.y - pb.y)是怎么算的?
zzyong00
发表于 2015-2-2 19:49:15
x,y是选择那些点,然后把acadpoint的x,y给point(p1,p2,pb)
第二个问题,你看看向量叉积的相关书箱吧(网上找)
charlesli8
发表于 2015-2-6 18:26:02
charlesli8 发表于 2015-2-1 21:12 static/image/common/back.gif
你说的是主代码吧?
这思路我也会,代码写了几天了还是弄不出来。
有些事说起来容易,做起来难,估计你也不一定能写出来呢。
charlesli8
发表于 2015-2-6 21:44:02
charlesli8 发表于 2015-2-1 21:12 static/image/common/back.gif
你说的是主代码吧?
你自己试着写下那个代码吧我反正是写不出来你试试 真不一定能写出来 有的事看起来简单,但自己做起来就不是那么简单了
charlesli8
发表于 2015-2-6 21:50:12
这玩意还有第二页,我说我一发布怎么就不见了呢。叉乘我看了,你说的思路方法我也试了,就是没试出来。你试试,要能写出来,我付给你20明经币。
zzyong00
发表于 2015-2-6 22:52:22
论坛是个学习的地方,如果你真的需要源码,可以到http://bbs.mjtd.com/plugin.php?id=it618_wike:wikehall发布任务