Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- namespace _777
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Clear_Click(object sender, EventArgs e)
- {
- Graphics clear = Graphics.FromHwnd(Picture.Handle);
- clear.Clear(BackColor);
- listBox.Items.Clear();
- }
- class Quadr //класс ЧЕТЫРЕХУГОЛЬНИК
- {
- public Point A, B, C, D;
- public Quadr(Point A, Point B, Point C, Point D) //конструктор с параметрами
- {
- this.A = A; this.B = B; this.C = C; this.D = D;
- }
- public float St(Point X, Point Y) //метод для вычисления сторон четырехугольника
- {
- float st = (float)Math.Sqrt(Math.Pow(Y.X - X.X, 2) + Math.Pow(Y.Y - X.Y, 2));
- return st;
- }
- public bool Proverka(Point X, Point Y, Point Z) //метод для проверки существования четырехугольника
- {
- float neparX = ((Z.X - X.X) / (Y.X - X.X)); //четырехугольник существует, если три любые точки не лежат на одной прямой
- float neparY = ((Z.Y - X.Y) / (Y.Y - X.Y));
- float[] arr = { St(A, B), St(B, C), St(C, D), St(A, D) };
- float max = arr[0];
- for (int i = 1; i < arr.Length; i++)
- {
- if (arr[i] > max) max = arr[i];
- }
- float sum = St(A, B) + St(B, C) + St(C, D) + St(A, D) - max; //четырехугольник существует, если длина одной из его сторон меньше, чем сумма длин трех остальных
- if (sum > max && neparX != neparY) return true;
- else return false;
- }
- public float Square() //метод для вычисления площади четырехугольника
- {
- if (Proverka(A, B, C))
- {
- float P = St(A, B) + St(B, C) + St(C, D) + St(A, D);
- float p = P / 2;
- float S = (float)Math.Sqrt((p - St(A, B)) * (p - St(B, C)) * (p - St(C, D)) * (p - St(A, D)));
- return S;
- }
- else return 0;
- }
- }
- class Parallelogram : Quadr //класс ПАРАЛЛЕЛОГРАММ
- {
- public Parallelogram(Point A, Point B, Point C, Point D)
- : base(A, B, C, D) { }
- public bool Proverka()
- {
- if (St(A, B) == St(C, D) && St(B, C) == St(A, D)) return true;
- else return false;
- }
- public float Sq(Point X, Point Y, Point Z, Point Q)
- {
- if (Proverka())
- {
- //float a = Y.Y - X.Y;
- float AB = St(A, B);
- float h = (float)Math.Sqrt(Math.Pow(X.X - Q.X, 2) + Math.Pow(X.Y - Q.Y, 2));
- float ss = AB * h;
- return ss;
- }
- else return 0;
- }
- public bool Romb(Point A, Point B, Point C, Point D) //окружность может быть вписаной, если параллелограмм - ромб
- {
- if (St(A, B) == St(B, C) && St(A, B) == St(A, D) && St(A, B) == St(C, D))
- {
- return true;
- }
- else return false;
- }
- }
- class Circle //класс ОКРУЖНОСТЬ
- {
- protected float R;
- public Circle(float R) { this.R = R; }
- public float getR()
- {
- return R;
- }
- public float Square()
- {
- float Sr = (float)(Math.PI * Math.Pow(R, 2)) / 10;
- return Sr;
- }
- public float Dlina()
- {
- float Dr = (float)(2 * Math.PI * R);
- return Dr;
- }
- public float Change(Parallelogram p) //изменение радиуса в зависимости от переданного параллелограмма
- {
- return R = (p.St(p.A, p.C) * p.St(p.B, p.D)) / (2 * p.St(p.A, p.B));
- }
- }
- private void Quadrr_Click(object sender, EventArgs e) //ЧЕТЫРЕХУГОЛЬНИК
- {
- Graphics clear = Graphics.FromHwnd(Picture.Handle);
- clear.Clear(BackColor);
- listBox.Items.Clear();
- Point A1 = new Point(50, 50);
- Point B1 = new Point(350, 100);
- Point C1 = new Point(300, 350);
- Point D1 = new Point(150, 350);
- Quadr ABCD1 = new Quadr(A1, B1, C1, D1);
- ABCD1.Proverka(A1, B1, C1);
- Graphics qq = Picture.CreateGraphics();
- Pen pen = new Pen(Color.Black, 3f);
- Point[] points = { A1, B1, C1, D1 };
- qq.DrawPolygon(pen, points);
- qq.Dispose();
- if (ABCD1.Proverka(A1, B1, C1))
- {
- listBox.Items.Add("Четырехугольник существует\n");
- listBox.Items.Add(" ");
- listBox.Items.Add("Стороны: AB = " + ABCD1.St(A1, B1));
- listBox.Items.Add(" BC = " + ABCD1.St(B1, C1));
- listBox.Items.Add(" CD = " + ABCD1.St(C1, D1));
- listBox.Items.Add(" AD = " + ABCD1.St(A1, D1));
- listBox.Items.Add(" ");
- listBox.Items.Add("Диагонали: AC = " + ABCD1.St(A1, C1));
- listBox.Items.Add(" BD = " + ABCD1.St(B1, D1));
- listBox.Items.Add(" ");
- listBox.Items.Add("Периметр: P = " + (ABCD1.St(A1, B1) + ABCD1.St(B1, C1) + ABCD1.St(C1, D1) + ABCD1.St(A1, D1)));
- listBox.Items.Add(" ");
- listBox.Items.Add("Площадь: S = " + ABCD1.Square());
- }
- else listBox.Items.Add("Четырехугольник не существует");
- }
- private void Parallelogramm_Click(object sender, EventArgs e) //ПАРАЛЛЕЛОГРАММ
- {
- Graphics clear = Graphics.FromHwnd(Picture.Handle);
- clear.Clear(BackColor);
- listBox.Items.Clear();
- Point a1 = new Point(150, 50);
- Point b1 = new Point(350, 50);
- Point c1 = new Point(250, 350);
- Point d1 = new Point(50, 350);
- Parallelogram abcd1 = new Parallelogram(a1, b1, c1, d1);
- abcd1.Proverka();
- float ss1 = abcd1.Sq(a1, b1, c1, d1);
- Graphics pp = Picture.CreateGraphics();
- Pen pen = new Pen(Color.Black, 3f);
- Point[] points = { a1, b1, c1, d1 };
- pp.DrawPolygon(pen, points);
- pp.Dispose();
- if(abcd1.Proverka())
- {
- listBox.Items.Add("Фигура - параллелограмм");
- listBox.Items.Add(" ");
- listBox.Items.Add("Стороны: AB = " + abcd1.St(a1, b1));
- listBox.Items.Add(" BC = " + abcd1.St(b1, c1));
- listBox.Items.Add(" CD = " + abcd1.St(c1, d1));
- listBox.Items.Add(" AD = " + abcd1.St(a1, d1));
- listBox.Items.Add(" ");
- listBox.Items.Add("Площадь: S = " + ss1);
- }
- else listBox.Items.Add("Фигура - не параллелограмм");
- }
- private void Circlee_Click(object sender, EventArgs e) //ОКРУЖНОСТЬ
- {
- Graphics clear = Graphics.FromHwnd(Picture.Handle);
- clear.Clear(BackColor);
- listBox.Items.Clear();
- float rr = 200;
- Circle okr = new Circle(rr);
- Graphics oo = Picture.CreateGraphics();
- Pen pen = new Pen(Color.Black, 3f);
- RectangleF rect = new RectangleF(100, 100, rr, rr);
- oo.DrawEllipse(pen, rect);
- oo.Dispose();
- listBox.Items.Add("Радиус: R = " + okr.getR());
- listBox.Items.Add(" ");
- listBox.Items.Add("Длина: L = " + okr.Dlina());
- listBox.Items.Add(" ");
- listBox.Items.Add("Площадь: S = " + okr.Square());
- }
- private void вписаннаяОкружностьToolStripMenuItem_Click(object sender, EventArgs e) //ВПИСАННАЯ ОКРУЖНОСТЬ
- {
- Graphics clear = Graphics.FromHwnd(Picture.Handle);
- clear.Clear(BackColor);
- listBox.Items.Clear();
- Point a = new Point(200, 50);
- Point b = new Point(350, 200);
- Point c = new Point(200, 350);
- Point d = new Point(50, 200);
- Parallelogram abcd = new Parallelogram(a, b, c, d);
- abcd.Romb(a, b, c, d);
- float rr = 200; ;
- Circle okr = new Circle(rr);
- float R = okr.Change(abcd);
- Graphics oo = Picture.CreateGraphics();
- Pen pen = new Pen(Color.Black, 3f);
- RectangleF rect = new RectangleF(94, 94, R, R);
- oo.DrawEllipse(pen, rect);
- oo.Dispose();
- Graphics pp = Picture.CreateGraphics();
- Point[] points = { a, b, c, d };
- pp.DrawPolygon(pen, points);
- pp.Dispose();
- if(abcd.Romb(a, b, c, d))
- {
- listBox.Items.Add("Парраллелограмм - ромб");
- listBox.Items.Add(" ");
- listBox.Items.Add("Информация о вписанной окружности:");
- listBox.Items.Add(" ");
- listBox.Items.Add("Радиус: R = " + okr.getR());
- listBox.Items.Add(" ");
- listBox.Items.Add("Длина: L = " + okr.Dlina());
- listBox.Items.Add(" ");
- listBox.Items.Add("Площадь: S = " + okr.Square());
- }
- else listBox.Items.Add("Парраллелограмм - не ромб");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement