Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Need Help with understanding line of code ( and what a certain placement of a comma means) Thanks VB.net and Mathmatica help ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122097] Need Help with understanding line of code ( and what a certain placement of a comma means) Thanks VB.net and Mathmatica help ?
  • From: Kane Avellano <avellano.kane at googlemail.com>
  • Date: Thu, 13 Oct 2011 03:49:09 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

Ok i was looking at the celestial Two-Body Problem  source code and
wanted it in Vb.net

http://demonstrations.wolfram.com/TheCelestialTwoBodyProblem/

\[CapitalTheta][\[Epsilon]_, R_, \[Alpha]_, t_] :=
 Mod[\[Alpha] + \[Pi] + (\[Pi] Tan[.5 (\[Epsilon] + .0001)^.284 (M[\
\[Epsilon], R, t] - \[Pi])])/Tan[.5 (\[Epsilon] + .0001)^.284 \[Pi]],
  2 \[Pi]]

and

M[\[Epsilon]_, R_, t_] :=
 Mod[8 \[Pi] t ((1 + \[Epsilon])/R)^(3/2) , 2 \[Pi]]

what does the 2 Pi do as when i put it in vb i didn't include the 2 pi
as i didn't what it was doing

my vb code is ...


Public Class test2
    Dim ee, r, a, angle, t, x1, y1, x2, y2, m As Decimal
    Private Function calcr(ByVal ee As Decimal, ByVal r As Decimal,
ByVal a As Decimal, ByVal angle As Decimal)
        Return ((1 - ee) * r) / (1 + ee * Cos(angle - a))
    End Function
    Private Function calcmass(ByVal ee As Decimal, ByVal r As Decimal,
ByVal t As Decimal)
        Return Abs(8 * PI * t * ((1 + ee) / r) ^ (3 / 2))
    End Function
    Private Function calcangle(ByVal ee As Decimal, ByVal r As
Decimal, ByVal a As Decimal, ByVal t As Decimal)
        Dim angleexample As Decimal

        angleexample = Abs(a + PI + ((PI * Tan((0.5 * (ee + 0.0001) ^
(0.284)) * calcmass(ee, r, t) - PI) _
                              / (Tan(0.5 * ((ee + 0.0001) ^ (0.284)) *
PI)))))
        Return Abs(a + PI + ((PI * Tan((0.5 * (ee + 0.0001) ^ (0.284))
* calcmass(ee, r, t) - PI) _
                                     / (Tan(0.5 * ((ee + 0.0001) ^
(0.284)) * PI)))))
    End Function
    Private Sub planetorbits(ByVal m, ByVal ee, ByVal r, ByVal a)


    End Sub
    Private Function x(ByVal ee, ByVal r, ByVal a, ByVal t)
        Return calcr(ee, r, a, calcangle(ee, r, a, t)) *
Cos(calcangle(ee, r, a, t))
    End Function
    Private Function y(ByVal ee, ByVal r, ByVal a, ByVal t)
        Return calcr(ee, r, a, calcangle(ee, r, a, t)) *
Sin(calcangle(ee, r, a, t))
    End Function

    Private Sub plotplanets()
        x1 = x(ee, r, a, t + (1 / 8) * (r / (1 + ee)) ^ (3 / 2))

        y1 = y(ee, r, a, t + 1 / 8 * (r / (1 + ee)) ^ (3 / 2))

        x2 = -m ^ -1 * x(ee, r, a, t + 1 / 8 * (r / (1 + ee)) ^ (3 /
2))


        PictureBox2.Location = New Point(x1, y1)
        PictureBox3.Location = New Point(x2, y2)


    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        m = 2
        ee = 0.5
        r = 10
        a = PI / 4
        t = 0
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
        t += 0.01
        plotplanets()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
        Timer1.Enabled = True
    End Sub

    Private Sub reset_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles reset.Click
        t = 0
        Timer1.Enabled = True
    End Sub
End Class


But when it runs, it follow the pattern for the first run but speeds
up each time until its going so fast it stops and reverses

got any ideas what the 2 pi does or is it like a limit to reset at 2
pi

Thanks

Kane A



  • Prev by Date: Constructing a huge graph
  • Next by Date: CUDA XCompiler
  • Previous by thread: Re: Constructing a huge graph
  • Next by thread: MLInitialize MLEnvironment