求助vb编程
已知三角形ABC各顶点的坐标为A(3,5),B(0,3),C(2,4)。写出使三角形ABC以点(6,6)为中心顺时针旋转60°,再沿x方向以系数-2.5做错切后,并求出变...
已知三角形ABC各顶点的坐标为A(3,5),B(0,3),C(2,4)。写出使三角形ABC以点(6,6)为中心顺时针旋转60°,再沿x方向以系数-2.5做错切后,并求出变换后的三角形ABC的顶点坐标。
展开
展开全部
Private Type Point
x As Single
y As Single
End Type
Const PI As Single = 3.1415926
Private Function Rotate(Pold As Point, pCenter As Point, degree As Integer) As Point
Dim pNew As Point
Dim r As Single
Dim a As Single
r = Sqr((Pold.x - pCenter.x) ^ 2 + (Pold.y - pCenter.y) ^ 2) '算出旋转半径
a = Atn((Pold.y - pCenter.y) / (Pold.x - pCenter.x)) '算出初始角度
'根据中心坐标、半径和旋转后的角度确定旋转后的X,Y值
pNew.x = pCenter.x + r * Cos(a + degree * PI / 180)
pNew.y = pCenter.y + r * Sin(a + degree * PI / 180)
Rotate = pNew
End Function
Private Function Shear(Pold As Point, m As Single) As Point
Dim pNew As Point
pNew.x = Pold.x + Pold.y / m
pNew.y = Pold.y
Shear = pNew
End Function
Private Sub Form_Load()
Dim p1 As Point, p2 As Point, p3 As Point
Dim pCenter As Point
p1.x = 3
p1.y = 5
p2.x = 0
p2.y = 3
p3.x = 2
p3.y = 4
pCenter.x = 6
pCenter.y = 6
p1 = Shear(Rotate(p1, pCenter, 60), -2.5)
p2 = Shear(Rotate(p2, pCenter, 60), -2.5)
p3 = Shear(Rotate(p3, pCenter, 60), -2.5)
MsgBox "变换后的新坐标为:" & vbCrLf & "(" & p1.x & ", " & p1.y & ")" _
& vbCrLf & "(" & p2.x & ", " & p2.y & ")" _
& vbCrLf & "(" & p3.x & ", " & p3.y & ")"
End Sub
x As Single
y As Single
End Type
Const PI As Single = 3.1415926
Private Function Rotate(Pold As Point, pCenter As Point, degree As Integer) As Point
Dim pNew As Point
Dim r As Single
Dim a As Single
r = Sqr((Pold.x - pCenter.x) ^ 2 + (Pold.y - pCenter.y) ^ 2) '算出旋转半径
a = Atn((Pold.y - pCenter.y) / (Pold.x - pCenter.x)) '算出初始角度
'根据中心坐标、半径和旋转后的角度确定旋转后的X,Y值
pNew.x = pCenter.x + r * Cos(a + degree * PI / 180)
pNew.y = pCenter.y + r * Sin(a + degree * PI / 180)
Rotate = pNew
End Function
Private Function Shear(Pold As Point, m As Single) As Point
Dim pNew As Point
pNew.x = Pold.x + Pold.y / m
pNew.y = Pold.y
Shear = pNew
End Function
Private Sub Form_Load()
Dim p1 As Point, p2 As Point, p3 As Point
Dim pCenter As Point
p1.x = 3
p1.y = 5
p2.x = 0
p2.y = 3
p3.x = 2
p3.y = 4
pCenter.x = 6
pCenter.y = 6
p1 = Shear(Rotate(p1, pCenter, 60), -2.5)
p2 = Shear(Rotate(p2, pCenter, 60), -2.5)
p3 = Shear(Rotate(p3, pCenter, 60), -2.5)
MsgBox "变换后的新坐标为:" & vbCrLf & "(" & p1.x & ", " & p1.y & ")" _
& vbCrLf & "(" & p2.x & ", " & p2.y & ")" _
& vbCrLf & "(" & p3.x & ", " & p3.y & ")"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询