Exemple #1
0
        public double Distance(Pointl first, Pointl second)//两点距离
        {
            double dis;

            dis = Math.Sqrt((second.Y - first.Y) * (second.Y - first.Y) + (second.X - first.X) * (second.X - first.X));
            return(dis);
        }
Exemple #2
0
        public int ZuoYou(Pointl cen, Pointl first, Pointl second)//判断左右
        {
            double s;

            s = (first.X - cen.X) * (second.Y - cen.Y) - (first.Y - cen.Y) * (second.X - cen.X);
            if (s > 0)
            {
                return(1);//zuoce
            }
            else
            {
                return(2);
            }
        }
Exemple #3
0
        public double Angle(Pointl cen, Pointl first, Pointl second)//三个点的夹角CEN为顶点,算的是夹角
        {
            double dx1, dx2, dy1, dy2;
            double angle;

            dx1 = first.X - cen.X;
            dy1 = first.Y - cen.Y;
            dx2 = second.X - cen.X;
            dy2 = second.Y - cen.Y;
            float c = (float)Math.Sqrt(dx1 * dx1 + dy1 * dy1) * (float)Math.Sqrt(dx2 * dx2 + dy2 * dy2);

            if (c == 0)
            {
                return(-1);

                MessageBox.Show("jinggao");
            }
            else
            {
                angle = (float)Math.Acos((dx1 * dx2 + dy1 * dy2) / c);
                return(angle);
            }
        }
Exemple #4
0
        private void Form1_Load(object sender, EventArgs e)//窗体加载事件
        {
            g = Graphics.FromImage(bitmap);
            g.RotateTransform(-90);
            g.TranslateTransform(-800, 0);
            double[,] ar = new double[, ] {
                #region
                { 414.28, 421.88, 39.555 }
                , { 387.80, 425.02, 36.8774 }
                , { 359.06, 426.62, 31.225 }
                , { 348.04, 425.53, 27.416 }
                , { 344.57, 440.31, 27.7945 }
                , { 352.89, 454.84, 28.4999 }
                , { 402.88, 442.45, 37.951 }
                , { 393.47, 393.86, 32.5395 }
                , { 358.85, 387.57, 29.426 }
                , { 358.59, 376.62, 29.223 }
                , { 348.66, 364.21, 28.2538 }
                , { 362.80, 340.89, 26.8212 }
                , { 335.73, 347.62, 26.2299 }
                , { 331.84, 362.69, 26.6612 }
                , { 351.82, 402.35, 28.4848 }
                , { 335.09, 399.61, 26.6922 }
                , { 331.15, 333.34, 24.6894 }
                , { 344.10, 322.26, 24.3684 }
                , { 326.80, 381.66, 26.7581 }
                , { 396.59, 331.42, 28.7137 }
                , { 372.70, 317.25, 25.8215 }
                , { 404.54, 313.74, 26.9055 }
                , { 416.04, 349.16, 31.7509 }
                , { 424.70, 367.77, 34.8919 }
                , { 414.85, 383.5, 37.4818 }
                , { 399.59, 370.21, 32.5866 }
                , { 386.89, 353.32, 30.5459 }
                , { 383.23, 336.82, 29.2504 }
                , { 421.13, 322.59, 27.7593 }
                , { 468.29, 316.53, 27.0276 }
                , { 434.93, 313.32, 26.5662 }
                , { 456.71, 324.05, 28.8742 }
                , { 491.54, 372.23, 33.0459 }
                , { 470.83, 363.75, 32.6194 }
                , { 414.07, 397.87, 39.5041 }
                , { 446.84, 368.77, 34.5865 }
                , { 438, 313.25, 30.1398 }
                , { 456.08, 344.36, 30.1871 }
                , { 472.76, 401.02, 38.5963 }
                , { 479.13, 432.82, 42.3405 }
                , { 499.63, 422.7, 40.7577 }
                , { 492.35, 402.93, 37.9286 }
                , { 489.32, 390.16, 36.34 }
                , { 449.70, 383.25, 36.9367 }
                , { 444.56, 406.78, 41.6945 }
                , { 464.50, 427.23, 43.5075 }
                , { 503.60, 439.93, 41.0365 }
                , { 515.85, 437.89, 39.9929 }
                , { 505.89, 493.01, 33.8673 }
                , { 485.63, 490.18, 36.4479 }
                , { 493.83, 472.49, 39.8801 }
                , { 482.52, 450.67, 42.3327 }
                , { 508.10, 461.98, 40.2172 }
                , { 513.7, 382.32, 36.919 }
                , { 532.14, 466.79, 37.7726 }
                , { 547.81, 446.42, 38.3385 }
                , { 555.09, 429.29, 37.5484 }
                , { 550.59, 466.8, 37.233 }
                , { 542.39, 490.08, 33.8351 }
                , { 562.32, 481.02, 34.4659 }
                , { 582.49, 461.23, 34.1418 }
                , { 585.43, 474.09, 32.5303 }
                , { 596.28, 464.84, 31.7542 }
                , { 573.76, 494.1, 31.3335 }
                , { 567.67, 505.61, 29.5076 }
                , { 435.85, 465.51, 40.6101 }
                , { 446.92, 438.86, 43.5085 }
                , { 451.21, 462.16, 42.1787 }
                , { 425.14, 442.84, 42.2289 }
                , { 465.83, 471.64, 41.4353 }
                , { 444.54, 478.39, 39.4434 }
                , { 436.92, 489.73, 35.15 }
                , { 446.87, 502.75, 32.0204 }
                , { 424.80, 499.59, 31.1902 }
                , { 415.55, 477.23, 36.1728 }
                , { 405.41, 459.37, 36.2749 }
                , { 407.98, 487.67, 31.2808 }
                , { 410.21, 511.39, 29.09 }
                , { 392.51, 495.92, 29.1024 }
                , { 434.96, 524.73, 28.8913 }
                , { 415.92, 523.57, 28.6408 }
                , { 381.47, 504.81, 28.3432 }
                , { 365.02, 495.85, 27.6838 }
                , { 352.99, 500.58, 26.1047 }
                , { 348.82, 486.82, 26.2623 }
                , { 350.47, 471.08, 27.5493 }
                , { 357.64, 521.57, 25.8516 }
                , { 387.14, 526.14, 25.9322 }
                , { 418.40, 538.09, 25.2847 }
                , { 448.49, 533.77, 25.8802 }
                , { 465.16, 494.46, 34.603 }
                , { 458.79, 508.1, 31.0874 }
                , { 503.63, 519.64, 28.9581 }
                , { 504.38, 505.74, 29.4945 }
                , { 487.85, 513.90, 29.3574 }
                , { 473.73, 522.38, 28.2401 }
                , { 474.65, 534.46, 28.1753 }
                , { 501.33, 537.72, 27.601 }
                , { 526.89, 530.08, 29.1993 }
                , { 538.63, 519.63, 29.2767 }
                , { 327.38, 431.95, 26.6129 }
                , { 326.22, 419.39, 26.2965 }
                , { 591.41, 400.14, 31.3133 }
                , { 580.18, 375.51, 30.2236 }
                , { 603.18, 381.36, 28.8233 }
                , { 529.15, 341.71, 27.0601 }
                , { 583.86, 408.9, 33.6867 }
                , { 565.07, 419.84, 36.2957 }
                , { 544.34, 402.71, 36.3476 }
                , { 568.31, 403.82, 34.7975 }
                , { 517.51, 388.7, 35.1603 }
                , { 521.11, 366.48, 31.672 }
                , { 539.64, 349.28, 29.138 }
                , { 506.62, 335.71, 26.9185 }
                , { 505.15, 350.97, 29.6483 }
                , { 494.79, 379.74, 33.5259 }
                , { 511.44, 374.64, 33.1928 }
                , { 493.14, 354.75, 30.8649 }
                , { 549.66, 508.67, 30.3146 }
                , { 369.18, 500.28, 27.7 }
                , { 442.80, 431.06, 43.90 }
                , { 455.78, 444.08, 43.460 }
                , { 461.02, 374.57, 35.5 }
                , { 437.30, 388.9, 38.2 }
                , { 399.61, 407.54, 37 }
                , { 514.12, 450.64, 40.1 }
            };
            #endregion
            double avg = 0;
            for (int q1 = 0; q1 < ar.Length / 3; q1++) //length表示所有元素的总数
            {
                avg += ar[q1, 2];                      //求高程的平均值
            }
            avg           /= ar.Length / 3;
            textBox14.Text = avg.ToString();

            Pointl[]  a = new Pointl[ar.Length / 3];//一次实例化多个相同类
            ArrayList S = new ArrayList();
            for (int i = 0; i < ar.Length / 3; i++)
            {
                a[i]   = new Pointl();
                a[i].X = (float)ar[i, 0];
                a[i].Y = (float)ar[i, 1];
                a[i].Z = (float)ar[i, 2];
            }
            foreach (object ab in a)
            {
                list.Add(ab);//列表又存储一次数据
            }
        }