Public
Class
Form2
Dim
alpha_z, alpha_y
As
Decimal
Dim
maus_x, maus_y
As
Integer
Private
Sub
frmTest_Paint(
ByVal
sender
As
Object
,
ByVal
e
As
System.Windows.Forms.PaintEventArgs)
Handles
MyBase
.Paint
If
RadioButton_2D.Checked
Then
Dim
p
As
New
Pen(Color.Blue, 2)
Dim
x, y
As
Integer
x =
Me
.Width / 2 + 115 * Math.Sin(Form1.phi)
y =
Me
.Height / 2 + 115 * Math.Cos(Form1.phi)
e.Graphics.DrawEllipse(Pens.Red, x - 10, y - 10, 20, 20)
e.Graphics.FillEllipse(Brushes.Red, x - 10, y - 10, 20, 20)
e.Graphics.DrawLine(p,
CInt
(
Me
.Width / 2),
CInt
(
Me
.Height / 2), x, y)
e.Graphics.DrawLine(Pens.Black, 212,
CInt
(
Me
.Height / 2),
Me
.Width - 212,
CInt
(
Me
.Height / 2))
With
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality
End
With
Button1.Visible =
False
Button2.Visible =
False
Button3.Visible =
False
Button4.Visible =
False
Label1.Visible =
False
End
If
If
RadioButton_3D.Checked
Then
Dim
b, t, h
As
Decimal
b = 6
t = 2
h = 15
Dim
x(7), y(7), z(7)
As
Decimal
y(1) = b
x(2) = t
y(2) = b
x(3) = t
z(4) = h
y(5) = b
z(5) = h
x(6) = t
y(6) = b
z(6) = h
x(7) = t
z(7) = h
Button1.Visible =
True
Button2.Visible =
True
Button3.Visible =
True
Button4.Visible =
True
Label1.Visible =
True
For
i = 0
To
7
z(i) = z(i) - 1.0 * h
y(i) = y(i) - 0.5 * b
Next
Dim
x0(7), y0(7), z0(7)
As
Decimal
For
i = 0
To
7
x0(i) = x(i)
y0(i) = y(i) * Math.Cos(Form1.phi) - z(i) * Math.Sin(Form1.phi)
z0(i) = y(i) * Math.Sin(Form1.phi) + z(i) * Math.Cos(Form1.phi)
Next
Dim
x1(7), y1(7), z1(7)
As
Decimal
For
i = 0
To
7
x1(i) = x0(i) * Math.Cos(alpha_z) - y0(i) * Math.Sin(alpha_z)
y1(i) = x0(i) * Math.Sin(alpha_z) + y0(i) * Math.Cos(alpha_z)
z1(i) = z0(i)
Next
Dim
x2(7), y2(7), z2(7)
As
Decimal
For
i = 0
To
7
x2(i) = x1(i) * Math.Cos(alpha_y) - z1(i) * Math.Sin(alpha_y)
z2(i) = x1(i) * Math.Sin(alpha_y) + z1(i) * Math.Cos(alpha_y)
y2(i) = y1(i)
Next
Dim
xb(7), yb(7)
As
Integer
For
i = 0
To
7
xb(i) =
Me
.Width / 2 + y2(i) * 20
yb(i) =
Me
.Height / 2 - z2(i) * 20
e.Graphics.DrawEllipse(Pens.Black, xb(i) - 4, yb(i) - 4, 8, 8)
Next
For
j = 0
To
1
For
i = 0
To
2
e.Graphics.DrawLine(Pens.Black, xb(i + j * 4), yb(i + j * 4), xb(i + 1 + j * 4), yb(i + 1 + j * 4))
Next
e.Graphics.DrawLine(Pens.Black, xb(3 + j * 4), yb(3 + j * 4), xb(0 + j * 4), yb(0 + j * 4))
Next
For
i = 0
To
3
e.Graphics.DrawLine(Pens.Black, xb(i), yb(i), xb(i + 4), yb(i + 4))
Next
If
x2(3) - x2(0) > 0
Then
Dim
quader()
As
Point =
{
New
Point(xb(2), yb(2)),
New
Point(xb(3), yb(3)),
New
Point(xb(7), yb(7)),
New
Point(xb(6), yb(6))}
With
e.Graphics
.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
End
With
e.Graphics.FillPolygon(Brushes.Red, quader)
End
If