[求助]求交点!!!
不在同一个平面的两条直线,怎么才能找到它们的“交点(就是移动到同一平面上的那个交点)”??,要求:除了把它们移到同一个平面上,还要怎么求?? 把它们的坐标取出来,用数学的方法求! <P>先把线化成 L1:ax+by=c ; L2:a2x+b2y=c2,<BR>然后套入二元一次线性方程式求解,<BR>求出来的答案,就是它的交点了。<BR>要注意的是,有可能是平行线,<BR>所以在求解之前,要先算一下斜率。</P> <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> Optional ByVal p4 As Variant) As Variant<BR> <BR> Dim Line1(0 To 2) As Double<BR> Dim Line2(0 To 2) As Double<BR> If TypeName(p4) = "Error" Then<BR> If TypeName(p3) = "Error" Then<BR> Line1(0) = p1(0)<BR> Line1(1) = p1(1)<BR> Line1(2) = p1(2)<BR> Line2(0) = p2(0)<BR> Line2(1) = p2(1)<BR> Line2(2) = p2(2)<BR> Else<BR> Line_Equation Line1, p1, p2<BR> Line_Equation Line2, p2, p3<BR> End If<BR> Else<BR> Line_Equation Line1, p1, p2<BR> Line_Equation Line2, p3, p4<BR> End If<BR> Dim dlt As Double<BR> Dim DltX As Double<BR> Dim DltY As Double<BR> dlt = Line1(0) * Line2(1) - Line2(0) * Line1(1)<BR> DltX = Line1(2) * Line2(1) - Line2(2) * Line1(1)<BR> DltY = Line1(0) * Line2(2) - Line2(0) - Line1(2)<BR> If Abs(dlt) < 0.000000001 Then<BR> If Abs(DltX) < 0.0000001 And Abs(DltY) < 0.0000001 Then<BR> LL_Inter = -1<BR> Else<BR> LL_Inter = -2<BR> End If<BR> Else<BR> LL_Inter = 0<BR> 'List1(0) = -DltX / Dlt<BR> 'List1(1) = -DltY / Dlt<BR> List1(1) = (Line1(0) * Line2(2) - Line2(0) * Line1(2)) / (Line2(0) * Line1(1) - Line1(0) * Line2(1))<BR> List1(0) = (Line1(1) * Line2(2) - Line2(1) * Line1(2)) / (Line2(1) * Line1(0) - Line1(1) * Line2(0))<BR> End If<BR>End Function</P>
<P>Sub Line_Equation(ByRef LParam() As Double, ByVal p1 As Variant, ByVal p2 As Variant)<BR> LParam(0) = p2(1) - p1(1)<BR> LParam(1) = p1(0) - p2(0)<BR> LParam(2) = -1# * LParam(0) * p1(0) - LParam(1) * p1(1)<BR>End Sub</P> 非常感谢! 没看懂,, 谢谢!.......... <P>假如是无法建立数学方程的曲线qline,和直线zline 相交呢?</P>
<P>vb还又没有办法?</P> <P>请问什么是无法建立数学方程的曲线?规则的曲线都有方程的吧?</P>
<P>如果曲线不规则,怎么知道它的趋势?怎么求交点?</P>
页:
[1]