- 积分
- 24557
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2004-4-23 22:49:00
|
显示全部楼层
本帖最后由 作者 于 2004-4-23 23:53:22 编辑
- Public Function GetVal(Line1 As AcadLine, Line2 As AcadLine) As Integer
- Dim c As AcadLine
- Dim a(1) As Double, b(1) As Double
- Dim d(2) As Double, e(2) As Double
- If Line1.Angle <> Line2.Angle Then GetVal = 0: Exit Function
- GetVal = 1
- e(1) = 1
- Set c = ThisDrawing.ModelSpace.AddLine(d, e)
- If c.Angle = Line1.Angle Then
- h = c.StartPoint
- h(0) = h(0) + 1
- c.StartPoint = h
- End If
- f = c.IntersectWith(Line1, acExtendBoth)
- g = c.IntersectWith(Line2, acExtendBoth)
- c.Delete
- If Abs(f(0) - g(0)) < 10 ^ -8 And Abs(f(1) - g(1)) < 10 ^ -8 Then
- GetVal = 2
- If Line1.StartPoint(0) = Line1.EndPoint(0) Then
- a(0) = Min(Line1.StartPoint(1), Line1.EndPoint(1))
- a(1) = Max(Line1.StartPoint(1), Line1.EndPoint(1))
- b(0) = Min(Line2.StartPoint(1), Line2.EndPoint(1))
- b(1) = Max(Line2.StartPoint(1), Line2.EndPoint(1))
- Else
- a(0) = Min(Line1.StartPoint(0), Line1.EndPoint(0))
- a(1) = Max(Line1.StartPoint(0), Line1.EndPoint(0))
- b(0) = Min(Line2.StartPoint(0), Line2.EndPoint(0))
- b(1) = Max(Line2.StartPoint(0), Line2.EndPoint(0))
- End If
- If (a(0) - b(1)) * (a(1) - b(0)) <= 0 Then GetVal = 3
- End If
- End Function
- Function Min(Value1 As Variant, Value2 As Variant) As Variant
- Min = Value1
- If Value2 < Value1 Then Min = Value2
- End Function
- Function Max(Value1 As Variant, Value2 As Variant) As Variant
- Max = Value1
- If Value2 > Value1 Then Max = Value2
- End Function
这是一个判断两直线是否平行且重合的程序不平行返回0平行但不在一直线上返回1平行且在一直线上但不相交返回2平行且在一直线上且相交返回3下一步应该简单了吧 |
|