a) Don't email me directly. Keep it on list.
b) Use http://dotnetdevelopment.pastebin.com/ instead of shoving an
avalanche of code at us.

∞ Andy Badera
∞ +1 518-641-1280
∞ This email is: [ ] bloggable [x] ask first [ ] private
∞ Google me: http://www.google.com/search?q=andrew%20badera



On Sun, Oct 11, 2009 at 6:21 AM,  <[email protected]> wrote:
> Certinly I have been used Double data type for this calculation. The code
> inserted in below is the same
> story that I have been explained.
>
>
> Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button6.Click
>
> Dim xint, yint, zint As Double
> Dim ob, oc, ratio As Double
> Dim havint, intree As Boolean
> Dim x0, x1, x2, xb As Double
> Dim y0, y1, y2, yb As Double
> Dim z0, z1, z2, zb As Double
> '3 Points of plane formed triangle too.
> x0 = 2
> x1 = 2
> x2 = 2
> y0 = 0
> y1 = 2
> y2 = 2
> z0 = 2
> z1 = 2
> z2 = 0
> 'Points of line, other point is [0 0 0]
> xb = 1.5
> yb = 1
> zb = 0.5
> Line_PlaneIntersection(x0, x1, x2, xb, y0, y1, y2, yb, z0, z1, z2, _
> zb, xint, yint, zint, ob, oc, ratio, havint, intree)
> End Sub
>
>
> Public Shared Sub Line_PlaneIntersect(ByVal X0 As Double, ByVal X1 As
> Double, ByVal X2 As Double, _
> ByVal Xb As Double,ByVal Y0 As Double, ByVal Y1 As Double, _
> ByVal Y2 As Double,ByVal Yb As Double,ByVal Z0 As Double, _
> ByVal Z1 As Double, ByVal Z2 As Double, ByVal Zb As Double, _
> ByRef Xint As Double, ByRef Yint As Double, ByRef Zint As _
> Double, ByRef OB As Double, ByRef OC As Double, ByRef Ratio As _
> Double,ByRef HaveIntersect As Boolean, ByRef InTriangle As _
> Boolean)
>
>
> '***This formulation is based on the assumption that the line starts from
> origin***
> Dim t, u, v As Single
> Dim A, B, C, D As Double
> Dim A1, A2, A3 As Double
> Dim B1, B2, B3 As Double
> Dim C1, C2, C3 As Double
> Dim D1, D2, D3, D4, D5, D6 As Double
> Dim Det As Double
> Dim Det1, Det2, Det3, Det4, Det5, Det6 As Double
> Det1 = +Xb * ((Y2 - Y0) * (Z1 - Z0))
> Det2 = +Yb * ((X1 - X0) * (Z2 - Z0))
> Det3 = +Zb * ((X2 - X0) * (Y1 - Y0))
> Det4 = -Xb * ((Y1 - Y0) * (Z2 - Z0))
> Det5 = -Yb * ((X2 - X0) * (Z1 - Z0))
> Det6 = -Zb * ((X1 - X0) * (Y2 - Y0))
> Det = Det1 + Det2 + Det3 + Det4 + Det5 + Det6
> If Det <> 0 Then
> HaveIntersect = True
> A1 = X0 * ((Y1 - Y0) * (Z2 - Z0) - (Y2 - Y0) * (Z1 - Z0))
> A2 = Y0 * ((X2 - X0) * (Z1 - Z0) - (X1 - X0) * (Z2 - Z0))
> A3 = Z0 * ((X1 - X0) * (Y2 - Y0) - (X2 - X0) * (Y1 - Y0))
> A = A1 + A2 + A3
> B1 = X0 * ((Y2 - Y0) * Zb - (Z2 - Z0) * Yb)
> B2 = Y0 * ((Z2 - Z0) * Xb - (X2 - X0) * Zb)
> B3 = Z0 * ((X2 - X0) * Yb - (Y2 - Y0) * Xb)
> B = B1 + B2 + B3
> C1 = X0 * ((Z1 - Z0) * Yb - (Y1 - Y0) * Zb)
> C2 = Y0 * ((X1 - X0) * Zb - (Z1 - Z0) * Xb)
> C3 = Z0 * ((Y1 - Y0) * Xb - (X1 - X0) * Yb)
> C = C1 + C2 + C3
> D1 = +(X1 - X0) * (Y2 - Y0) * Zb
> D2 = +(X2 - X0) * (Z1 - Z0) * Yb
> D3 = +(Y1 - Y0) * (Z2 - Z0) * Xb
> D4 = -(X1 - X0) * (Z2 - Z0) * Yb
> D5 = -(X2 - X0) * (Y1 - Y0) * Zb
> D6 = -(Y2 - Y0) * (Z1 - Z0) * Xb
> D = D1 + D2 + D3 + D4 + D5 + D6
> t = A / D
> u = B / D
> v = C / D
> Xint = Xb * t
> Yint = Yb * t
> Zint = Zb * t
> Dim Bool1, Bool2 As Boolean
> Bool1 = u >= 0 And u <= 1
> Bool2 = v >= 0 And v <= 1
> If Bool1 And Bool2 And (u + v) <= 1 Then
> 'means that the intersection point lies in triangle wroughted from 3 points
> of the plane
> InTriangle = True
> OB = Math.Sqrt(Xb ^ 2 + Yb ^ 2 + Zb ^ 2)
> OC = Math.Sqrt(Xint ^ 2 + Yint ^ 2 + Zint ^ 2)
> Ratio = OB / OC
> End If
> Else
> HaveIntersect = False
> InTriangle = False
> End If
> End Sub
> '***************************************************************************************************
>
> %MAtlab syntax
> clear
> %Data of line's points
> xa=0; ya=0; za=0;
> xb=1.5; yb=1; zb=1/2;
> Ia=[xa
> ya
> za];
> Ib=[xb
> yb
> zb];
> %Data of plane
> x0=2; y0=0; z0=2;
> x1=2; y1=2; z1=2;
> x2=2; y2=2; z2=0;
> A= [xa-xb x1-x0 x2-x0
> ya-yb y1-y0 y2-y0
> za-zb z1-z0 z2-z0];
> B=[xa-x0
> ya-y0
> za-z0];
>
> C=A^-1*B
>
> Iint=Ia+(Ib-Ia).*C(1)
>
> after running
> Iint =
>
> 2.0000
> 1.3333
> 0.6667
>
> On Oct 11, 2009 2:43am, Andrew Badera <[email protected]> wrote:
>>
>>
>> Because the Schwarzenfunfer Constant approaches 1!
>>
>>
>>
>> How the heck should we know, if we don't know what your code, and thus
>>
>> your math, look like?
>>
>>
>>
>> And it probably doesn't matter, but you have "int" in all your
>>
>> variable names ... you're not really dealing with ints here, are you?
>>
>>
>>
>> ∞ Andy Badera
>>
>> ∞ +1 518-641-1280
>>
>> ∞ This email is: [ ] bloggable [x] ask first [ ] private
>>
>> ∞ Google me: http://www.google.com/search?q=andrew%20badera
>>
>>
>>
>>
>>
>>
>>
>> On Sun, Oct 11, 2009 at 4:03 AM, amirhosein najafi
>>
>> [email protected]> wrote:
>>
>> >
>>
>> > Hi All,
>>
>> > The problem discussed is accuracy of numeric calculation result,in vb.
>>
>> > Namely I compare a numerical mathematic calculation, Line-Plan
>>
>> > Intersection, in VB.Net and Matlab 2007 the intersection point result
>>
>> > specify in below:
>>
>> > Matlab 2007 ---->
>>
>> > Xint=2.000000000000000
>>
>> > Yint=1.333333333333333
>>
>> > Zint=0.666666666666667
>>
>> > But
>>
>> > Visual Studio 2008 ---->
>>
>> > Xint=2.0000000596046448
>>
>> > Yint=1.3333333730697632
>>
>> > Zint=0.66666668653488159
>>
>> > Hand Calculated ----->
>>
>> > Xint=2.000000000000000
>>
>> > Yint=1.333333333333333
>>
>> > Zint=0.666666666666667
>>
>> > why this error occurs?
>>
>> > Thanks.
>>
>> >
>>

Reply via email to