more 发表于 2005-11-5 15:09:00

[求助]求交点!!!

不在同一个平面的两条直线,怎么才能找到它们的“交点(就是移动到同一平面上的那个交点)”??,要求:除了把它们移到同一个平面上,还要怎么求??

zxj_76 发表于 2005-11-7 08:42:00

把它们的坐标取出来,用数学的方法求!

Orcagna 发表于 2005-11-7 11:35:00

<P>先把线化成 L1:ax+by=c ; L2:a2x+b2y=c2,<BR>然后套入二元一次线性方程式求解,<BR>求出来的答案,就是它的交点了。<BR>要注意的是,有可能是平行线,<BR>所以在求解之前,要先算一下斜率。</P>

sieben 发表于 2005-11-7 16:01:00

<P>同3楼的思路,VB6的代码</P>
<P>Function LL_Inter(ByRef List1() As Double, ByVal p1 As Variant, ByVal p2 As Variant, Optional ByVal p3 As Variant, _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Optional ByVal p4 As Variant) As Variant<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim Line1(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim Line2(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; If TypeName(p4) = "Error" Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If TypeName(p3) = "Error" Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line1(0) = p1(0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line1(1) = p1(1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line1(2) = p1(2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line2(0) = p2(0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line2(1) = p2(1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line2(2) = p2(2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line_Equation Line1, p1, p2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line_Equation Line2, p2, p3<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line_Equation Line1, p1, p2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Line_Equation Line2, p3, p4<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Dim dlt As Double<BR>&nbsp;&nbsp;&nbsp; Dim DltX As Double<BR>&nbsp;&nbsp;&nbsp; Dim DltY As Double<BR>&nbsp;&nbsp;&nbsp; dlt = Line1(0) * Line2(1) - Line2(0) * Line1(1)<BR>&nbsp;&nbsp;&nbsp; DltX = Line1(2) * Line2(1) - Line2(2) * Line1(1)<BR>&nbsp;&nbsp;&nbsp; DltY = Line1(0) * Line2(2) - Line2(0) - Line1(2)<BR>&nbsp;&nbsp;&nbsp; If Abs(dlt) &lt; 0.000000001 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Abs(DltX) &lt; 0.0000001 And Abs(DltY) &lt; 0.0000001 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LL_Inter = -1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LL_Inter = -2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LL_Inter = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'List1(0) = -DltX / Dlt<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'List1(1) = -DltY / Dlt<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List1(1) = (Line1(0) * Line2(2) - Line2(0) * Line1(2)) / (Line2(0) * Line1(1) - Line1(0) * Line2(1))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List1(0) = (Line1(1) * Line2(2) - Line2(1) * Line1(2)) / (Line2(1) * Line1(0) - Line1(1) * Line2(0))<BR>&nbsp;&nbsp;&nbsp; End If<BR>End Function</P>
<P>Sub Line_Equation(ByRef LParam() As Double, ByVal p1 As Variant, ByVal p2 As Variant)<BR>&nbsp;&nbsp;&nbsp; LParam(0) = p2(1) - p1(1)<BR>&nbsp;&nbsp;&nbsp; LParam(1) = p1(0) - p2(0)<BR>&nbsp;&nbsp;&nbsp; LParam(2) = -1# * LParam(0) * p1(0) - LParam(1) * p1(1)<BR>End Sub</P>

more 发表于 2005-11-8 10:34:00

非常感谢!

gdzhou 发表于 2005-11-8 22:56:00

没看懂,,

guodengch 发表于 2005-12-15 15:08:00

谢谢!..........

he993 发表于 2005-12-26 10:06:00

<P>假如是无法建立数学方程的曲线qline,和直线zline 相交呢?</P>
<P>vb还又没有办法?</P>

BigJue 发表于 2005-12-26 14:55:00

<P>请问什么是无法建立数学方程的曲线?规则的曲线都有方程的吧?</P>
<P>如果曲线不规则,怎么知道它的趋势?怎么求交点?</P>
页: [1]
查看完整版本: [求助]求交点!!!