标题:求画出点的运行轨迹
只看楼主
小小同学
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2019-7-4
结帖率:50%
已结贴  问题点数:20 回复次数:11 
求画出点的运行轨迹
Dim a, b, c, xo, yo, xa, ya, xb, yb, xsa, ysa, X, Y, n1, n2 As Double

Dim t1, t2
Dim m1, m2 As Single

Const pi = 3.1415926535
'????arctan2?????????????
Private Function arctan2(Y As Single, X As Single) As Single
   m = Atn(Y / X)
If X < 0 Then
   m = m + ??
ElseIf Y < 0 And X > 0 Then
   m = m + 2 * ??
Else
   m = Atn(Y / X)
End If
   arctan2 = m
End Function


Private Sub Command1_Click()

Timer1.Interval = 1
Timer1.Enabled = True


End Sub


Public Sub Form_Load()




t1 = 0 * pi / 180
a = 112
b = 336
c = -b * b / a



 
End Sub

Private Sub Command2_Click()


Timer1.Interval = 1

Timer1.Enabled = False




End Sub



Private Sub Form_Activate()


m = Picture1.Width / Picture1.Height
Picture1.Scale (-800 * m, 900)-(1000 * m, -900)


xo = 0
yo = 0
xa = xo + a * Cos(t1)
ya = yo + a * Sin(t1)
xb = xa + b * Cos(t2)
yb = yo
xsa = xa - c * Cos(pi + t2)
ysa = ya - c * Sin(pi + t2)


t2 = arctan2((a * Sin(t1)), (-Sqr(b * b - a * a * Sin(t1) * Sin(t1))))



Line1.X1 = xa
Line1.Y1 = ya
Line1.X2 = xb
Line1.Y2 = yb
Line4.X1 = xa
Line4.Y1 = ya
Line4.X2 = xsa
Line4.Y2 = ysa
Line5.X1 = xo
Line5.Y1 = yo
Line5.X2 = xa
Line5.Y2 = ya
Line2.X1 = -1400

Line2.Y1 = 0
Line2.X2 = 1400
Line2.Y2 = 0
Line3.X1 = 0
Line3.Y1 = -800
Line3.X2 = 0
Line3.Y2 = 800

Line6.X1 = 130
Line6.Y1 = -18
Line6.X2 = 550
Line6.Y2 = -18
Line7.X1 = -40
Line7.Y1 = -65
Line7.X2 = 40
Line7.Y2 = -65
Line8.X1 = 0
Line8.Y1 = 0
Line8.X2 = -40
Line8.X2 = -65
Line9.X1 = 0
Line9.Y1 = 0
Line9.X2 = 40
Line9.Y2 = -65
Shape5.Left = 340 - Shape5.Width / 2
Shape5.Top = -24
Shape1.Left = -Shape1.Width / 2
Shape1.Top = Shape1.Width / 2
Shape2.Left = xa - Shape2.Width / 2
Shape2.Top = ya + Shape2.Width / 2
Shape3.Left = xb - Shape3.Width / 2
Shape3.Top = Shape3.Width / 2
Shape4.Left = xb - Shape4.Width / 2
Shape4.Top = yb + Shape4.Height / 2
Shape6.Left = -Shape6.Width / 2
Shape6.Top = -65


  X = xa - c * Cos(pi - t2)
 
  Y = -(ya - c * Sin(t2))
  
 

  
  

If Option1.Value = True Then
  Picture1.PSet (X, m * Y), vbRed
End If

End Sub





Private Sub Timer1_Timer()
Timer1.Interval = 1
If m1 < 360 Then
m2 = 360 - m1
m1 = m1 + 1

Else
m1 = 0
End If
t1 = m2 * pi / 180

Call Form_Activate
End Sub


 请问大佬,X,Y点的轨迹怎么画出来

 X = xa - c * Cos(pi - t2)
 
  Y = -(ya - c * Sin(t2))
这个公式画出来不对
  
搜索更多相关主题的帖子: Sin If End Sub Left 
2019-07-04 11:59
小小同学
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2019-7-4
得分:0 
2019-07-04 12:08
wufuzhang
Rank: 9Rank: 9Rank: 9
来 自:广州
等 级:贵宾
威 望:21
帖 子:206
专家分:1346
注 册:2017-8-9
得分:0 
你把这个工程打包发出来,我看看。

不经历千百遍的调试,怎能体会成功时那一刹那的喜悦。
2019-07-04 12:34
小小同学
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2019-7-4
得分:0 
2019-07-04 12:52
小小同学
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2019-7-4
得分:0 
您好,刚刚那个问题我已经解决,但是还存在轨迹存在覆盖,不连续等问题。另外我还希望给点和滑块做一下填充,不知道用控件画出来的圆圈和滑块怎么填充
2019-07-04 12:54
wufuzhang
Rank: 9Rank: 9Rank: 9
来 自:广州
等 级:贵宾
威 望:21
帖 子:206
专家分:1346
注 册:2017-8-9
得分:0 
你怎么就给我一个.vbp文件,啥都看不了,其他窗体和模块文件呢?

不经历千百遍的调试,怎能体会成功时那一刹那的喜悦。
2019-07-04 18:22
小小同学
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2019-7-4
得分:0 
2019-07-04 22:57
小小同学
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2019-7-4
得分:0 
2019-07-04 22:57
小小同学
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2019-7-4
得分:0 
是这些吗
2019-07-04 22:58
RJQ
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2019-7-5
得分:0 
回复 2楼 小小同学
等待学习
2019-07-05 09:34



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-495685-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.209939 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved