Esempio n. 1
0
        private void SavePointsButton_Click(object sender, EventArgs e)
        {
            using (SaveFileDialog sfd = new SaveFileDialog())
            {
                if (sfd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                Geodesic      geodesic = new Geodesic(Convert.ToInt32(GenerationBox.Text));
                List <string> lines    = new List <string>();

                for (int i = 0; i < geodesic.MaxGridIndex; i++)
                {
                    GridIndex            index    = geodesic.GetGridIndex(i);
                    GeodesicGridTriangle triangle = index.GeodesicGridTriangle;

                    foreach (Vector3D point in triangle.Points)
                    {
                        lines.Add(point.ToString());
                    }
                }

                System.IO.File.WriteAllLines(sfd.FileName, lines);
            }
        }
Esempio n. 2
0
        public Variance VarianceOf(Geodesic geodesic)
        {
            List <double> areas     = new List <double>();
            double        totalArea = 0;
            double        maxArea   = -10;
            double        minArea   = 10;

            double lengthMin   = 10;
            double lengthMax   = 0;
            double lengthTotal = 0;

            for (int i = 0; i < geodesic.MaxGridIndex; i++)
            {
                GridIndex            index    = geodesic.GetGridIndex(i);
                GeodesicGridTriangle triangle = index.GeodesicGridTriangle;
                double area = triangle.Area;
                areas.Add(area);
                totalArea += area;
                if (area > maxArea)
                {
                    maxArea = area;
                }
                if (area < minArea)
                {
                    minArea = area;
                }

                double a = (triangle.PointCA - triangle.PointAB).Magnitude;
                double b = (triangle.PointAB - triangle.PointBC).Magnitude;
                double c = (triangle.PointBC - triangle.PointCA).Magnitude;

                double maxLength = a > b ? a > c ? a : c : b > c ? b : c;
                double minLength = a < b ? a < c ? a : c : b < c ? b : c;
                if (maxLength > lengthMax)
                {
                    lengthMax = maxLength;
                }
                if (minLength < lengthMin)
                {
                    lengthMin = minLength;
                }

                lengthTotal += a + b + c;
            }
            Variance variance = new Variance();

            variance.variance = maxArea / minArea;

            variance.max     = maxArea;
            variance.min     = minArea;
            variance.average = totalArea / geodesic.MaxGridIndex;

            variance.lengthMin     = lengthMin;
            variance.lengthMax     = lengthMax;
            variance.lengthAverage = lengthTotal / geodesic.MaxGridIndex / 3;

            return(variance);
        }
Esempio n. 3
0
        private void Button5_Click(object sender, EventArgs e)
        {
            Geodesic      geodesic = new Geodesic(1);
            List <string> areas    = new List <string>();

            for (int i = 0; i < geodesic.MaxGridIndex; i++)
            {
                GridIndex            index    = geodesic.GetGridIndex(i);
                GeodesicGridTriangle triangle = index.GeodesicGridTriangle;
                areas.Add(triangle.Area.ToString());
            }

            using (SaveFileDialog sfd = new SaveFileDialog())
            {
                if (sfd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                System.IO.File.WriteAllLines(sfd.FileName, areas);
            }
        }
Esempio n. 4
0
        private void DrawAreaVarianceButton_Click(object sender, EventArgs e)
        {
            int      generation = Convert.ToInt32(GenerationBox.Text);
            Geodesic geodesic   = new Geodesic(generation - 2);

            BisectGeodesic bisectGeodesic = new BisectGeodesic(generation);

            List <DrawTriangle> triangles       = new List <DrawTriangle>();
            List <DrawTriangle> bisectTriangles = new List <DrawTriangle>();

            double minArea         = 10;
            double maxArea         = 0;
            double totalArea       = 0;
            double totalBisectArea = 0;

            for (int i = 0; i < geodesic.MaxGridIndex; i++)
            {
                GridIndex            index    = geodesic.GetGridIndex(i);
                GeodesicGridTriangle triangle = index.GeodesicGridTriangle;
                double area = triangle.Area;
                if (area < minArea)
                {
                    minArea = area;
                }
                if (area > maxArea)
                {
                    maxArea = area;
                }
                totalArea += area;
            }

            foreach (SphericalTriangle triangle in bisectGeodesic.SphericalTriangles)
            {
                double area = triangle.Area;
                if (area < minArea)
                {
                    minArea = area;
                }
                if (area > maxArea)
                {
                    maxArea = area;
                }
                totalBisectArea += area;
            }

            double averageArea       = totalArea / geodesic.MaxGridIndex;
            double averageBisectArea = totalBisectArea / bisectGeodesic.SphericalTriangles.Count;

            for (int i = 0; i < geodesic.MaxGridIndex; i++)
            {
                GridIndex            index        = geodesic.GetGridIndex(i);
                GeodesicGridTriangle triangle     = index.GeodesicGridTriangle;
                DrawTriangle         drawTriangle = new DrawTriangle()
                {
                    point1 = triangle.PointAB,
                    point2 = triangle.PointBC,
                    point3 = triangle.PointCA
                };
                drawTriangle.fillColor = GenerateEnhancedColorFor(triangle.Area, minArea, maxArea, averageArea);
                triangles.Add(drawTriangle);
            }

            foreach (SphericalTriangle triangle in bisectGeodesic.SphericalTriangles)
            {
                DrawTriangle drawTriangle = new DrawTriangle()
                {
                    point1 = triangle.A,
                    point2 = triangle.B,
                    point3 = triangle.C
                };
                drawTriangle.fillColor = GenerateEnhancedColorFor(triangle.Area, minArea, maxArea, averageBisectArea);
                bisectTriangles.Add(drawTriangle);
            }


            IllustrationForm illustrationForm = new IllustrationForm();
            //using (IllustrationForm illustrationForm = new IllustrationForm())
            {
                illustrationForm.triangles = triangles;
                illustrationForm.fill      = true;
                illustrationForm.lines     = false;
                illustrationForm.Text      = "Cut Geodesic Grid";
                illustrationForm.Show();
            }

            IllustrationForm bisectForm = new IllustrationForm();

            //using (IllustrationForm illustrationForm = new IllustrationForm())
            {
                bisectForm.triangles = bisectTriangles;
                bisectForm.fill      = true;
                bisectForm.lines     = false;
                bisectForm.Text      = "Bisect Geodesic Grid";
                bisectForm.Show();
            }

            DrawScale(minArea, maxArea, averageArea);
        }