Exemple #1
0
        public static double perimeter(clsPoint xA, clsPoint xB, clsPoint xC)
        {
            double p;

            p = (Space(xA, xB) + Space(xA, xC) + Space(xB, xC));
            return(p);
        }
Exemple #2
0
        public static double Howfar(clsPoint a, clsPoint b)
        {
            double result;

            result = Math.Sqrt(Math.Pow(a.ix - b.ix, 2) + Math.Pow(a.iy - b.iy, 2));
            return(result);
        }
Exemple #3
0
        public static double area(clsPoint xA, clsPoint xB, clsPoint xC)
        {
            double p = perimeter(xA, xB, xC) / 2;

            double area = Math.Sqrt(p * (p - Space(xA, xB)) * (p - Space(xA, xB)) * (p - Space(xB, xC)));

            return(area);
        }
Exemple #4
0
 public void Draw(clsPoint a, clsPoint b, clsPoint c)
 {
     using (Graphics g = panel1.CreateGraphics())
     {
         g.DrawLine(new Pen(Color.Black, 5), new Point(a.ix, a.iy), new Point(b.ix, b.iy));
         g.DrawLine(new Pen(Color.Black, 5), new Point(c.ix, c.iy), new Point(b.ix, b.iy));
         g.DrawLine(new Pen(Color.Black, 5), new Point(c.ix, c.iy), new Point(a.ix, a.iy));
     }
 }
Exemple #5
0
 void Button1Click(object sender, EventArgs e)
 {
     Refresh();
     if (txtAx.Text == "" || txtAy.Text == "" || txtBx.Text == "" || txtBy.Text == "" || txtCx.Text == "" || txtCy.Text == "")
     {
         ClearData();
     }
     else
     {
         clsPoint a = new clsPoint();
         clsPoint b = new clsPoint();
         clsPoint c = new clsPoint();
         a.ix = int.Parse(txtAx.Text);
         a.iy = int.Parse(txtAy.Text);
         b.iy = int.Parse(txtBy.Text);
         b.ix = int.Parse(txtBx.Text);
         c.ix = int.Parse(txtCx.Text);
         c.iy = int.Parse(txtCy.Text);
         Space(a, b, c);
         txtPerimeter.Text = clsRectangle.perimeter(a, b, c).ToString();
         txtArea.Text      = clsRectangle.area(a, b, c).ToString();
         Draw(a, b, c);
     }
 }
Exemple #6
0
 public void Space(clsPoint xA, clsPoint xB, clsPoint xC)
 {
     txtBC.Text = clsRectangle.Space(xB, xC).ToString();
     txtAB.Text = clsRectangle.Space(xA, xB).ToString();
     txtAC.Text = clsRectangle.Space(xA, xC).ToString();
 }
Exemple #7
0
 public clsRectangle(clsPoint xA, clsPoint xB, clsPoint xC)
 {
     A = xA;
     B = xB;
     C = xC;
 }
Exemple #8
0
 public static double Space(clsPoint xA, clsPoint xB)
 {
     return(Math.Sqrt(Math.Pow(xB.ix - xA.ix, 2) + Math.Pow(xB.iy - xA.iy, 2)));
 }