标题:什么都有了,就缺您了,元芳你怎么看???,,谢谢了
只看楼主
V菜鸟V
Rank: 2
等 级:论坛游民
帖 子:97
专家分:10
注 册:2014-11-27
结帖率:100%
已结贴  问题点数:20 回复次数:18 
什么都有了,就缺您了,元芳你怎么看???,,谢谢了
谢谢了,期望您的指导。附件中有1.机构运动视频2.机构视图分析3.机构简化图4.代码5.各部分运动计算6.自我分析
谢谢了,怎么运动起来那?什么都有了。(视频)(简化图)(代码),谢谢了,期望得到您的指导了,谢谢。
VB运动图.zip (3.92 MB)
搜索更多相关主题的帖子: 机构 机构 
2014-12-14 01:49
V菜鸟V
Rank: 2
等 级:论坛游民
帖 子:97
专家分:10
注 册:2014-11-27
得分:0 
机构界面(有问题)
2014-12-14 01:51
V菜鸟V
Rank: 2
等 级:论坛游民
帖 子:97
专家分:10
注 册:2014-11-27
得分:0 
具体机构图
2014-12-14 01:52
V菜鸟V
Rank: 2
等 级:论坛游民
帖 子:97
专家分:10
注 册:2014-11-27
得分:0 
机构简化图
2014-12-14 01:53
V菜鸟V
Rank: 2
等 级:论坛游民
帖 子:97
专家分:10
注 册:2014-11-27
得分:0 
这个附件里面什么都有的,前面那俩没视频的,谢谢了。
2014-12-14 02:02
xzlxzlxzl
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:湖北
等 级:贵宾
威 望:125
帖 子:1091
专家分:5825
注 册:2014-5-3
得分:0 
在Timer1_Timer事件里加一句k2=k2+1就动起来了,另你在子程序jigoujisuan的a至f的运算没起作用,简化后代码如下:(全部覆盖你原代码运行即可)
程序代码:
Option Explicit
Const PI = 3.14159
Dim xa(0 To 360) As Double
Dim ya(0 To 360) As Double
Dim xb(0 To 360) As Double
Dim yb(0 To 360) As Double
Dim xc(0 To 360) As Double
Dim yc(0 To 360) As Double
Dim afai1(0 To 360) As Double
Dim afai2(0 To 360) As Double
Dim afai3(0 To 360) As Double
Dim xd As Double
Dim yd As Double
Dim L1 As Double
Dim L2 As Double
Dim L3 As Double
Dim L4 As Double
Dim W As Integer
Dim a20 As Integer
Dim a2 As Integer


Public Sub readdate()
L1 = Val(Text1.Text)
L2 = Val(Text2.Text)
L3 = Val(Text3.Text)
L4 = Val(Text4.Text)
xd = Val(Text5.Text)
yd = Val(Text6.Text)
W = Val(Text7.Text)
a20 = Val(Text8.Text)

End Sub
Public Sub jigoujisuan()
Dim k1 As Integer
For k1 = 0 To 360
a2 = 2 * k1 * W + a20
xa(k1) = L1 * Cos(k1 * PI / 180)
ya(k1) = L1 * Sin(k1 * PI / 180)
xb(k1) = L1 * Cos(k1 * PI / 180) + L2 * Cos(a2)
xb(k1) = L1 * Sin(k1 * PI / 180) + L2 * Sin(a2)
Next k1
End Sub
Public Function arcsin(x) As Double
arcsin = Atn(x / Sqr(1 - x * x))
End Function
For k1 = 0 To 360
afai1(k1) = arcsin(e)
afai2(k1) = Atn(f)
afai3(k1) = afai1(k1) - afai2(k1)
Next k1

For k1 = 0 To 360
xc = xd + L4 * Cos(afai3(k1))

yc = yd + L4 * Sin(afai3(k1))
Next k1

Public Sub chushiweizhi()
Picture1.Scale (-72, 72)-(72, -72)
Picture1.Line (0, 0)-(xa(0), ya(0)), RGB(0, 0, 0)
Picture1.Line (xa(0), ya(0))-(xb(0), yb(0)), RGB(0, 0, 0)
Picture1.Line (xb(0), yb(0))-(xc(0), yc(0)), RGB(0, 0, 0)
Picture1.Line (xc(0), yc(0))-(xd, yd), RGB(0, 0, 0)
Picture1.Circle (0, 0), 1, RGB(0, 0, 0)
Picture1.Circle (xa(0), ya(0)), 2, RGB(0, 0, 0)
Picture1.Circle (xb(0), yb(0)), 5, RGB(0, 0, 0)
Picture1.Circle (xc(0), yc(0)), 5, RGB(0, 0, 0)
Picture1.Circle (xd, yd), 3, RGB(0, 0, 0)
Dim k4 As Integer
For k4 = 0 To 359
Picture1.Line (xb(k4), yb(k4))-(xb(k4 + 1), yb(k4 + 1)), RGB(0, 0, 0)
Next k4
End Sub
Private Sub Command1_Click()
Call readdate
Call jigoujisuan
Timer1.Enabled = False
Call chushiweizhi
End Sub

Private Sub Command2_Click()
Timer1.Enabled = True
Picture1.Cls
End Sub

Private Sub Timer1_Timer()
Picture1.Scale (-72, 72)-(72, -72)
Static k2 As Integer
Dim k3 As Integer

 If k2 = 0 Then
    k3 = 359

 Else
    k3 = k2 - 1

 End If
If k2 = 360 Then k2 = 0
Picture1.Line (0, 0)-(xa(k3), ya(k3)), Picture1.BackColor
Picture1.Line (xa(k3), ya(k3))-(xb(k3), yb(k3)), Picture1.BackColor
Picture1.Line (xb(k3), yb(k3))-(xc(k3), yc(k3)), Picture1.BackColor
Picture1.Line (xc(k3), yc(k3))-(xd, yd), Picture1.BackColor
Picture1.Circle (0, 0), 1, Picture1.BackColor
Picture1.Circle (xa(k3), ya(k3)), 2, Picture1.BackColor
Picture1.Circle (xb(k3), yb(k3)), 5, Picture1.BackColor
Picture1.Circle (xc(k3), yc(k3)), 10, Picture1.BackColor
Picture1.Circle (xd, yd), 3, Picture1.BackColor

Picture1.Line (0, 0)-(xa(k2), ya(k2)), RGB(0, 0, 0)
Picture1.Line (xa(k2), ya(k2))-(xb(k2), yb(k2)), RGB(0, 0, 0)
Picture1.Line (xb(k2), yb(k2))-(xc(0), yc(k2)), RGB(0, 0, 0)
Picture1.Line (xc(k2), yc(k2))-(xd, yd), RGB(0, 0, 0)
Picture1.Circle (0, 0), 1, RGB(0, 0, 0)
Picture1.Circle (xa(k2), ya(k2)), 2, RGB(0, 0, 0)
Picture1.Circle (xb(k2), yb(k2)), 5, RGB(0, 0, 0)
Picture1.Circle (xc(k2), yc(k2)), 5, RGB(0, 0, 0)
Picture1.Circle (xd, yd), 3, RGB(0, 0, 0)
k2 = k2 + 1
End Sub
2014-12-14 09:14
V菜鸟V
Rank: 2
等 级:论坛游民
帖 子:97
专家分:10
注 册:2014-11-27
得分:0 
回复 6楼 xzlxzlxzl
哈哈 ,不过说真的,它这真的动起来了,怎么动的那么抽象呀,谢谢了,关键不是我想要的运动规律呀,还有你看那个视频了没?我的最终目标是那个样子的运动的,你能帮忙想一下不?的确不能呀,a-f还是有用的因为他运动了的,只是可能有些地方没写好,,,,,
2014-12-14 13:54
lianyicq
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:26
帖 子:735
专家分:3478
注 册:2013-1-26
得分:9 
上次回复说让仔细看看控件的属性,可能被忽略了.最新的工程我没细看.上次就有两个问题你没解决:
1 图形控件的SCALE问题。仔细学一学,它不是万能的,如果连长宽比例都没有规划,随意画个控件大小。程序怎么能够如你所愿。
2 三角函数问题,度和弧度问题,自己试试,在缺省坐标系和自定义坐标系下,ATN在不同象限的值。如何符合你的要求。
先把这两个问题透彻了,再说其它的。
要想实现有意思的想法,写代码前,一定要有流程图。出了问题,逐个环节检查。


这是按你条件作出来的B点运动,其它约束条件你并没有透彻.
移栽机构.zip (2.58 KB)


[ 本帖最后由 lianyicq 于 2014-12-15 17:24 编辑 ]

大开眼界
2014-12-15 08:49
V菜鸟V
Rank: 2
等 级:论坛游民
帖 子:97
专家分:10
注 册:2014-11-27
得分:0 
回复 8楼 lianyicq
嗯呢,的确,我还带再看看,这差距也太大了,恩恩,谢了。哎,,,,
2014-12-15 20:17
xzlxzlxzl
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:湖北
等 级:贵宾
威 望:125
帖 子:1091
专家分:5825
注 册:2014-5-3
得分:11 
不懂机械,也不大会做三角函数运算,根据你给的视频给你模拟了一个,看能否有帮助。

VB运动图.rar (2.73 KB)


程序代码:
Private Type PointApi
  x As Double
  y As Double
End Type
Dim activeP As PointApi, slaveP As PointApi '主动点和从动点坐标
Dim noteScale As Double     '斜边节点比例
Dim Angle As Integer        '角度

Private Sub Drawl(oS As PointApi, oE As PointApi)
  Pic1.Line (oS.x, oS.y)-(oE.x, oE.y), vbBlack
  Pic1.Circle (oS.x, oS.y), 30, vbBlue
  Pic1.Circle (oE.x, oE.y), 30, vbBlue
End Sub

Private Sub Drawp(oA As PointApi, oS As PointApi, nS As Double, Ag As Integer)
  '根据输入参数画机械图,oA主动点坐标,oS从动点坐标,nS从动臂动点分割比例
  Const PI = 3.1415926
  Dim l As Double, l1 As Double, l2 As Double, l3 As Double, i As Integer
  Dim o1 As PointApi, o2 As PointApi, o3 As PointApi
  Pic1.Cls
  l1 = oS.x - oA.x
  l = Sqr(2 * l1 ^ 2)
  l2 = nS * l
  l3 = l - l2
  l1 = l1 * 0.5
  o1.x = oA.x + l1 * Cos(Ag * PI / 180)
  o1.y = oA.y - l1 * Sin(Ag * PI / 180)
  o2.x = o1.x + l1 * Cos((360 - Ag + 180) * PI / 180)
  o2.y = o1.y - l1 * Sin((360 - Ag + 180) * PI / 180)
  For i = 0 To -270 Step -1
    o3.x = oS.x + l2 * Cos(i * PI / 180)
    o3.y = oS.y - l2 * Sin(i * PI / 180)
    l = Sqr((o3.x - o2.x) ^ 2 + (o3.y - o2.y) ^ 2)
    If Abs(l - l3) < 15 Then Exit For
  Next
  Drawl o1, oA
  Drawl o1, o2
  Drawl o2, o3
  Drawl o3, oS
  o3.x = o2.x
  o3.y = o2.y + 450
  Pic1.Line (o3.x - 150, o3.y)-(o3.x + 150, o3.y + 300), vbRed, BF
  Drawl o3, o2
End Sub

Private Sub readCfg()
  '参数读取
  Dim l As Double
  activeP.x = Val(Text1) * 15
  activeP.y = Val(Text2) * 15
  slaveP.x = activeP.x + Val(Text3) * 15
  slaveP.y = activeP.y
  noteScale = Val(Text4)
  If noteScale > 0.5 Or noteScale < 0.15 Then noteScale = 0.3   '从动臂分割比例必须小于0.5大于0.15,否则转动会卡死
  Text4 = noteScale
End Sub

Private Sub Command1_Click()
  If Command1.Caption = "转动" Then
    Timer1.Interval = 10
    Timer1.Enabled = True
    Command1.Caption = "暂停"
  Else
    Timer1.Interval = 0
    Timer1.Enabled = False
    Command1.Caption = "转动"
  End If
End Sub

Private Sub Command2_Click()
  readCfg
  Drawp activeP, slaveP, noteScale, Angle
End Sub

Private Sub Form_Load()
  Command2_Click
  Angle = 270
  Drawp activeP, slaveP, noteScale, Angle
End Sub

Private Sub Timer1_Timer()
  Drawp activeP, slaveP, noteScale, Angle
  Angle = Angle + 1
  If Angle > 359 Then Angle = 0
End Sub
2014-12-15 21:22



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




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

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