vb.net绘制三角形 vb中怎么做出三角形数字塔

vb.net画图控件如何画三角网图形?Imports System.Drawing
Imports System.Drawing.Drawing2D
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim g As Graphics = PictureBox1.CreateGraphics
Dim hs As HatchStyle = HatchStyle.Cross
Dim sb As HatchBrush = New HatchBrush(hs, Color.Black, Color.White)
Dim p(3) As Point
p(0).X = 100
p(0).Y = 50
p(1).X = 0
p(1).Y = 100
p(2).X = 200
p(2).Y = 100
p(3).X = 100
p(3).Y = 50
g.FillPolygon(sb, p)
g.DrawPolygon(Pens.Black, p)
End Sub
End Class
vb画三角形Private Sub Form_Click()
Dim a, b, c, temp As Integer
a = Val(InputBox("a"))
temp = a
b = Val(InputBox("b"))
If ba Then
a = b
b = temp
End If
c = Val(InputBox("c"))
If ca Then
temp = a
a = c
c = temp
End If
If c + b = a Then '判断是不是三角形
Print "不是三角形"
Exit Sub
End If
If a = b And b = c Then
Print "等边三角形"
ElseIf (a = b And bc) Or (a = c And ab) Then
Print "等腰三角形"
ElseIf ab And bc And ac Then
Print "一般三角形"
End If
End Sub
在vb中 。如何进行三角函数的程序代码编写有几个地方要注意:
1、VB中的三角函数的角度全部是用弧度制表示的 , 如果是度数的话,应先乘以180再除以π转成弧度,再用函数计算结果 。
2、VB中直接支持的三角函数有:Sin()、Cos()、Tan() , 如果涉及到其它三角函数,可以从下面列出的代码中自己选择相应的函数:
Function
Sec(X)
As
Double
'正割
Sec
=
1
/
Cos(Angle)
End
Function
Function
Csc(X)
As
Double
'余割
Csc
=
1
/
Sin(Angle)
End
Function
Function
Cot(X)
As
Double
'余切
Cot
=
1
/
Tan(Angle)
End
Function
Function
ArcSin(X)
As
Double
'反正弦
ArcSin
=
Atn(X
/
Sqr(-X
*
X
+
1))
End
Function
Function
ArcCos(X)
As
Double
'反余弦
ArcCos
=
Atn(-X
/
Sqr(-X
*
X
+
1))
+
2
*
Atn(1)
End
Function
Function
ArcSec(X)
As
Double
'反正割
ArcSec
=
Atn(X
/
Sqr(X
*
X
-
1))
+
Sgn((X)
-
1)
*
(2
*
Atn(1))
End
Function
Function
ArcCsc(X)
As
Double
'反余割
ArcCsc
=
Atn(X
/
Sqr(X
*
X
-
1))
+
(Sgn(X)
-
1)
*
(2
*
Atn(1))
End
Function
Function
ArcCot(X)
As
Double
'反余切
ArcCot
=
Atn(X)
+
2
*
Atn(1)
End
Function
Function
HSin(X)
As
Double
'双曲正弦
HSin
=
(Exp(X)
-
Exp(-X))
/
2
End
Function
Function
HCos(X)
As
Double
'双曲余弦
HCos
=
(Exp(X)
+
Exp(-X))
/
2
End
Function
Function
HTan(X)
As
Double
'双曲正切
HTan
=
(Exp(X)
-
Exp(-X))
/
(Exp(X)
+
Exp(-X))
End
Function
Function
HSec(X)
As
Double
'双曲正割

推荐阅读