End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim j As Double
Select Case KeyCode
Case 39 '右
j = 1 / 180 * 3.1415926
rote_y j
Case 37 '左
j = -1 / 180 * 3.1415926
rote_y j
Case 40 '下
j = -1 / 180 * 3.1415926
rote_x j
Case 38 '上
j = 1 / 180 * 3.1415926
rote_x j
End Select
Draw_3D
End Sub
Private Sub rote_y(j As Double)
'x=x*cosa+z*sina,y=y,z=-x*sina+z*cosa
Dim i As Integer
For i = 0 To 7
P_3D(i).x = P_3D(i).x * Cos(j) + P_3D(i).z * Sin(j)
P_3D(i).z = -P_3D(i).x * Sin(j) + P_3D(i).z * Cos(j)
Next
End Sub
Private Sub rote_x(j As Double)
'x=x,y=y*cosa-z*sina,z=y*sina+z*cosa
Dim i As Integer
For i = 0 To 7
P_3D(i).y = P_3D(i).y * Cos(j) - P_3D(i).z * Sin(j)
P_3D(i).z = P_3D(i).y * Sin(j) + P_3D(i).z * Cos(j)
Next
End Sub
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim j As Double
Select Case KeyCode
Case 39 '右
j = 1 / 180 * 3.1415926
rote_y j
Case 37 '左
j = -1 / 180 * 3.1415926
rote_y j
Case 40 '下
j = -1 / 180 * 3.1415926
rote_x j
Case 38 '上
j = 1 / 180 * 3.1415926
rote_x j
End Select
Draw_3D
End Sub
Private Sub rote_y(j As Double)
'x=x*cosa+z*sina,y=y,z=-x*sina+z*cosa
Dim i As Integer
For i = 0 To 7
P_3D(i).x = P_3D(i).x * Cos(j) + P_3D(i).z * Sin(j)
P_3D(i).z = -P_3D(i).x * Sin(j) + P_3D(i).z * Cos(j)
Next
End Sub
Private Sub rote_x(j As Double)
'x=x,y=y*cosa-z*sina,z=y*sina+z*cosa
Dim i As Integer
For i = 0 To 7
P_3D(i).y = P_3D(i).y * Cos(j) - P_3D(i).z * Sin(j)
P_3D(i).z = P_3D(i).y * Sin(j) + P_3D(i).z * Cos(j)
Next
End Sub