using System using System Collections Generic using System ComponentMo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace rotateTriangle
{
public partial class Form1 : Form
{
static double angle = 5 * Math.PI / 180;
//Matrix b = new Matrix(0, 1, -1, 0, 0, 0);
Matrix b = new Matrix((float)Math.Cos(angle), (float)Math.Sin(angle), -(float)Math.Sin(angle), (float)Math.Cos(angle),0, 0);
Point[] square = new Point[4] { new Point(500, 500), new Point(550, 500), new Point(550, 550), new Point(500, 550) };
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics test = e.Graphics;
test.DrawLine(new Pen(Color.Black), square[0], square[1]);
test.DrawLine(new Pen(Color.Black), square[1], square[2]);
test.DrawLine(new Pen(Color.Black), square[2], square[3]);
test.DrawLine(new Pen(Color.Black), square[3], square[0]);
}
private void timer1_Tick(object sender, EventArgs e)
{
Invalidate();
b.TransformPoints(square);
}
}
}