Exemplo n.º 1
0
        private int visibility(pointcode p1, pointcode p2)
        {
            int i, flag = 0;

            for (i = 0; i < 4; i++)
            {
                if ((p1.code[i] != '0') || (p2.code[i] != '0'))
                {
                    flag = 1;
                }
            }

            if (flag == 0)
            {
                return(0);
            }

            for (i = 0; i < 4; i++)
            {
                if ((p1.code[i] == p2.code[i]) && (p1.code[i] == '1'))
                {
                    flag = 0;
                }
            }

            if (flag == 0)
            {
                return(1);
            }

            return(2);
        }
Exemplo n.º 2
0
        private pointcode resetendpt(pointcode p1, pointcode p2, Point max, Point min)
        {
            pointcode temp = new pointcode();
            int       x = 0, y = 0, i = 0;
            float     m = 0, k = 0;

            if (p1.code[3] == '1')
            {
                x = min.X;
            }

            if (p1.code[2] == '1')
            {
                x = max.X;
            }

            if ((p1.code[3] == '1') || (p1.code[2] == '1'))
            {
                m      = (float)(p2.y - p1.y) / (p2.x - p1.x);
                k      = (p1.y + (m * (x - p1.x)));
                temp.y = Convert.ToInt32(k);
                temp.x = x;

                for (i = 0; i < 4; i++)
                {
                    temp.code[i] = p1.code[i];
                }

                if (temp.y <= max.Y && temp.y >= min.Y)
                {
                    return(temp);
                }
            }

            if (p1.code[0] == '1')
            {
                y = min.Y;
            }

            if (p1.code[1] == '1')
            {
                y = max.Y;
            }

            if ((p1.code[0] == '1') || (p1.code[1] == '1'))
            {
                m      = (float)(p2.y - p1.y) / (p2.x - p1.x);
                k      = (float)p1.x + (float)(y - p1.y) / m;
                temp.x = Convert.ToInt32(k);
                temp.y = y;

                for (i = 0; i < 4; i++)
                {
                    temp.code[i] = p1.code[i];
                }

                return(temp);
            }
            else
            {
                return(p1);
            }
        }
Exemplo n.º 3
0
 public points()
 {
     p1 = new pointcode();
     p2 = new pointcode();
 }