| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3325 人关注过本帖
标题:求画出点的运行轨迹
取消只看楼主 加入收藏
小小同学
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2019-7-4
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:7 
求画出点的运行轨迹
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
小小同学
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
小小同学
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
小小同学
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2019-7-4
收藏
得分:0 
哈哈哈,谢谢老师。确实是这样的,已解决。学习还是有很长的路啊
2019-07-06 10:33
快速回复:求画出点的运行轨迹
数据加载中...
 
   



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

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