太阳系行星轨道及运行
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
太阳系行星轨道及运行
动画演示
本程序对太阳系行星、卫星运行情况进行动画演示。具有以下功能:
1.可单独(或全部)显示或隐藏某个天体、运行轨道、天体名称。
2.可调节演示速度、画面比列、观察角度(从天球赤道到天球北极观察太阳系)。
3.可将某个天体(例如月亮)设置为屏幕中间静止不动的天体,观察其他天体相对于该天体运行的情况。
本程序改进版见:太阳系行星轨道及运行-3D立体动画演示
通过设置不同的参数,可得到许多美丽而奇妙的图案,如下:
'需在窗体放置以下3 个控件,所有控件均采用默认设置:
' Picture1,Command1,Timer1
' 注意:在属性窗口将Command1 的Index 属性设置为0
'其次,为窗体添加一个名为mFast 的菜单,再为mFast 添加一个名为mmFast 的下级子菜单,并将mmFast 的索引设置为0。
' 即:mmFast 是以序号0 开头的菜单数组控件的第一个。
'以下是窗体代码,在VB6.0 调试通过:
Dim ctD() As tyD, ctDs As Long, ctP As Single, ctCenter As Long
Dim ctBi As Single, ctV As Single, ctTrack As Boolean, ctBW As Long Dim ctSeeJ As Long, ctSeeBi As Single, ctSet As MenuSet
'定义表示天体的数据类型
Private Type tyD
Cap As String '天体名称
r As Long '天体半径(像素,下同)
a As Single '轨道:横半径
b As Single '轨道:纵半径
c As Single '轨道:焦点
e As Single '轨道:偏心率
IsHui As Boolean '是否彗星
Father As Long '父天体序号:轨道焦点上的天体Se As Long '颜色
V As Single '运行角速度
Jiao As Single '某时刻的与父天体连线角度
X As Single '天体当前坐标
Y As Single
xUp As Single '上一时刻坐标
yUp As Single
Visible As Boolean '是否显示:球体
ShowCap As Boolean '是否显示:标题
GuiDao As Boolean '是否显示:轨道
End Type
Enum MenuSet
'以下为选项菜单标示
ms_All = -2
ms_NoAll = -1
'以下为按钮标示
ms_RunStop = 0 '开始/暂停
ms_Step '步进,下一位置
ms_UnRun '后退
ms_Track '轨迹:显示/隐藏
ms_DefSet '默认设置
ms_Center '参照系
ms_Visible '天体:显示/隐藏
ms_ShowCap '天体名称
ms_GuiDao '轨道
ms_Bi '缩放比
ms_V '速度
ms_SeeJ '视角
End Enum
Private Sub Form_Load()
Me.ScaleMode = 3: Me.Caption = "太阳系行星运行演示"
mFast.Visible = False: ctP = 3.1415926
Timer1.Interval = 25: Timer1.Enabled = True
Call Init
'Me.WindowState = vbMaximized '最大化窗体
'窗体大小为屏幕的3/4,居中
Me.Move Screen.Width * 0.1, Screen.Height * 0.1, Screen.Width * 0.8, Screen.Height * 0.8
End Sub
Private Sub Form_Resize()
Dim I As Long, L As Single, T As Single, H As Single, H1 As Single, W As Single
'设置控件位置
H1 = Me.TextHeight("A"): L = H1 * 0.3: T = L
L = 3
For I = 0 To Command1.Count - 1
W = Me.TextWidth(Command1(I).Caption & "ab")
Command1(I).Move L, T, W, H1 * 2
L = L + W + 3
Next
T = T * 2 + Command1(0).Height: H = Me.ScaleHeight - T
If H > 0 Then Picture1.Move 0, T, Me.ScaleWidth, H
'将Picture1 的中心设置为坐标原点
Picture1.ScaleMode = 3
Picture1.ScaleLeft = -Picture1.ScaleWidth * 0.5
Picture1.ScaleTop = -Picture1.ScaleHeight * 0.5
Picture1.Cls
Call Run1
End Sub
Private Sub Init()
'初始化天体参数
Dim I As Long, V As Single, J As Single