1、本文档整理仅供上海理工大学计算机辅助设计课程作业参考和 VB 初学者学习(若只绕原点旋转 command4 函数下坐标变换只需要保存中间带三角函数的 8 个变幻赋值即可)经同学们反映,现改用 VB 编写,并附上前面板图,程序中包括完善容错,显得冗长,请同学们自行取舍By 飞云留客Private Sub Command1_Click()If Text1.Text = “ ThenLabel12.Caption = (“请输入坐标数值 x1“)ElseIf Not IsNumeric(Text1.Text) ThenLabel12.Caption = (“x1 输入的不是一个数字“)ElseIf
2、Val(Text1.Text) 50 Or Val(Text1.Text) 50 Or Val(Text2.Text) 50 Or Val(Text3.Text) 50 Or Val(Text4.Text) 50 Or Val(Text1.Text) 50 Or Val(Text2.Text) 50 Or Val(Text3.Text) 50 Or Val(Text4.Text) 50 Or Val(Text6.Text) 50 Or Val(Text7.Text) -50 ThenLabel12.Caption = (“y0 不在绘制范围“)Elsex1 = Text1.Texty1 = T
3、ext2.Textx2 = Text3.Texty2 = Text4.Texta1 = Text5.Texte = Text6.Textf = Text7.Textrota = a1 * 3.1415926 / 180x1 = x1 - ey1 = y1 - fx2 = x2 - ey2 = y2 - fx11 = x1 * Cos(rota) - y1 * Sin(rota)y11 = x1 * Sin(rota) + y1 * Cos(rota)x12 = x2 * Cos(rota) - y1 * Sin(rota)y12 = x2 * Sin(rota) + y1 * Cos(rota
4、)x22 = x2 * Cos(rota) - y2 * Sin(rota)y22 = x2 * Sin(rota) + y2 * Cos(rota)x21 = x1 * Cos(rota) - y2 * Sin(rota)y21 = x1 * Sin(rota) + y2 * Cos(rota)x11 = x11 + ey11 = y11 + fx12 = x12 + ey12 = y12 + fx22 = x22 + ey22 = y22 + fx21 = x21 + ey21 = y21 + fPicture1.Line (x11, y11)-(x12, y12)Picture1.Lin
5、e (x12, y12)-(x22, y22)Picture1.Line (x22, y22)-(x21, y21)Picture1.Line (x11, y11)-(x21, y21)End IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd IfEnd SubPrivate Sub Form_Load()Picture1.ScaleMode = 6Picture1.Height = 7000Picture1.Widt
6、h = 6000Picture1.Scale (-50, 50)-(50, -50)Picture1.Line (-50, 0)-(50, 0)Picture1.Line (0, 50)-(0, -50)Dim a As SingleDim a1 As SingleDim x1 As DoubleDim y1 As DoubleDim x2 As DoubleDim y2 As DoubleDim rota As DoubleDim x11 As DoubleDim y11 As DoubleDim x12 As DoubleDim y12 As DoubleDim x22 As DoubleDim y22 As DoubleDim x21 As DoubleDim y21 As DoubleDim e As DoubleDim f As DoubleEnd Sub