Exemplo n.º 1
0
        private void DrawScale(double minArea, double maxArea, double averageArea)
        {
            double deviation1 = maxArea - averageArea;
            double deviation2 = averageArea - minArea;
            double deviation  = deviation1 > deviation2 ? deviation1 : deviation2;

            minArea = averageArea - deviation;
            maxArea = averageArea + deviation;

            double step = (maxArea - minArea) / 800;

            List <Color>  colorArray = new List <Color>();
            List <double> values     = new List <double>();

            for (int i = 0; i < 800; i++)
            {
                double current = minArea + step * i;
                colorArray.Add(GenerateEnhancedColorFor(current, minArea, maxArea, averageArea));
                values.Add(current / averageArea - 1);
            }

            IllustrationForm bisectForm = new IllustrationForm();
            //using (IllustrationForm illustrationForm = new IllustrationForm())
            {
                bisectForm.colorArray = colorArray;
                bisectForm.values     = values;
                bisectForm.fill       = true;
                bisectForm.lines      = false;
                bisectForm.Text       = "Scale";
                bisectForm.Show();
            }
        }
Exemplo n.º 2
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);
        }