Beispiel #1
0
        private spacing GetXSpacing()
        {
            spacing x = new spacing();

            x.B = Convert.ToDouble(textBoxXSt.Text);
            x.E = Convert.ToDouble(textBoxXEnd.Text);
            x.D = Convert.ToDouble(textBoxXDelta.Text);
            return(x);
        }
Beispiel #2
0
        private spacing GetZSpacing()
        {
            spacing z = new spacing();

            z.B = Convert.ToDouble(textBoxYStart.Text);
            z.E = Convert.ToDouble(textBoxYEnd.Text);
            z.D = Convert.ToDouble(textBoxYDelta.Text);
            return(z);
        }
Beispiel #3
0
        public void Go()
        {
            canvas.Refresh();
            g.Clear(Color.White);
            spacing x = GetXSpacing();
            spacing z = GetZSpacing();

            double ox = Convert.ToDouble(numericUpDownX.Value);
            double oy = Convert.ToDouble(numericUpDownY.Value);
            double oz = Convert.ToDouble(numericUpDownZ.Value);
            var    f  = GetFunction();

            horizon = new Horizont(penDraw, canvas.Size, f);
            horizon.HorizonAlgo(x, z, g, ox, oy, oz);
            canvas.Refresh();
        }
Beispiel #4
0
        public void HorizonAlgo(spacing parX, spacing parZ, Graphics painter, double tetax, double tetay, double tetaz)
        {
            prepareArrays();

            int x_left = -1, y_left = -1, x_right = -1, y_right = -1;
            int x_prev = 0, y_prev = 0;

            for (double z = parZ.E; z >= parZ.B; z -= parZ.D)
            {
                double y_p = f(parX.B, z);
                transform(ref parX.B, ref y_p, ref z, tetax, tetay, tetaz, ref x_prev, ref y_prev);
                ProcessEdge(ref x_prev, ref y_prev, ref x_left, ref y_left, painter);
                int Pflag = Visible(x_prev, y_prev);
                for (double x = parX.B; x <= parX.E; x += parX.D)
                {
                    int x_curr = 0, y_curr = 0;
                    int xi = 0, yi = 0;
                    y_p = f(x, z);
                    transform(ref x, ref y_p, ref z, tetax, tetay, tetaz, ref x_curr, ref y_curr);
                    int Tflag = Visible(x_curr, y_curr);
                    if (Tflag == Pflag)
                    {
                        if (Pflag != 0)
                        {
                            horizon(x_prev, y_prev, x_curr, y_curr, painter);
                        }
                    }
                    else if (Tflag == 0)
                    {
                        if (Pflag == 1)
                        {
                            GetIntersection(x_prev, y_prev, x_curr, y_curr, TOP, ref xi, ref yi);
                        }
                        else
                        {
                            GetIntersection(x_prev, y_prev, x_curr, y_curr, DOWN, ref xi, ref yi);
                        }
                        horizon(x_prev, y_prev, xi, yi, painter);
                    }
                    else if (Tflag == 1)
                    {
                        if (Pflag == 0)
                        {
                            GetIntersection(x_prev, y_prev, x_curr, y_curr, TOP, ref xi, ref yi);
                            horizon(x_prev, y_prev, xi, yi, painter);
                        }
                        else
                        {
                            GetIntersection(x_prev, y_prev, x_curr, y_curr, TOP, ref xi, ref yi);
                            horizon(x_prev, y_prev, xi, yi, painter);
                            GetIntersection(x_prev, y_prev, x_curr, y_curr, DOWN, ref xi, ref yi);
                            horizon(xi, yi, x_curr, y_curr, painter);
                        }
                    }
                    else
                    {
                        if (Pflag == 0)
                        {
                            GetIntersection(x_prev, y_prev, x_curr, y_curr, DOWN, ref xi, ref yi);
                            horizon(x_prev, y_prev, xi, yi, painter);
                        }
                        else
                        {
                            GetIntersection(x_prev, y_prev, x_curr, y_curr, TOP, ref xi, ref yi);
                            horizon(x_prev, y_prev, xi, yi, painter);
                            GetIntersection(x_prev, y_prev, x_curr, y_curr, DOWN, ref xi, ref yi);
                            horizon(xi, yi, x_curr, y_curr, painter);
                        }
                    }
                    Pflag  = Tflag;
                    x_prev = x_curr;
                    y_prev = y_curr;
                }
                ProcessEdge(ref x_prev, ref y_prev, ref x_right, ref y_right, painter);
            }
        }