home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / orbit / planet.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-12-05  |  18.9 KB  |  634 lines

  1. VERSION 2.00
  2. Begin Form planet 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Orbit"
  6.    ClientHeight    =   5310
  7.    ClientLeft      =   540
  8.    ClientTop       =   1590
  9.    ClientWidth     =   8040
  10.    Height          =   6000
  11.    Icon            =   PLANET.FRX:0000
  12.    Left            =   480
  13.    LinkMode        =   1  'Source
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    ScaleHeight     =   120.819
  17.    ScaleMode       =   0  'User
  18.    ScaleWidth      =   113.559
  19.    Top             =   960
  20.    Width           =   8160
  21.    Begin TextBox Text7 
  22.       Height          =   375
  23.       Left            =   6120
  24.       TabIndex        =   10
  25.       Top             =   4800
  26.       Width           =   1815
  27.    End
  28.    Begin TextBox Text5 
  29.       Height          =   375
  30.       Left            =   6240
  31.       TabIndex        =   9
  32.       Top             =   4320
  33.       Width           =   1695
  34.    End
  35.    Begin SSPanel lookhere 
  36.       AutoSize        =   3  'AutoSize Child To Panel
  37.       BevelInner      =   1  'Inset
  38.       BevelWidth      =   2
  39.       ForeColor       =   &H00000000&
  40.       Height          =   855
  41.       Left            =   120
  42.       TabIndex        =   31
  43.       Top             =   4320
  44.       Width           =   4575
  45.       Begin PictureBox mark 
  46.          AutoRedraw      =   -1  'True
  47.          BackColor       =   &H00C0C0C0&
  48.          BorderStyle     =   0  'None
  49.          FontBold        =   -1  'True
  50.          FontItalic      =   0   'False
  51.          FontName        =   "Times New Roman"
  52.          FontSize        =   24
  53.          FontStrikethru  =   0   'False
  54.          FontUnderline   =   0   'False
  55.          ForeColor       =   &H00FF0000&
  56.          Height          =   645
  57.          Left            =   105
  58.          ScaleHeight     =   645
  59.          ScaleWidth      =   4365
  60.          TabIndex        =   32
  61.          Top             =   105
  62.          Width           =   4365
  63.       End
  64.    End
  65.    Begin TextBox Text6 
  66.       Height          =   375
  67.       Left            =   6480
  68.       TabIndex        =   8
  69.       Top             =   3840
  70.       Width           =   1455
  71.    End
  72.    Begin CheckBox seconds 
  73.       BackColor       =   &H00C0C0C0&
  74.       Caption         =   "Two Suns"
  75.       Height          =   255
  76.       Left            =   3000
  77.       TabIndex        =   12
  78.       Top             =   3840
  79.       Width           =   1215
  80.    End
  81.    Begin CheckBox datarec 
  82.       BackColor       =   &H00C0C0C0&
  83.       Caption         =   "Record Data"
  84.       Enabled         =   0   'False
  85.       Height          =   255
  86.       Left            =   3000
  87.       TabIndex        =   13
  88.       Top             =   3480
  89.       Width           =   1455
  90.    End
  91.    Begin TextBox Text12 
  92.       Height          =   375
  93.       Left            =   5760
  94.       TabIndex        =   7
  95.       Top             =   3360
  96.       Width           =   2175
  97.    End
  98.    Begin Frame Frame1 
  99.       BackColor       =   &H00C0C0C0&
  100.       Caption         =   "Bodies"
  101.       Height          =   855
  102.       Left            =   120
  103.       TabIndex        =   29
  104.       Top             =   3360
  105.       Width           =   2535
  106.       Begin PictureBox suns 
  107.          AutoSize        =   -1  'True
  108.          DragIcon        =   PLANET.FRX:0302
  109.          Height          =   510
  110.          Left            =   1920
  111.          Picture         =   PLANET.FRX:0604
  112.          ScaleHeight     =   480
  113.          ScaleWidth      =   480
  114.          TabIndex        =   33
  115.          Top             =   240
  116.          Width           =   510
  117.       End
  118.       Begin PictureBox Picture3 
  119.          AutoSize        =   -1  'True
  120.          DragIcon        =   PLANET.FRX:0906
  121.          Height          =   510
  122.          Left            =   1320
  123.          Picture         =   PLANET.FRX:0C08
  124.          ScaleHeight     =   480
  125.          ScaleWidth      =   480
  126.          TabIndex        =   30
  127.          Top             =   240
  128.          Width           =   510
  129.       End
  130.       Begin PictureBox Picture2 
  131.          AutoSize        =   -1  'True
  132.          DragIcon        =   PLANET.FRX:0F0A
  133.          Height          =   510
  134.          Left            =   720
  135.          Picture         =   PLANET.FRX:120C
  136.          ScaleHeight     =   480
  137.          ScaleWidth      =   480
  138.          TabIndex        =   11
  139.          Top             =   240
  140.          Width           =   510
  141.       End
  142.       Begin PictureBox Picture1 
  143.          AutoSize        =   -1  'True
  144.          DragIcon        =   PLANET.FRX:150E
  145.          Height          =   510
  146.          Left            =   120
  147.          Picture         =   PLANET.FRX:1810
  148.          ScaleHeight     =   480
  149.          ScaleWidth      =   480
  150.          TabIndex        =   1
  151.          Top             =   240
  152.          Width           =   510
  153.       End
  154.    End
  155.    Begin SSCommand SSCommand2 
  156.       AutoSize        =   2  'Adjust Button Size To Picture
  157.       Caption         =   "Clear"
  158.       Font3D          =   3  'Inset w/light shading
  159.       ForeColor       =   &H00000000&
  160.       Height          =   255
  161.       Left            =   3720
  162.       TabIndex        =   16
  163.       Top             =   3000
  164.       Width           =   1095
  165.    End
  166.    Begin TextBox Text11 
  167.       Height          =   375
  168.       Left            =   5760
  169.       TabIndex        =   6
  170.       Top             =   2880
  171.       Width           =   2175
  172.    End
  173.    Begin TextBox Text16 
  174.       Height          =   375
  175.       Left            =   3720
  176.       TabIndex        =   14
  177.       Top             =   2520
  178.       Width           =   1095
  179.    End
  180.    Begin TextBox Text4 
  181.       Height          =   375
  182.       Left            =   5760
  183.       TabIndex        =   5
  184.       Top             =   2400
  185.       Width           =   2175
  186.    End
  187.    Begin TextBox Text3 
  188.       Height          =   375
  189.       Left            =   5760
  190.       TabIndex        =   4
  191.       Top             =   1920
  192.       Width           =   2175
  193.    End
  194.    Begin TextBox Text10 
  195.       Height          =   375
  196.       Left            =   3720
  197.       TabIndex        =   15
  198.       Top             =   1800
  199.       Width           =   1095
  200.    End
  201.    Begin TextBox Text2 
  202.       Height          =   375
  203.       Left            =   6360
  204.       TabIndex        =   3
  205.       Top             =   1440
  206.       Width           =   1575
  207.    End
  208.    Begin TextBox Text1 
  209.       Height          =   375
  210.       Left            =   6120
  211.       TabIndex        =   2
  212.       Top             =   960
  213.       Width           =   1815
  214.    End
  215.    Begin SSPanel SSPanel2 
  216.       AutoSize        =   3  'AutoSize Child To Panel
  217.       BevelWidth      =   2
  218.       BorderWidth     =   2
  219.       ForeColor       =   &H00000000&
  220.       Height          =   630
  221.       Left            =   5880
  222.       TabIndex        =   36
  223.       Top             =   240
  224.       Width           =   630
  225.       Begin SSCommand SSCommand1 
  226.          AutoSize        =   2  'Adjust Button Size To Picture
  227.          Font3D          =   3  'Inset w/light shading
  228.          ForeColor       =   &H00000000&
  229.          Height          =   570
  230.          Left            =   30
  231.          Picture         =   PLANET.FRX:1B12
  232.          TabIndex        =   37
  233.          Top             =   30
  234.          Width           =   570
  235.       End
  236.    End
  237.    Begin SSPanel SSPanel3 
  238.       AutoSize        =   3  'AutoSize Child To Panel
  239.       BevelWidth      =   2
  240.       BorderWidth     =   2
  241.       ForeColor       =   &H00000000&
  242.       Height          =   630
  243.       Left            =   5040
  244.       TabIndex        =   38
  245.       Top             =   240
  246.       Width           =   630
  247.       Begin SSCommand Stopg 
  248.          AutoSize        =   2  'Adjust Button Size To Picture
  249.          Font3D          =   3  'Inset w/light shading
  250.          ForeColor       =   &H00000000&
  251.          Height          =   570
  252.          Left            =   30
  253.          Picture         =   PLANET.FRX:1E14
  254.          TabIndex        =   39
  255.          Top             =   30
  256.          Width           =   570
  257.       End
  258.    End
  259.    Begin SSPanel SSPanel1 
  260.       AutoSize        =   3  'AutoSize Child To Panel
  261.       BevelInner      =   1  'Inset
  262.       BevelWidth      =   2
  263.       ForeColor       =   &H00000000&
  264.       Height          =   735
  265.       Left            =   6840
  266.       TabIndex        =   34
  267.       Top             =   120
  268.       Width           =   735
  269.       Begin PictureBox Picture4 
  270.          Height          =   525
  271.          Left            =   105
  272.          Picture         =   PLANET.FRX:2116
  273.          ScaleHeight     =   495
  274.          ScaleWidth      =   495
  275.          TabIndex        =   35
  276.          Top             =   105
  277.          Width           =   525
  278.       End
  279.    End
  280.    Begin SSCommand graphset 
  281.       Caption         =   "Graph Set"
  282.       Font3D          =   3  'Inset w/light shading
  283.       ForeColor       =   &H00000000&
  284.       Height          =   930
  285.       Left            =   3720
  286.       Picture         =   PLANET.FRX:2418
  287.       TabIndex        =   0
  288.       Top             =   120
  289.       Width           =   1050
  290.    End
  291.    Begin PictureBox graph 
  292.       AutoRedraw      =   -1  'True
  293.       Height          =   3135
  294.       Left            =   120
  295.       ScaleHeight     =   100
  296.       ScaleMode       =   0  'User
  297.       ScaleWidth      =   100
  298.       TabIndex        =   24
  299.       Top             =   120
  300.       Width           =   3495
  301.    End
  302.    Begin Label Label7 
  303.       AutoSize        =   -1  'True
  304.       BackColor       =   &H00C0C0C0&
  305.       Caption         =   "Time Interval"
  306.       Height          =   195
  307.       Left            =   4920
  308.       TabIndex        =   23
  309.       Top             =   4800
  310.       Width           =   1125
  311.    End
  312.    Begin Label Label5 
  313.       AutoSize        =   -1  'True
  314.       BackColor       =   &H00C0C0C0&
  315.       Caption         =   "Planet's Angle"
  316.       Height          =   195
  317.       Left            =   4920
  318.       TabIndex        =   21
  319.       Top             =   4320
  320.       Width           =   1230
  321.    End
  322.    Begin Label Label6 
  323.       AutoSize        =   -1  'True
  324.       BackColor       =   &H00C0C0C0&
  325.       Caption         =   "Planet's Velocity"
  326.       Height          =   195
  327.       Left            =   4920
  328.       TabIndex        =   22
  329.       Top             =   3840
  330.       Width           =   1425
  331.    End
  332.    Begin Label Label9 
  333.       AutoSize        =   -1  'True
  334.       BackColor       =   &H00C0C0C0&
  335.       Caption         =   "Sun's Y"
  336.       Height          =   195
  337.       Left            =   4920
  338.       TabIndex        =   26
  339.       Top             =   3360
  340.       Width           =   660
  341.    End
  342.    Begin Label Label8 
  343.       AutoSize        =   -1  'True
  344.       BackColor       =   &H00C0C0C0&
  345.       Caption         =   "Sun's X"
  346.       Height          =   195
  347.       Left            =   4920
  348.       TabIndex        =   25
  349.       Top             =   2880
  350.       Width           =   660
  351.    End
  352.    Begin Label Label4 
  353.       AutoSize        =   -1  'True
  354.       BackColor       =   &H00C0C0C0&
  355.       Caption         =   "Planet Y"
  356.       Height          =   195
  357.       Left            =   4920
  358.       TabIndex        =   20
  359.       Top             =   2400
  360.       Width           =   735
  361.    End
  362.    Begin Label Label13 
  363.       AutoSize        =   -1  'True
  364.       BackColor       =   &H00C0C0C0&
  365.       Caption         =   "Graph Y"
  366.       Height          =   195
  367.       Left            =   3720
  368.       TabIndex        =   27
  369.       Top             =   2280
  370.       Width           =   705
  371.    End
  372.    Begin Label Label3 
  373.       AutoSize        =   -1  'True
  374.       BackColor       =   &H00C0C0C0&
  375.       Caption         =   "Planet X"
  376.       Height          =   195
  377.       Left            =   4920
  378.       TabIndex        =   19
  379.       Top             =   1920
  380.       Width           =   735
  381.    End
  382.    Begin Label Label14 
  383.       AutoSize        =   -1  'True
  384.       BackColor       =   &H00C0C0C0&
  385.       Caption         =   "Graph X"
  386.       Height          =   195
  387.       Left            =   3720
  388.       TabIndex        =   28
  389.       Top             =   1560
  390.       Width           =   705
  391.    End
  392.    Begin Label Label2 
  393.       AutoSize        =   -1  'True
  394.       BackColor       =   &H00C0C0C0&
  395.       Caption         =   "Mass of Planet"
  396.       Height          =   195
  397.       Left            =   4920
  398.       TabIndex        =   18
  399.       Top             =   1440
  400.       Width           =   1275
  401.    End
  402.    Begin Label Label1 
  403.       AutoSize        =   -1  'True
  404.       BackColor       =   &H00C0C0C0&
  405.       Caption         =   "Mass of Sun"
  406.       Height          =   195
  407.       Left            =   4920
  408.       TabIndex        =   17
  409.       Top             =   960
  410.       Width           =   1065
  411.    End
  412.    Begin Menu file 
  413.       Caption         =   "&File"
  414.       Begin Menu about 
  415.          Caption         =   "&About"
  416.       End
  417.       Begin Menu done 
  418.          Caption         =   "&Exit"
  419.       End
  420.    End
  421.    Begin Menu dat1 
  422.       Caption         =   "&Data"
  423.       Begin Menu rate 
  424.          Caption         =   "Sample &Rate"
  425.       End
  426.       Begin Menu dat 
  427.          Caption         =   "&Show"
  428.       End
  429.    End
  430. Const pi = 3.14159265359
  431. Const g = 6.67E-11!
  432. Dim init As Single
  433. Dim dragitem  As String
  434. Dim tim As Single
  435. Dim n As Integer
  436. Dim msg As String
  437. Dim timepast As Single
  438. Dim xol As Double
  439. Dim yol As Double
  440. Dim com As Single
  441. Sub about_Click ()
  442.     orbita.Show
  443. End Sub
  444. Sub dat_Click ()
  445. datas.Show
  446. End Sub
  447. Sub datarec_Click ()
  448.     If datarec.value = 1 Then
  449.         Load datas
  450.         rate_click
  451.     End If
  452.     Beep
  453. End Sub
  454. Sub done_Click ()
  455.     msg = "Thank You!"
  456.     mark_c
  457.     End
  458. End Sub
  459. Sub Form_Load ()
  460.     msg = "Welcome to ORBIT!!"
  461.     samplerate = 1
  462. End Sub
  463. Sub graph_DragDrop (Source As Control, X As Single, Y As Single)
  464.     graph.PSet (X, Y)
  465.     Select Case dragitem
  466.     Case Is = "sun"
  467.         text11.text = Format$(X)
  468.         text12.text = Format$(Y)
  469.     Case Is = "planet"
  470.         text3.text = Format$(X)
  471.         text4.text = Format$(Y)
  472.     Case Is = "vortex"
  473.         text11.text = Format$(X)
  474.         text12.text = Format$(Y)
  475.         text1.text = Str$(-1)
  476.     Case Is = "sun2"
  477.         sons.Show
  478.         sons.sun2xs.text = Str$(X)
  479.         sons.sun2ys.text = Str$(Y)
  480. End Select
  481.         
  482. End Sub
  483. Sub graph_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  484.     text10.text = Format$(X)
  485.     text16.text = Format$(Y)
  486. End Sub
  487. Sub graph_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  488.     text10.text = Str$(X)
  489.     text16.text = Str$(Y)
  490. End Sub
  491. Sub graphset_Click ()
  492.     initgraph.Show
  493. End Sub
  494. Function gravx (xol As Double) As Single
  495.     gravx = (-1) * g * (xol - sun2x) * sun2 * com / ((sun2x - xol) ^ 2 + (sun2y - yol) ^ 2) ^ (3 / 2)
  496. End Function
  497. Function gravy (yol As Double) As Single
  498.     gravy = (-1) * g * sun2 * com * (yol - sun2y) / ((sun2x - xol) ^ 2 + (sun2y - yol) ^ 2) ^ (3 / 2)
  499. End Function
  500. Sub mark_c ()
  501. marquee$ = msg
  502. thewidth = mark.TextWidth(marquee$)
  503. Do While mark.TextWidth(marquee$) < mark.scalewidth + thewidth
  504.     marquee$ = marquee$ + " "
  505. For X& = 1 To Len(marquee$)
  506.         a$ = Mid$(marquee$, 1, X&)
  507.         mark.currentx = mark.scalewidth - mark.TextWidth(a$)
  508.         mark.Print a$;
  509.         q = DoEvents()
  510.         mark.Cls
  511. End Sub
  512. Sub Picture1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  513.     picture1.Drag 1
  514.     dragitem = "sun"
  515. End Sub
  516. Sub Picture1_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  517.     picture1.Drag 2
  518. End Sub
  519. Sub Picture2_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  520.     picture2.Drag 1
  521.     dragitem = "planet"
  522. End Sub
  523. Sub Picture2_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  524.     picture2.Drag 2
  525. End Sub
  526. Sub Picture3_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  527.     picture3.Drag 1
  528.     dragitem = "vortex"
  529. End Sub
  530. Sub Picture3_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  531.     picture3.Drag 3
  532. End Sub
  533. Sub rate_click ()
  534.     datarate.Show 1
  535. End Sub
  536. Sub SSCommand1_Click ()
  537.     On Error GoTo a:
  538.     sun = Val(text1.text)
  539.     com = Val(text2.text)
  540.     xol = Val(text3.text)
  541.     yol = Val(text4.text)
  542.     coma = Val(text5.text)
  543.     comv = Val(text6.text)
  544.     timi = Val(text7.text)
  545.     suny = Val(text12.text)
  546.     sunx = Val(text11.text)
  547.     xvo = -comv * (Cos((coma * pi) / 180))
  548.     yvo = comv * (Sin((coma * pi) / 180))
  549.     msg = "Nice Orbit!"
  550.     graph.PSet (sunx, suny)
  551.     If seconds.value = 1 Then
  552.         graph.PSet (sun2x, sun2y)
  553.     End If
  554.     If datarec.value = 1 Then datas.points.row = 0
  555.     n = 0
  556.     timepast = 0
  557.     ptg = ((1 / timi) / samplerate)
  558.     p = 0
  559.     Do
  560.     timepast = timepast + timi
  561.     graph.PSet (xol, yol)
  562.     gxo = (-1) * g * (xol - sunx) * sun * com / ((sunx - xol) ^ 2 + (suny - yol) ^ 2) ^ (3 / 2)
  563.     gyo = (-1) * g * sun * com * (yol - suny) / ((sunx - xol) ^ 2 + (suny - yol) ^ 2) ^ (3 / 2)
  564.     If seconds.value = 1 Then
  565.         gxo = gxo + gravx(xol)
  566.         gyo = gyo + gravy(yol)
  567.     End If
  568.     xvn = xvo + gxo * timi
  569.     yvn = yvo + gyo * timi
  570.     xnl = xol + timi * (xvo + xvn) / 2
  571.     ynl = yol + timi * (yvo + yvn) / 2
  572.     If (datarec.value = 1) And p = ptg Then
  573.         datas.points.col = 0
  574.         datas.points.text = Format$(timepast, "0.00#")
  575.         datas.points.col = 1
  576.         datas.points.text = Format$(xol, "0.00#")
  577.         datas.points.col = 2
  578.         datas.points.text = Format$(yol, "0.00#")
  579.         datas.points.col = 3
  580.         datas.points.text = Format$(xvo, "0.00#")
  581.         datas.points.col = 4
  582.         datas.points.text = Format$(yvo, "0.00#")
  583.         datas.points.col = 5
  584.         datas.points.text = Format$(gxo, "0.00#")
  585.         datas.points.col = 6
  586.         datas.points.text = Format$(gyo, "0.00#")
  587.         datas.points.row = datas.points.row + 1
  588.         p = 0
  589.     End If
  590.     xol = xnl
  591.     yol = ynl
  592.     xvo = xvn
  593.     yvo = yvn
  594.     other% = DoEvents()
  595.     p = p + 1
  596.     Loop Until n = 1
  597. mark_c
  598. Exit Sub
  599. saveErr% = Err
  600. generalerrors
  601. Exit Sub
  602. End Sub
  603. Sub SSCommand2_Click ()
  604.     graph.Cls
  605.     If gridison Then
  606.         griddraw "x", gridx, 1
  607.         griddraw "y", gridy, 1
  608.     End If
  609. End Sub
  610. Sub Stopg_Click ()
  611.     n = 1
  612.     msg = "Graph Stopped"
  613. End Sub
  614. Sub suns_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  615.     If seconds.value = 1 Then
  616.         picture1.Drag 1
  617.         dragitem = "sun2"
  618.     End If
  619. End Sub
  620. Sub suns_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  621.     If seconds.value = 1 Then
  622.         picture1.Drag 2
  623.     End If
  624. End Sub
  625. Sub Text1_Change ()
  626.     sun = Val(text1.text)
  627. End Sub
  628. Sub Text2_Change ()
  629.     com = Val(text2.text)
  630. End Sub
  631. Sub Text7_Change ()
  632. If text7.text = "" Then datarec.enabled = 0 Else datarec.enabled = -1
  633. End Sub
  634.