示例#1
0
        public static double Area(MySpace a, MySpace b, MySpace c)
        {
            double s1;
            double s2;
            double s3;
            double sin;
            double cos;

            s1  = Math.Sqrt(Math.Pow(a.x - b.x, 2) + Math.Sqrt(Math.Pow(a.y - b.y, 2) + Math.Sqrt(Math.Pow(a.z - b.z, 2))));
            s2  = Math.Sqrt(Math.Pow(c.x - b.x, 2) + Math.Sqrt(Math.Pow(c.y - b.y, 2) + Math.Sqrt(Math.Pow(c.z - b.z, 2))));
            s3  = Math.Sqrt(Math.Pow(a.x - c.x, 2) + Math.Sqrt(Math.Pow(a.y - c.y, 2) + Math.Sqrt(Math.Pow(a.z - c.z, 2))));
            cos = (Math.Pow(s1, 2) + Math.Pow(s2, 2) - Math.Pow(s3, 2));
            sin = Math.Sqrt(1 - Math.Pow(cos, 2));
            return(1 / 2 * s1 * s2 * sin);
        }
示例#2
0
 public static void MaxMin(out MySpace a, out MySpace b, MySpace[] c, int d)
 {
     a = c[0];
     b = c[0];
     for (int i = 0; i < d; i++)
     {
         if (Distance(a) <= Distance(c[i]))
         {
             a = c[i];
         }
         if (Distance(b) >= Distance(c[i]))
         {
             b = c[i];
         }
     }
 }
示例#3
0
        public static void MaxTriangle(MySpace a, MySpace[] b, int c)
        {
            double area = Area(b[0], b[1], b[3]);

            for (int i = 0; i < c; i++)
            {
                for (int m = i + 1; m < c; m++)
                {
                    for (int k = m + 1; k < c; k++)
                    {
                        if (area < Area(b[i], b[m], b[k]))
                        {
                            area = Area(b[i], b[m], b[k]);
                        }
                    }
                }
            }
            Console.WriteLine(area);
        }
示例#4
0
 public static double Distance(MySpace a, MySpace b)
 {
     return(Math.Sqrt(Math.Pow(a.x - b.x, 2) + Math.Pow(a.y - b.y, 2) + Math.Pow(a.z - b.z, 2)));
 }
示例#5
0
 public static void Print(MySpace a)
 {
     Console.WriteLine("X=" + a.x + "Y=" + a.y + "Z=" + a.z);
 }